Publish java diagnostics to ILanguageClient

This commit is contained in:
Akash Yadav
2022-01-25 14:35:24 +05:30
parent b77f0df5db
commit 9fb75d302d
4 changed files with 18 additions and 0 deletions
Binary file not shown.
@@ -27,6 +27,7 @@ import com.itsaky.androidide.utils.Logger;
import com.itsaky.lsp.api.ILanguageServer;
import com.itsaky.lsp.models.AnalyzeParams;
import com.itsaky.lsp.models.DiagnosticItem;
import com.itsaky.lsp.models.DiagnosticResult;
import com.itsaky.lsp.models.Position;
import com.itsaky.lsp.models.Range;
@@ -79,6 +80,10 @@ public class JavaAnalyzer extends AbstractCodeAnalyzer {
JavaAnalyzer.this.diagnostics = result.getDiagnostics ();
JavaAnalyzer.this.helper = new HighlightRangeHelper (result.getSemanticHighlights ());
if (languageServer.getClient () != null) {
languageServer.getClient ().publishDiagnostics (new DiagnosticResult (file.toPath (), JavaAnalyzer.this.diagnostics));
}
});
}
@@ -74,6 +74,13 @@ public interface ILanguageServer {
*/
void connectClient (@Nullable ILanguageClient client);
/**
* Get the instance of the language client connected to this server.
* @return The language client.
*/
@Nullable
ILanguageClient getClient ();
/**
* Apply settings to the language server. Its up to the language server how it
* applies these settings to the language service providers.
@@ -141,6 +141,12 @@ public class JavaLanguageServer implements ILanguageServer, IDocumentHandler {
this.client = client;
}
@Nullable
@Override
public ILanguageClient getClient () {
return this.client;
}
@Override
public void applySettings (@Nullable IServerSettings settings) {
this.settings = settings;