summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-01-06 13:33:36 -0800
committerGeorge Fraser <george@fivetran.com>2019-01-06 13:33:36 -0800
commit7aca5297246443a948b47c8219f6c95394ddaa1f (patch)
tree68a61e6d6929014459acb626fe10bebc78561b1b
parentd2942ecf8b33af9bcf02e585f669b0c85c05e77b (diff)
downloadjava-language-server-7aca5297246443a948b47c8219f6c95394ddaa1f.zip
Filter out module-info.java
-rw-r--r--src/main/java/org/javacs/JavaCompilerService.java7
-rw-r--r--src/main/java/org/javacs/SourcePath.java16
2 files changed, 18 insertions, 5 deletions
diff --git a/src/main/java/org/javacs/JavaCompilerService.java b/src/main/java/org/javacs/JavaCompilerService.java
index b46fac5..19b5562 100644
--- a/src/main/java/org/javacs/JavaCompilerService.java
+++ b/src/main/java/org/javacs/JavaCompilerService.java
@@ -140,7 +140,12 @@ public class JavaCompilerService {
// Construct list of sources
var files = new ArrayList<File>();
- for (var p : uris) files.add(new File(p));
+ for (var uri : uris) {
+ if (FileStore.isJavaFile(uri)) {
+ files.add(new File(uri));
+ ;
+ }
+ }
// TODO should get current contents of open files from FileStore
var sources = fileManager.getJavaFileObjectsFromFiles(files);
diff --git a/src/main/java/org/javacs/SourcePath.java b/src/main/java/org/javacs/SourcePath.java
index a8150c5..491b87d 100644
--- a/src/main/java/org/javacs/SourcePath.java
+++ b/src/main/java/org/javacs/SourcePath.java
@@ -2,7 +2,6 @@ package org.javacs;
import java.io.File;
import java.io.IOException;
-import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -32,7 +31,11 @@ class SourcePath {
*/
boolean create(Set<Path> javaFiles) {
if (javaFiles.isEmpty()) return false;
- allJavaFiles.addAll(javaFiles);
+ for (var f : javaFiles) {
+ if (isJavaFile(f)) {
+ allJavaFiles.add(f);
+ }
+ }
return checkSourceRoots();
}
@@ -52,6 +55,7 @@ class SourcePath {
*/
// TODO batch this
boolean update(Path javaFile) {
+ if (!isJavaFile(javaFile)) return false;
// Check if file is in an existing source root
for (var root : sourceRoots) {
if (!javaFile.startsWith(root)) continue;
@@ -89,12 +93,16 @@ class SourcePath {
return false;
}
+ private static boolean isJavaFile(Path file) {
+ var name = file.getFileName().toString();
+ return name.endsWith(".java") && !name.equals("module-info.java");
+ }
+
private static Set<Path> allJavaFilesInDirs(Set<Path> dirs) {
var all = new HashSet<Path>();
- var match = FileSystems.getDefault().getPathMatcher("glob:*.java");
for (var dir : dirs) {
try {
- Files.walk(dir).filter(java -> match.matches(java.getFileName())).forEach(all::add);
+ Files.walk(dir).filter(SourcePath::isJavaFile).forEach(all::add);
} catch (IOException e) {
throw new RuntimeException(e);
}