Skip to content

Commit 6f96b4d

Browse files
committed
try to add traces
1 parent d2faa74 commit 6f96b4d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/main/java/com/github/cameltooling/lsp/internal/diagnostic/DiagnosticRunner.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public void computeDiagnostics(String camelText, TextDocumentItem documentItem)
8282
diagnostics.addAll(camelKModelineDiagnosticService.compute(camelText, documentItem));
8383
diagnostics.addAll(camelKafkaConnectorDiagnosticService.compute(camelText, documentItem));
8484
diagnostics.addAll(connectedModeDiagnosticService.compute(camelText, documentItem));
85-
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
85+
if(!Thread.currentThread().isInterrupted()) {
86+
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
87+
} else {
88+
System.out.println("### Thread was interrupted (i.e. Future for diagnostic cancelled)");
89+
}
8690
lastTriggeredDiagnostic.remove(uri);
8791
});
8892
lastTriggeredDiagnostic.put(uri, lastTriggeredComputation);
@@ -100,6 +104,7 @@ public void clear(String uri) {
100104
CompletableFuture<Void> previousComputation = lastTriggeredDiagnostic.get(uri);
101105
if (previousComputation != null) {
102106
previousComputation.cancel(true);
107+
lastTriggeredDiagnostic.remove(uri);
103108
}
104109
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, Collections.emptyList()));
105110
}

src/test/java/com/github/cameltooling/lsp/internal/AbstractCamelLanguageServerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public void showMessage(MessageParams messageParams) {
136136

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

src/test/java/com/github/cameltooling/lsp/internal/diagnostic/CamelDiagnosticTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,22 @@ void testNoExceptionOnInvalidJavaFile() throws Exception {
142142

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

148+
System.out.println("### Will close");
149+
147150
DidCloseTextDocumentParams params = new DidCloseTextDocumentParams(new TextDocumentIdentifier(DUMMY_URI+".xml"));
148151
camelLanguageServer.getTextDocumentService().didClose(params);
149152

153+
System.out.println("### didClose sent");
154+
150155
await().timeout(AWAIT_TIMEOUT.multipliedBy(2)).untilAsserted(() -> assertThat(lastPublishedDiagnostics.getDiagnostics()).isEmpty());
151156
}
152157

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

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

0 commit comments

Comments
 (0)