Skip to content

Commit

Permalink
Adjust testcase due to differing diagnostics from JEP 445.
Browse files Browse the repository at this point in the history
- Unnamed classes (JEP 445) has changed diagnostics reported on
  invalid class declarations

Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber committed Feb 3, 2024
1 parent 975e1c3 commit cfc3e1f
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,17 +1008,17 @@ public void testDiagnosticsOnExternalFileWithInternalProject() throws Exception
Path filePath = Files.createTempDirectory("testDiagnosticsOnExternalFileWithInternalProject").resolve("A.java");
try {
String content = "error public class A { }";
Files.writeString(filePath, content);
Files.writeString(filePath, content);
lifeCycleHandler.didOpen(new DidOpenTextDocumentParams(new TextDocumentItem(filePath.toUri().toString(), "java", 0, content)));
List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics");
assertFalse("No diagnostics sent on open", diagnosticReports.isEmpty());
List<Diagnostic> diagnostics = diagnosticReports.get(0).getDiagnostics();
assertTrue("First diagnostics not sent", diagnostics.stream().map(Diagnostic::getMessage).anyMatch(message -> message.contains("error on token \"error\"")));
assertTrue("First diagnostics not sent", diagnostics.stream().map(Diagnostic::getMessage).anyMatch(message -> message.contains("Syntax error")));
lifeCycleHandler.didChange(new DidChangeTextDocumentParams(new VersionedTextDocumentIdentifier(filePath.toUri().toString(), 0), List.of(new TextDocumentContentChangeEvent(new Range(new Position(0, 0), new Position(0, 0)), "another"))));
diagnosticReports = getClientRequests("publishDiagnostics");
assertEquals("No diagnostics sent on change", 2, diagnosticReports.size());
diagnostics = diagnosticReports.get(1).getDiagnostics();
assertTrue("diagnostics not updated upon edit", diagnostics.stream().map(Diagnostic::getMessage).anyMatch(message -> message.contains("error on token \"anothererror\"")));
assertTrue("diagnostics not updated upon edit", diagnostics.stream().map(Diagnostic::getMessage).anyMatch(message -> message.contains("Syntax error")));
} finally {
Files.delete(filePath);
Files.delete(filePath.getParent());
Expand Down

0 comments on commit cfc3e1f

Please sign in to comment.