summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2019-01-05 13:24:55 -0800
committerGeorge Fraser <george@fivetran.com>2019-01-05 13:24:55 -0800
commit7005490c456bbd24ebb9115ed8f78bc3fc8d11e8 (patch)
tree75ab5ce02c218212b4a76b78a395d4059270c339
parent9d0a24f07815030b3a0738475f2084b152d78796 (diff)
downloadjava-language-server-7005490c456bbd24ebb9115ed8f78bc3fc8d11e8.zip
Error-prone is too slow
-rw-r--r--.vscodeignore4
-rw-r--r--lib/error_prone/dataflow.jarbin311612 -> 0 bytes
-rw-r--r--lib/error_prone/error_prone.jarbin7046439 -> 0 bytes
-rw-r--r--lib/error_prone/jFormatString.jarbin34741 -> 0 bytes
-rw-r--r--lib/error_prone/javacutil.jarbin102426 -> 0 bytes
-rw-r--r--src/main/java/org/javacs/Lib.java11
-rw-r--r--src/test/java/org/javacs/BenchmarkErrorProne.java96
-rw-r--r--src/test/java/org/javacs/WarningsTest.java3
8 files changed, 3 insertions, 111 deletions
diff --git a/.vscodeignore b/.vscodeignore
index 6fc5a0f..34e1a78 100644
--- a/.vscodeignore
+++ b/.vscodeignore
@@ -22,10 +22,6 @@ images/**
modules/**
jdks/**
!lib/src.zip
-!lib/error_prone/dataflow.jar
-!lib/error_prone/error_prone.jar
-!lib/error_prone/javacutil.jar
-!lib/error_prone/jFormatString.jar
!lib/java.tmLanguage.json
!lib/java.hover.tmLanguage.json
diff --git a/lib/error_prone/dataflow.jar b/lib/error_prone/dataflow.jar
deleted file mode 100644
index 04bff60..0000000
--- a/lib/error_prone/dataflow.jar
+++ /dev/null
Binary files differ
diff --git a/lib/error_prone/error_prone.jar b/lib/error_prone/error_prone.jar
deleted file mode 100644
index 046faee..0000000
--- a/lib/error_prone/error_prone.jar
+++ /dev/null
Binary files differ
diff --git a/lib/error_prone/jFormatString.jar b/lib/error_prone/jFormatString.jar
deleted file mode 100644
index bdcb846..0000000
--- a/lib/error_prone/jFormatString.jar
+++ /dev/null
Binary files differ
diff --git a/lib/error_prone/javacutil.jar b/lib/error_prone/javacutil.jar
deleted file mode 100644
index 0f8045e..0000000
--- a/lib/error_prone/javacutil.jar
+++ /dev/null
Binary files differ
diff --git a/src/main/java/org/javacs/Lib.java b/src/main/java/org/javacs/Lib.java
index 8fb98f4..924f98c 100644
--- a/src/main/java/org/javacs/Lib.java
+++ b/src/main/java/org/javacs/Lib.java
@@ -1,6 +1,5 @@
package org.javacs;
-import java.io.File;
import java.nio.file.*;
class Lib {
@@ -13,14 +12,4 @@ class Lib {
}
static final Path SRC_ZIP = installRoot().resolve("lib/src.zip");
-
- static final String ERROR_PRONE = findErrorProne();
-
- private static String findErrorProne() {
- var dataflow = installRoot().resolve("lib/error_prone/dataflow.jar").toString();
- var errorProne = installRoot().resolve("lib/error_prone/error_prone.jar").toString();
- var javacUtil = installRoot().resolve("lib/error_prone/javacutil.jar").toString();
- var jFormatString = installRoot().resolve("lib/error_prone/jFormatString.jar").toString();
- return String.join(File.pathSeparator, dataflow, errorProne, javacUtil, jFormatString);
- }
}
diff --git a/src/test/java/org/javacs/BenchmarkErrorProne.java b/src/test/java/org/javacs/BenchmarkErrorProne.java
deleted file mode 100644
index ff3f64e..0000000
--- a/src/test/java/org/javacs/BenchmarkErrorProne.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.javacs;
-
-import com.sun.source.util.JavacTask;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.StringJoiner;
-import java.util.concurrent.TimeUnit;
-import javax.tools.JavaCompiler;
-import javax.tools.StandardJavaFileManager;
-import org.openjdk.jmh.annotations.*;
-
-// TODO this is coloring badly
-@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
-@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
-@Fork(1)
-public class BenchmarkErrorProne {
- private static Path file = Paths.get(FindResource.uri("/org/javacs/example/BenchmarkStringSearch.java"));
-
- @State(Scope.Thread)
- public static class BenchmarkState {
- JavaCompiler compiler = ServiceLoader.load(JavaCompiler.class).iterator().next();
- StandardJavaFileManager fileManager =
- new FileManagerWrapper(compiler.getStandardFileManager(__ -> {}, null, Charset.defaultCharset()));
- }
-
- @Benchmark
- public void vanilla(BenchmarkState state) {
- var options = JavaCompilerService.options(Set.of(), Set.of());
-
- analyze(state, options);
- }
-
- @Benchmark
- public void withErrorProne(BenchmarkState state) {
- var options = JavaCompilerService.options(Set.of(), Set.of());
- // Add error-prone
- options.addAll(errorProneOptions());
-
- analyze(state, options);
- }
-
- private void analyze(BenchmarkState state, List<String> options) {
- var sources = state.fileManager.getJavaFileObjectsFromPaths(List.of(file));
- // Create task
- var task =
- (JavacTask)
- state.compiler.getTask(
- null, state.fileManager, __ -> {}, options, Collections.emptyList(), sources);
- // Print timing information for optimization
- var profiler = new Profiler();
- try {
- task.analyze();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static List<String> errorProneOptions() {
- var options = new ArrayList<String>();
-
- // https://errorprone.info/docs/installation "Command Line"
- Collections.addAll(options, "-XDcompilePolicy=byfile");
- Collections.addAll(options, "-processorpath", Lib.ERROR_PRONE);
-
- // https://errorprone.info/bugpatterns
- var bugPatterns = new StringJoiner(" ");
- // bugPatterns.add("-Xep:EmptyIf");
- // bugPatterns.add("-Xep:NumericEquality");
- // bugPatterns.add("-Xep:ConstructorLeaksThis");
- // bugPatterns.add("-Xep:EqualsBrokenForNull");
- // bugPatterns.add("-Xep:InvalidThrows");
- // bugPatterns.add("-Xep:RedundantThrows");
- // bugPatterns.add("-Xep:StaticQualifiedUsingExpression");
- // bugPatterns.add("-Xep:StringEquality");
- // bugPatterns.add("-Xep:Unused");
- // bugPatterns.add("-Xep:UnusedException");
- // bugPatterns.add("-Xep:FieldCanBeFinal");
- // bugPatterns.add("-Xep:FieldMissingNullable");
- // bugPatterns.add("-Xep:MethodCanBeStatic");
- // bugPatterns.add("-Xep:PackageLocation");
- // bugPatterns.add("-Xep:PrivateConstructorForUtilityClass");
- // bugPatterns.add("-Xep:ReturnMissingNullable");
-
- Collections.addAll(
- options, "-Xplugin:ErrorProne -XepAllErrorsAsWarnings " + bugPatterns + " --illegal-access=warn");
-
- return options;
- }
-}
diff --git a/src/test/java/org/javacs/WarningsTest.java b/src/test/java/org/javacs/WarningsTest.java
index 696eed2..f9e54d4 100644
--- a/src/test/java/org/javacs/WarningsTest.java
+++ b/src/test/java/org/javacs/WarningsTest.java
@@ -35,4 +35,7 @@ public class WarningsTest {
assertThat(errors, hasItem("unused(8)")); // int unusedPrivate
assertThat(errors, not(hasItem("unused(4)")));
}
+
+ // TODO warn on type.equals(otherType)
+ // TODO warn on map.get(wrongKeyType)
}