17
17
package com .google .errorprone .apply ;
18
18
19
19
import com .google .common .base .CharMatcher ;
20
- import com .google .common .base .Function ;
21
20
import com .google .common .base .Preconditions ;
22
21
import com .google .common .collect .ImmutableSet ;
23
22
import com .google .common .collect .Lists ;
24
23
import com .sun .tools .javac .tree .EndPosTable ;
24
+ import com .sun .tools .javac .tree .JCTree ;
25
25
import com .sun .tools .javac .tree .JCTree .JCCompilationUnit ;
26
26
import com .sun .tools .javac .tree .JCTree .JCExpression ;
27
- import com .sun .tools .javac .tree .JCTree .JCImport ;
28
27
import java .util .Collection ;
29
28
import java .util .LinkedHashSet ;
30
29
import java .util .List ;
@@ -64,7 +63,7 @@ public static ImportStatements create(
64
63
65
64
ImportStatements (
66
65
JCExpression packageTree ,
67
- List <JCImport > importTrees ,
66
+ List <? extends JCTree > importTrees ,
68
67
EndPosTable endPositions ,
69
68
ImportOrganizer importOrganizer ) {
70
69
@@ -80,7 +79,7 @@ public static ImportStatements create(
80
79
} else {
81
80
// process list of imports and find start/end positions
82
81
hasExistingImports = true ;
83
- for (JCImport importTree : importTrees ) {
82
+ for (JCTree importTree : importTrees ) {
84
83
int currStartPos = importTree .getStartPosition ();
85
84
int currEndPos = importTree .getEndPosition (endPositions );
86
85
@@ -99,14 +98,9 @@ public static ImportStatements create(
99
98
importStrings .addAll (
100
99
Lists .transform (
101
100
importTrees ,
102
- new Function <JCImport , String >() {
103
- @ Override
104
- public String apply (JCImport input ) {
105
- String importExpr = input .toString ();
106
- return CharMatcher .whitespace ()
107
- .or (CharMatcher .is (';' ))
108
- .trimTrailingFrom (importExpr );
109
- }
101
+ input -> {
102
+ String importExpr = input .toString ();
103
+ return CharMatcher .whitespace ().or (CharMatcher .is (';' )).trimTrailingFrom (importExpr );
110
104
}));
111
105
112
106
originalImports = ImmutableSet .copyOf (importStrings );
0 commit comments