diff options
author | George Fraser <george@fivetran.com> | 2019-04-01 23:56:27 -0700 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2019-04-01 23:56:27 -0700 |
commit | fe2080d0cd62a66197f9a6243f8ee522a0efe6f8 (patch) | |
tree | f469d26c52852041faa538523fc4ba171abc56cb /src/main | |
parent | 5ce53ab15a2cab08924f0dd4879c8f9c1936a882 (diff) | |
download | java-language-server-fe2080d0cd62a66197f9a6243f8ee522a0efe6f8.zip |
Dead code
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/javacs/CompileBatch.java | 34 | ||||
-rw-r--r-- | src/main/java/org/javacs/JavaCompilerService.java | 12 | ||||
-rw-r--r-- | src/main/java/org/javacs/JavaLanguageServer.java | 4 | ||||
-rw-r--r-- | src/main/java/org/javacs/ReportProgress.java | 16 |
4 files changed, 10 insertions, 56 deletions
diff --git a/src/main/java/org/javacs/CompileBatch.java b/src/main/java/org/javacs/CompileBatch.java index 672b347..41aa740 100644 --- a/src/main/java/org/javacs/CompileBatch.java +++ b/src/main/java/org/javacs/CompileBatch.java @@ -24,16 +24,14 @@ public class CompileBatch implements AutoCloseable { public static final int MAX_COMPLETION_ITEMS = 50; private final JavaCompilerService parent; - private final ReportProgress progress; private final TaskPool.Borrow borrow; private final Trees trees; private final Elements elements; private final Types types; private final List<CompilationUnitTree> roots; - CompileBatch(JavaCompilerService parent, Collection<? extends JavaFileObject> files, ReportProgress progress) { + CompileBatch(JavaCompilerService parent, Collection<? extends JavaFileObject> files) { this.parent = parent; - this.progress = progress; this.borrow = batchTask(parent, files); this.trees = Trees.instance(borrow.task); this.elements = borrow.task.getElements(); @@ -42,34 +40,6 @@ public class CompileBatch implements AutoCloseable { // Print timing information for optimization var profiler = new Profiler(); borrow.task.addTaskListener(profiler); - // Show progress message through the UI - class CountFiles implements TaskListener { - Set<URI> parse = new HashSet<>(), enter = new HashSet<>(), analyze = new HashSet<>(); - - void inc(String message) { - var n = parse.size() + enter.size() + analyze.size(); - var total = files.size() * 3; - progress.progress(message, n, total); - } - - @Override - public void started(TaskEvent e) { - var uri = e.getSourceFile().toUri(); - switch (e.getKind()) { - case PARSE: - if (parse.add(uri)) inc("Parse sources"); - break; - case ENTER: - if (enter.add(uri)) inc("Enter symbols"); - break; - case ANALYZE: - var name = Parser.fileName(uri); - if (analyze.add(uri)) inc("Analyze " + name); - break; - } - } - } - borrow.task.addTaskListener(new CountFiles()); // Compile all roots try { for (var t : borrow.task.parse()) roots.add(t); @@ -87,7 +57,7 @@ public class CompileBatch implements AutoCloseable { borrow.close(); } - static TaskPool.Borrow batchTask(JavaCompilerService parent, Collection<? extends JavaFileObject> sources) { + private static TaskPool.Borrow batchTask(JavaCompilerService parent, Collection<? extends JavaFileObject> sources) { parent.diags.clear(); return parent.compiler.getTask( null, diff --git a/src/main/java/org/javacs/JavaCompilerService.java b/src/main/java/org/javacs/JavaCompilerService.java index 99fba71..9f179fc 100644 --- a/src/main/java/org/javacs/JavaCompilerService.java +++ b/src/main/java/org/javacs/JavaCompilerService.java @@ -85,21 +85,21 @@ public class JavaCompilerService { return compileBatch(List.of(file)); } - public CompileBatch compileBatch(Collection<URI> uris) { - return compileBatch(uris, ReportProgress.EMPTY); + public CompileBatch compileFile(URI uri) { + return compileUris(Collections.singleton(uri)); } - public CompileBatch compileBatch(Collection<URI> uris, ReportProgress progress) { + public CompileBatch compileUris(Collection<URI> uris) { var files = new ArrayList<File>(); for (var p : uris) files.add(new File(p)); var sources = fileManager.getJavaFileObjectsFromFiles(files); var list = new ArrayList<JavaFileObject>(); for (var s : sources) list.add(s); - return new CompileBatch(this, list, progress); + return new CompileBatch(this, list); } - public CompileBatch compileBatch(List<? extends JavaFileObject> sources) { - return new CompileBatch(this, sources, ReportProgress.EMPTY); + public CompileBatch compileBatch(Collection<? extends JavaFileObject> sources) { + return new CompileBatch(this, sources); } public List<Diagnostic<? extends JavaFileObject>> reportErrors(Collection<URI> uris) { diff --git a/src/main/java/org/javacs/JavaLanguageServer.java b/src/main/java/org/javacs/JavaLanguageServer.java index 5932e21..f6d8d8b 100644 --- a/src/main/java/org/javacs/JavaLanguageServer.java +++ b/src/main/java/org/javacs/JavaLanguageServer.java @@ -627,7 +627,7 @@ class JavaLanguageServer extends LanguageServer { || activeFileCacheVersion != FileStore.version(uri)) { LOG.info("Recompile active file..."); if (activeFileCache != null) activeFileCache.close(); - activeFileCache = compiler.compileBatch(Collections.singleton(uri)); + activeFileCache = compiler.compileFile(uri); activeFileCacheFile = uri; activeFileCacheVersion = FileStore.version(uri); } @@ -1141,7 +1141,7 @@ class JavaLanguageServer extends LanguageServer { if (!outOfDate.isEmpty()) { // Compile all files that need to be updated in a batch outOfDate.add(toUri); - try (var batch = compiler.compileBatch(outOfDate)) { + try (var batch = compiler.compileUris(outOfDate)) { // Find all declarations in toFile var toEls = batch.declarations(toUri); diff --git a/src/main/java/org/javacs/ReportProgress.java b/src/main/java/org/javacs/ReportProgress.java deleted file mode 100644 index 4ff9222..0000000 --- a/src/main/java/org/javacs/ReportProgress.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.javacs; - -public interface ReportProgress { - void start(String message); - - void progress(String message, int n, int total); - - public static final ReportProgress EMPTY = - new ReportProgress() { - @Override - public void start(String message) {} - - @Override - public void progress(String message, int n, int total) {} - }; -} |