Skip to content

Commit

Permalink
try to add traces
Browse files Browse the repository at this point in the history
  • Loading branch information
apupier committed Jun 7, 2023
1 parent d2faa74 commit a9faacb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ public void computeDiagnostics(String camelText, TextDocumentItem documentItem)
diagnostics.addAll(camelKModelineDiagnosticService.compute(camelText, documentItem));
diagnostics.addAll(camelKafkaConnectorDiagnosticService.compute(camelText, documentItem));
diagnostics.addAll(connectedModeDiagnosticService.compute(camelText, documentItem));
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
lastTriggeredDiagnostic.remove(uri);
if(!Thread.currentThread().isInterrupted()) {
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
lastTriggeredDiagnostic.remove(uri);
} else {
System.out.println("### Thread was interrupted (i.e. Future for diagnostic cancelled)");
}
});
lastTriggeredDiagnostic.put(uri, lastTriggeredComputation);
}
Expand All @@ -100,6 +104,7 @@ public void clear(String uri) {
CompletableFuture<Void> previousComputation = lastTriggeredDiagnostic.get(uri);
if (previousComputation != null) {
previousComputation.cancel(true);
lastTriggeredDiagnostic.remove(uri);
}
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, Collections.emptyList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public void showMessage(MessageParams messageParams) {

@Override
public void publishDiagnostics(PublishDiagnosticsParams diagnostics) {
System.out.println("Published Diagnostics " + diagnostics.getUri() +" "+ diagnostics.getDiagnostics().size());
AbstractCamelLanguageServerTest.this.lastPublishedDiagnostics = diagnostics;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,22 @@ void testNoExceptionOnInvalidJavaFile() throws Exception {

@Test
void testValidationErrorClearedOnClose() throws Exception {
System.out.println("### Starting testValidationErrorClearedOnClose test ");
testDiagnostic("camel-with-endpoint-error", 1, ".xml");

System.out.println("### Will close");

DidCloseTextDocumentParams params = new DidCloseTextDocumentParams(new TextDocumentIdentifier(DUMMY_URI+".xml"));
camelLanguageServer.getTextDocumentService().didClose(params);

System.out.println("### didClose sent");

await().timeout(AWAIT_TIMEOUT.multipliedBy(2)).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).isEmpty());
}

@Test
void testValidationErrorUpdatedOnChange() throws Exception {
System.out.println("### Starting testValidationErrorUpdatedOnChange test ");
testDiagnostic("camel-with-endpoint-error", 1, ".xml");

camelLanguageServer.getTextDocumentService().getOpenedDocument(DUMMY_URI+".xml").getText();
Expand Down

0 comments on commit a9faacb

Please sign in to comment.