File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
main/java/com/google/googlejavaformat/java
test/java/com/google/googlejavaformat/java Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -227,10 +227,6 @@ private ImportsAndIndex scanImports(int i) throws FormatterException {
227227 if (isNewlineToken (i )) {
228228 trailing .append (tokenAt (i ));
229229 i ++;
230- } else if (tokenAt (i ).equals ("import" )) {
231- // continue
232- } else {
233- throw new FormatterException ("Extra tokens after import: " + tokenAt (i ));
234230 }
235231 imports .add (new Import (importedName , trailing .toString (), isStatic ));
236232 // Remember the position just after the import we just saw, before skipping blank lines.
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ public static ImmutableList<RawTok> getTokens(
9999 }
100100 if (stopTokens .contains (t .kind )) {
101101 if (t .kind != TokenKind .EOF ) {
102- end = t .endPos - 1 ;
102+ end = t .pos ;
103103 }
104104 break ;
105105 }
Original file line number Diff line number Diff line change @@ -286,7 +286,7 @@ public static Collection<Object[]> parameters() {
286286 "import com.foo.First;" ,
287287 },
288288 {
289- "!!Extra tokens after import: /* no block comments after imports */ " ,
289+ "!!Imports not contiguous (perhaps a comment separates them?) " ,
290290 }
291291 },
292292 {
@@ -353,7 +353,18 @@ public static Collection<Object[]> parameters() {
353353 "" ,
354354 "class Test {}" ,
355355 }
356- }
356+ },
357+ {
358+ {
359+ "import com.foo.Second; import com.foo.First; class Test {}" ,
360+ },
361+ {
362+ "import com.foo.First;" , //
363+ "import com.foo.Second;" ,
364+ "" ,
365+ "class Test {}" ,
366+ }
367+ },
357368 };
358369 ImmutableList .Builder <Object []> builder = ImmutableList .builder ();
359370 for (String [][] inputAndOutput : inputsOutputs ) {
You can’t perform that action at this time.
0 commit comments