Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.openjdk.source.util.TreeScanner;
import org.openjdk.tools.javac.api.JavacTrees;
import org.openjdk.tools.javac.file.JavacFileManager;
import org.openjdk.tools.javac.main.Option;
import org.openjdk.tools.javac.parser.JavacParser;
import org.openjdk.tools.javac.parser.ParserFactory;
import org.openjdk.tools.javac.tree.DCTree;
Expand Down Expand Up @@ -195,6 +196,8 @@ public Void visitIdentifier(IdentifierTree node, Void aVoid) {
public static String removeUnusedImports(
final String contents, JavadocOnlyImports javadocOnlyImports) {
Context context = new Context();
// TODO(cushon): this should default to the latest supported source level, same as in Formatter
Options.instance(context).put(Option.SOURCE, "9");
JCCompilationUnit unit = parse(context, contents);
if (unit == null) {
// error handling is done during formatting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ public static Collection<Object[]> parameters() {
"public class Test implements Foo, Bar, Baz, Bork {}",
},
},
{
{
"import java.lang.Foo;", //
"interface Test { private static void foo() {} }",
},
{
"interface Test { private static void foo() {} }",
},
{
"interface Test { private static void foo() {} }",
},
},
};
ImmutableList.Builder<Object[]> builder = ImmutableList.builder();
for (String[][] inputAndOutput : inputsOutputs) {
Expand Down