summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-04-01 23:56:27 -0700
committerGeorge Fraser <george@fivetran.com>2019-04-01 23:56:27 -0700
commitfe2080d0cd62a66197f9a6243f8ee522a0efe6f8 (patch)
treef469d26c52852041faa538523fc4ba171abc56cb
parent5ce53ab15a2cab08924f0dd4879c8f9c1936a882 (diff)
downloadjava-language-server-fe2080d0cd62a66197f9a6243f8ee522a0efe6f8.zip
Dead code
-rw-r--r--src/main/java/org/javacs/CompileBatch.java34
-rw-r--r--src/main/java/org/javacs/JavaCompilerService.java12
-rw-r--r--src/main/java/org/javacs/JavaLanguageServer.java4
-rw-r--r--src/main/java/org/javacs/ReportProgress.java16
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java2
-rw-r--r--src/test/java/org/javacs/PtrTest.java3
6 files changed, 12 insertions, 59 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) {}
- };
-}
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() {