Skip to content

Commit

Permalink
minimal poc diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
dshimo committed Jan 11, 2024
1 parent b186438 commit d82b1f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion liberty-ls/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>io.openliberty.tools</groupId>
<artifactId>ci.common</artifactId>
<version>1.8.30-SNAPSHOT</version>
<version>1.8.31-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DidChangeTextDocumentParams;
import org.eclipse.lsp4j.DidOpenTextDocumentParams;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.PublishDiagnosticsParams;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextDocumentItem;

import io.openliberty.tools.langserver.LibertyLanguageServer;
Expand Down Expand Up @@ -54,7 +56,13 @@ public void computeDiagnostics(String text, TextDocumentItem documentItem) {
CompletableFuture.runAsync(() -> {
LibertyTextDocument openedDocument = libertyLanguageServer.getTextDocumentService().getOpenedDocument(uri);
List<Diagnostic> diagnostics = new ArrayList<>();
LOGGER.warning("About to calculate diagnostics");
Map<String, PropertiesValidationResult> propertiesErrors = libertyPropertiesDiagnosticService.compute(text, openedDocument);
if (openedDocument.isServerXml()) {
LOGGER.warning("Running server.xml diagnostics");
Diagnostic testDiagnostic = new Diagnostic(new Range(new Position(0, 0), new Position(0,1)), "This is our proof of concept diagnostic.");
diagnostics.add(testDiagnostic);
}
diagnostics.addAll(libertyPropertiesDiagnosticService.convertToLSPDiagnostics(propertiesErrors));
libertyLanguageServer.getLanguageClient().publishDiagnostics(new PublishDiagnosticsParams(uri, diagnostics));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ public void update(List<TextDocumentContentChangeEvent> changes) {
}
}

// TODO: improve this -- likely expand to isConfigFile
public boolean isServerXml() {
return this.getUri().endsWith("server.xml");
}

}

0 comments on commit d82b1f0

Please sign in to comment.