Skip to content

Commit

Permalink
Fix another import ordering / newline issue
Browse files Browse the repository at this point in the history
MOE_MIGRATED_REVID=172516439
  • Loading branch information
cushon committed Oct 17, 2017
1 parent 352aac7 commit 8364f6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,6 @@ private ImportsAndIndex scanImports(int i) throws FormatterException {
if (isNewlineToken(i)) {
trailing.append(tokenAt(i));
i++;
} else if (tokenAt(i).equals("import")) {
// continue
} else {
throw new FormatterException("Extra tokens after import: " + tokenAt(i));
}
imports.add(new Import(importedName, trailing.toString(), isStatic));
// Remember the position just after the import we just saw, before skipping blank lines.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static ImmutableList<RawTok> getTokens(
}
if (stopTokens.contains(t.kind)) {
if (t.kind != TokenKind.EOF) {
end = t.endPos - 1;
end = t.pos;
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public static Collection<Object[]> parameters() {
"import com.foo.First;",
},
{
"!!Extra tokens after import: /* no block comments after imports */",
"!!Imports not contiguous (perhaps a comment separates them?)",
}
},
{
Expand Down Expand Up @@ -353,7 +353,18 @@ public static Collection<Object[]> parameters() {
"",
"class Test {}",
}
}
},
{
{
"import com.foo.Second; import com.foo.First; class Test {}",
},
{
"import com.foo.First;", //
"import com.foo.Second;",
"",
"class Test {}",
}
},
};
ImmutableList.Builder<Object[]> builder = ImmutableList.builder();
for (String[][] inputAndOutput : inputsOutputs) {
Expand Down

0 comments on commit 8364f6c

Please sign in to comment.