Skip to content

Commit c73cffc

Browse files
committed
try to add traces
1 parent d5961c6 commit c73cffc

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ public void computeDiagnostics(String camelText, TextDocumentItem documentItem)
7979
diagnostics.addAll(configurationPropertiesDiagnosticService.converToLSPDiagnostics(configurationPropertiesErrors));
8080
diagnostics.addAll(camelKModelineDiagnosticService.compute(camelText, documentItem));
8181
diagnostics.addAll(connectedModeDiagnosticService.compute(camelText, documentItem));
82-
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
83-
lastTriggeredDiagnostic.remove(uri);
82+
if(!Thread.currentThread().isInterrupted()) {
83+
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
84+
lastTriggeredDiagnostic.remove(uri);
85+
} else {
86+
System.out.println("### Thread was interrupted (i.e. Future for diagnostic cancelled)");
87+
}
8488
});
8589
lastTriggeredDiagnostic.put(uri, lastTriggeredComputation);
8690
}
@@ -97,6 +101,7 @@ public void clear(String uri) {
97101
CompletableFuture<Void> previousComputation = lastTriggeredDiagnostic.get(uri);
98102
if (previousComputation != null) {
99103
previousComputation.cancel(true);
104+
lastTriggeredDiagnostic.remove(uri);
100105
}
101106
camelLanguageServer.getClient().publishDiagnostics(new PublishDiagnosticsParams(uri, Collections.emptyList()));
102107
}

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)