From fe2080d0cd62a66197f9a6243f8ee522a0efe6f8 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Mon, 1 Apr 2019 23:56:27 -0700 Subject: Dead code --- src/main/java/org/javacs/CompileBatch.java | 34 ++-------------------- src/main/java/org/javacs/JavaCompilerService.java | 12 ++++---- src/main/java/org/javacs/JavaLanguageServer.java | 4 +-- src/main/java/org/javacs/ReportProgress.java | 16 ---------- .../java/org/javacs/JavaCompilerServiceTest.java | 2 +- src/test/java/org/javacs/PtrTest.java | 3 +- 6 files changed, 12 insertions(+), 59 deletions(-) delete mode 100644 src/main/java/org/javacs/ReportProgress.java 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 roots; - CompileBatch(JavaCompilerService parent, Collection files, ReportProgress progress) { + CompileBatch(JavaCompilerService parent, Collection 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 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 sources) { + private static TaskPool.Borrow batchTask(JavaCompilerService parent, Collection 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 uris) { - return compileBatch(uris, ReportProgress.EMPTY); + public CompileBatch compileFile(URI uri) { + return compileUris(Collections.singleton(uri)); } - public CompileBatch compileBatch(Collection uris, ReportProgress progress) { + public CompileBatch compileUris(Collection uris) { var files = new ArrayList(); for (var p : uris) files.add(new File(p)); var sources = fileManager.getJavaFileObjectsFromFiles(files); var list = new ArrayList(); for (var s : sources) list.add(s); - return new CompileBatch(this, list, progress); + return new CompileBatch(this, list); } - public CompileBatch compileBatch(List sources) { - return new CompileBatch(this, sources, ReportProgress.EMPTY); + public CompileBatch compileBatch(Collection sources) { + return new CompileBatch(this, sources); } public List> reportErrors(Collection 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) {} - }; -} diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java index ec41d26..eb947a7 100644 --- a/src/test/java/org/javacs/JavaCompilerServiceTest.java +++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java @@ -268,7 +268,7 @@ public class JavaCompilerServiceTest { @Test public void fixImports() { var uri = resourceUri("MissingImport.java"); - var qualifiedNames = compiler.compileBatch(Collections.singleton(uri)).fixImports(uri); + var qualifiedNames = compiler.compileFile(uri).fixImports(uri); assertThat(qualifiedNames, hasItem("java.util.List")); } diff --git a/src/test/java/org/javacs/PtrTest.java b/src/test/java/org/javacs/PtrTest.java index 69a42ab..0503521 100644 --- a/src/test/java/org/javacs/PtrTest.java +++ b/src/test/java/org/javacs/PtrTest.java @@ -4,7 +4,6 @@ import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import java.net.URI; -import java.util.Collections; import org.junit.Test; public class PtrTest { @@ -12,7 +11,7 @@ public class PtrTest { static JavaLanguageServer server = LanguageServerFixture.getJavaLanguageServer(); static String file = "/org/javacs/example/Ptrs.java"; static URI uri = FindResource.uri(file); - static CompileBatch compile = server.compiler.compileBatch(Collections.singleton(uri)); + static CompileBatch compile = server.compiler.compileFile(uri); @Test public void classPtr() { -- cgit v1.2.3