diff options
author | George Fraser <george@fivetran.com> | 2018-06-24 16:26:47 -0700 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2018-06-24 16:26:47 -0700 |
commit | 2b1145e1a05d7936124fa587942f8ceb806414c0 (patch) | |
tree | 84ea1e0558e6da69576edba064dbaf677b26f6ca /src/test | |
parent | 1f9eb19dc5ed275822401607d49e6223746d3e49 (diff) | |
download | java-language-server-2b1145e1a05d7936124fa587942f8ceb806414c0.zip |
Scan sources for imports
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/javacs/FixImportsTest.java | 9 | ||||
-rw-r--r-- | src/test/java/org/javacs/JavaCompilerServiceTest.java | 2 | ||||
-rw-r--r-- | src/test/resources/HasImport.java | 5 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/test/java/org/javacs/FixImportsTest.java b/src/test/java/org/javacs/FixImportsTest.java index 4b77087..786c6fa 100644 --- a/src/test/java/org/javacs/FixImportsTest.java +++ b/src/test/java/org/javacs/FixImportsTest.java @@ -3,6 +3,7 @@ package org.javacs; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import java.nio.file.*; import java.util.*; import org.junit.Test; @@ -16,4 +17,12 @@ public class FixImportsTest { Map<String, String> resolved = fix.resolveSymbols(Collections.singleton("List"), emptyImports); assertThat(resolved, hasEntry("List", "java.util.List")); } + + @Test + public void findExistingImports() { + FixImports.ExistingImports find = + fix.existingImports(Collections.singleton(JavaCompilerServiceTest.resourcesDir())); + assertThat(find.classes, hasItem("java.util.List")); + assertThat(find.packages, hasItem("java.util")); + } } diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java index 39989b0..8320d0c 100644 --- a/src/test/java/org/javacs/JavaCompilerServiceTest.java +++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java @@ -26,7 +26,7 @@ public class JavaCompilerServiceTest { new JavaCompilerService( Collections.singleton(resourcesDir()), Collections.emptySet(), Collections.emptySet()); - private static Path resourcesDir() { + static Path resourcesDir() { try { return Paths.get(JavaCompilerServiceTest.class.getResource("/HelloWorld.java").toURI()).getParent(); } catch (URISyntaxException e) { diff --git a/src/test/resources/HasImport.java b/src/test/resources/HasImport.java new file mode 100644 index 0000000..2b4f66e --- /dev/null +++ b/src/test/resources/HasImport.java @@ -0,0 +1,5 @@ +import java.util.List; + +class HasImport { + +}
\ No newline at end of file |