jlahoda commented on a change in pull request #2324:
URL: https://github.com/apache/netbeans/pull/2324#discussion_r512436463
##########
File path: ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java
##########
@@ -232,6 +250,8 @@ private static InitializeResult initServer(Process p,
LanguageServer server, Fil
wcc.setWorkspaceEdit(new WorkspaceEditCapabilities());
wcc.getWorkspaceEdit().setDocumentChanges(true);
wcc.getWorkspaceEdit().setResourceOperations(Arrays.asList(ResourceOperationKind.Create,
ResourceOperationKind.Delete, ResourceOperationKind.Rename));
+ SymbolCapabilities sc = new SymbolCapabilities(new
SymbolKindCapabilities(Arrays.asList(SymbolKind.values())));
+ wcc.setSymbol(sc);
initParams.setCapabilities(new ClientCapabilities(wcc, tdcc, null));
Review comment:
Not sure if that's better, but when I was experimenting with the
semantic highlighting, it seemed there is a way to extend the protocol mostly
transparently:
-when sending data, just create a subclass of the class you want to send,
and add annotated getters for the additional data you want to create
-when receiving data, the main Gson instance need to create the extended
subclass. One way I've found that could be used is to inject a different Gson
while creating the LSPLauncher:
```
Launcher<LanguageServer> launcher = LSPLauncher.createClientLauncher(lci,
in, out);
=>
Launcher<LanguageServer> launcher = new LSPLauncher.Builder<LanguageServer>()
.setLocalService(lci)
.setRemoteInterface(LanguageServer.class)
.setInput(in)
.setOutput(out)
.configureGson(gson -> {
gson.registerTypeAdapterFactory(new TypeAdapterFactory() {
@Override
public <T>
TypeAdapter<T> create(Gson gson, TypeToken<T> tt) {
if
(tt.getRawType() == ServerCapabilities.class) {
return new TypeAdapter<T>() {
@Override
public void write(JsonWriter writer, T t) throws IOException {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public T read(JsonReader reader) throws IOException {
return gson.fromJson(reader, NBServerCapabilities.class);
}
};
}
return
null;
}
});
}).create();
```
-to call additional methods/invocation points, use (I was only trying this
on the client side so far):
```
ServiceEndpoints.toServiceObject(launcher.getRemoteEndpoint(),
SemanticService.class)
```
where:
```
public interface SemanticService {
@JsonRequest("textDocument/semanticTokens/full")
public CompletableFuture<JsonObject>
semanticTokensFull(SemanticTokensParams params);
}
```
This seemed to more or less work, but I didn't finish this work yet, so
there may be a problem lurking somewhere.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists