diff options
author | George Fraser <george@fivetran.com> | 2019-01-01 17:38:42 -0800 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2019-01-01 17:38:42 -0800 |
commit | 280e801d4e529f471fc0631dc880b778815aa394 (patch) | |
tree | b75d464669f18a61f9cb49258dfaae8d8487e13b /src/test | |
parent | 6260e5e63a30f348f1f2e5dad08038a4ba4447ce (diff) | |
download | java-language-server-280e801d4e529f471fc0631dc880b778815aa394.zip |
Use error-prone
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/javacs/JavaCompilerServiceTest.java | 19 | ||||
-rw-r--r-- | src/test/test-project/simple/ErrorProne.java | 9 |
2 files changed, 26 insertions, 2 deletions
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java index 838d9b5..82fe157 100644 --- a/src/test/java/org/javacs/JavaCompilerServiceTest.java +++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java @@ -278,10 +278,25 @@ public class JavaCompilerServiceTest { } @Test - public void lint() { + public void reportErrors() { var uri = resourceUri("HasError.java"); var files = Collections.singleton(uri); - var diags = compiler.compileBatch(files).lint(); + var diags = compiler.reportErrors(files); + assertThat(diags, not(empty())); + } + + @Test + public void errorProne() { + var uri = resourceUri("ErrorProne.java"); + var files = Collections.singleton(uri); + var diags = compiler.reportErrors(files); + for (var d : diags) { + var file = d.getSource().toUri().getPath(); + var line = d.getLineNumber(); + var kind = d.getKind(); + var msg = d.getMessage(null); + System.out.println(String.format("%s(%d)\t%s\t%s", file, line, kind, msg)); + } assertThat(diags, not(empty())); } diff --git a/src/test/test-project/simple/ErrorProne.java b/src/test/test-project/simple/ErrorProne.java new file mode 100644 index 0000000..d4b751c --- /dev/null +++ b/src/test/test-project/simple/ErrorProne.java @@ -0,0 +1,9 @@ +import java.util.HashSet; +import java.util.Set; + +class ErrorProne { + void collectionIncompatibleType() { + Set<Long> values = new HashSet<>(); + if (values.contains(42)) System.out.println("Impossible!"); + } +}
\ No newline at end of file |