summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2018-06-23 19:16:22 -0700
committerGeorge Fraser <george@fivetran.com>2018-06-23 19:16:59 -0700
commitfa25ffd8fc51c46d57103d0ba2e04356814fbd7c (patch)
treef980376161f808498504cf8445a02f9f658fed02
parentc423d6c969cc0fa207bd443a999753c0fe95b2c0 (diff)
downloadjava-language-server-fa25ffd8fc51c46d57103d0ba2e04356814fbd7c.zip
Reduce use of URI
-rw-r--r--src/main/java/org/javacs/JavaCompilerService.java14
-rw-r--r--src/main/java/org/javacs/JavaLanguageServer.java8
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java2
3 files changed, 12 insertions, 12 deletions
diff --git a/src/main/java/org/javacs/JavaCompilerService.java b/src/main/java/org/javacs/JavaCompilerService.java
index df11fa5..12deb4c 100644
--- a/src/main/java/org/javacs/JavaCompilerService.java
+++ b/src/main/java/org/javacs/JavaCompilerService.java
@@ -196,9 +196,9 @@ public class JavaCompilerService {
Collections.singletonList(new StringFileObject(contents, file)));
}
- private JavacTask batchTask(Collection<URI> paths) {
+ private JavacTask batchTask(Collection<Path> paths) {
diags.clear();
- List<File> files = paths.stream().map(f -> Paths.get(f).toFile()).collect(Collectors.toList());
+ List<File> files = paths.stream().map(Path::toFile).collect(Collectors.toList());
return (JavacTask)
compiler.getTask(
null,
@@ -209,7 +209,7 @@ public class JavaCompilerService {
fileManager.getJavaFileObjectsFromFiles(files));
}
- List<Diagnostic<? extends JavaFileObject>> lint(Collection<URI> files) {
+ List<Diagnostic<? extends JavaFileObject>> lint(Collection<Path> files) {
JavacTask task = batchTask(files);
try {
task.parse();
@@ -720,7 +720,7 @@ public class JavaCompilerService {
return sourcePath.stream().flatMap(dir -> javaSourcesInDir(dir));
}
- private List<URI> potentialReferences(Element to) {
+ private List<Path> potentialReferences(Element to) {
String name = to.getSimpleName().toString();
Pattern word = Pattern.compile("\\b\\w+\\b");
Predicate<String> containsWord =
@@ -739,7 +739,7 @@ public class JavaCompilerService {
throw new RuntimeException(e);
}
};
- return javaSources().filter(test).map(p -> p.toUri()).collect(Collectors.toList());
+ return javaSources().filter(test).collect(Collectors.toList());
}
/**
@@ -793,7 +793,7 @@ public class JavaCompilerService {
}
}
- private Batch compileBatch(List<URI> files) {
+ private Batch compileBatch(List<Path> files) {
JavacTask task = batchTask(files);
List<CompilationUnitTree> result = new ArrayList<>();
@@ -813,7 +813,7 @@ public class JavaCompilerService {
Trees trees = Trees.instance(cache.task);
TreePath path = path(file, line, character);
Element to = trees.getElement(path);
- List<URI> possible = potentialReferences(to);
+ List<Path> possible = potentialReferences(to);
Batch batch = compileBatch(possible);
List<TreePath> result = new ArrayList<>();
for (CompilationUnitTree f : batch.roots) {
diff --git a/src/main/java/org/javacs/JavaLanguageServer.java b/src/main/java/org/javacs/JavaLanguageServer.java
index df85405..d3696d3 100644
--- a/src/main/java/org/javacs/JavaLanguageServer.java
+++ b/src/main/java/org/javacs/JavaLanguageServer.java
@@ -72,10 +72,10 @@ class JavaLanguageServer implements LanguageServer {
}
}
- void lint(Collection<URI> paths) {
- LOG.info("Lint " + paths.stream().map(uri -> uri.toString()).collect(Collectors.joining(", ")));
-
- publishDiagnostics(paths, compiler.lint(paths));
+ void lint(Collection<URI> uris) {
+ LOG.info("Lint " + uris.stream().map(uri -> uri.toString()).collect(Collectors.joining(", ")));
+ List<Path> paths = uris.stream().map(uri -> Paths.get(uri)).collect(Collectors.toList());
+ publishDiagnostics(uris, compiler.lint(paths));
}
private JavaCompilerService createCompiler() {
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java
index b007e68..3a8c344 100644
--- a/src/test/java/org/javacs/JavaCompilerServiceTest.java
+++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java
@@ -250,7 +250,7 @@ public class JavaCompilerServiceTest {
@Test
public void lint() {
List<Diagnostic<? extends JavaFileObject>> diags =
- compiler.lint(Collections.singleton(resourceUri("/HasError.java")));
+ compiler.lint(Collections.singleton(Paths.get(resourceUri("/HasError.java"))));
assertThat(diags, not(empty()));
}