diff options
author | George Fraser <george@fivetran.com> | 2019-01-08 20:29:20 -0800 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2019-01-08 20:29:20 -0800 |
commit | 938fce4f8d2630d456caea03b0c178508680e945 (patch) | |
tree | 393084404c94156fd549c2c7e1aaf2a79eaa8eea | |
parent | a8d28f51dfc42c88eddbe1b5156f5b1be5aece83 (diff) | |
download | java-language-server-938fce4f8d2630d456caea03b0c178508680e945.zip |
Use SourceFileManager from docs
-rw-r--r-- | src/main/java/org/javacs/Docs.java | 9 | ||||
-rw-r--r-- | src/main/java/org/javacs/SourceFileManager.java | 4 | ||||
-rw-r--r-- | src/test/java/org/javacs/DocsTest.java | 7 | ||||
-rw-r--r-- | src/test/java/org/javacs/LanguageServerFixture.java | 1 |
4 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/org/javacs/Docs.java b/src/main/java/org/javacs/Docs.java index fa9181a..29d4c28 100644 --- a/src/main/java/org/javacs/Docs.java +++ b/src/main/java/org/javacs/Docs.java @@ -13,7 +13,7 @@ import javax.tools.*; public class Docs { /** File manager with source-path + platform sources, which we will use to look up individual source files */ - private final StandardJavaFileManager fileManager; + private final SourceFileManager fileManager = new SourceFileManager(); private static Path srcZip() { try { @@ -25,12 +25,7 @@ public class Docs { } Docs(Set<Path> docPath) { - this.fileManager = - ServiceLoader.load(JavaCompiler.class).iterator().next().getStandardFileManager(__ -> {}, null, null); - - // Compute the full source path, including src.zip for platform classes - // TODO source path needs to somehow get from FileStore to here; maybe write a FileManager that fuses FileStore - // with docPath? + // Path to source .jars + src.zip var sourcePathFiles = docPath.stream().map(Path::toFile).collect(Collectors.toSet()); try { diff --git a/src/main/java/org/javacs/SourceFileManager.java b/src/main/java/org/javacs/SourceFileManager.java index 64ef0b0..9ea750f 100644 --- a/src/main/java/org/javacs/SourceFileManager.java +++ b/src/main/java/org/javacs/SourceFileManager.java @@ -113,5 +113,9 @@ class SourceFileManager extends ForwardingJavaFileManager<StandardJavaFileManage fileManager.setLocation(location, files); } + public void setLocationFromPaths(Location location, Collection<? extends Path> searchpath) throws IOException { + fileManager.setLocationFromPaths(location, searchpath); + } + private static final Logger LOG = Logger.getLogger("main"); } diff --git a/src/test/java/org/javacs/DocsTest.java b/src/test/java/org/javacs/DocsTest.java index 6819974..eb764be 100644 --- a/src/test/java/org/javacs/DocsTest.java +++ b/src/test/java/org/javacs/DocsTest.java @@ -4,9 +4,16 @@ import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import java.util.Set; +import org.junit.Before; import org.junit.Test; public class DocsTest { + + @Before + public void setWorkspaceRoot() { + FileStore.setWorkspaceRoots(Set.of(LanguageServerFixture.SIMPLE_WORKSPACE_ROOT)); + } + @Test public void classDoc() { var sourcePath = Set.of(JavaCompilerServiceTest.simpleProjectSrc()); diff --git a/src/test/java/org/javacs/LanguageServerFixture.java b/src/test/java/org/javacs/LanguageServerFixture.java index f9052a0..20772ee 100644 --- a/src/test/java/org/javacs/LanguageServerFixture.java +++ b/src/test/java/org/javacs/LanguageServerFixture.java @@ -10,6 +10,7 @@ import org.javacs.lsp.*; class LanguageServerFixture { public static Path DEFAULT_WORKSPACE_ROOT = Paths.get("src/test/test-project/workspace").normalize(); + public static Path SIMPLE_WORKSPACE_ROOT = Paths.get("src/test/test-project/simple").normalize(); static { Main.setRootFormat(); |