use of org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage in project sts4 by spring-projects.
the class DelegatingStreamConnectionProvider method handleMessage.
@Override
public void handleMessage(Message message, LanguageServer languageServer, URI rootURI) {
if (message instanceof ResponseMessage) {
ResponseMessage responseMessage = (ResponseMessage) message;
if (responseMessage.getResult() instanceof InitializeResult) {
this.languageServer = languageServer;
sendConfiguration();
// Add config listener
BootLanguageServerPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(configListener);
// Add resource listener
ResourcesPlugin.getWorkspace().addResourceChangeListener(fResourceListener = new ResourceListener(languageServer, Arrays.asList(FileSystems.getDefault().getPathMatcher("glob:**/pom.xml"), FileSystems.getDefault().getPathMatcher("glob:**/*.gradle"), FileSystems.getDefault().getPathMatcher("glob:**/*.java"))));
}
}
}
use of org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage in project sts4 by spring-projects.
the class CloudFoundryManifestLanguageServer method handleMessage.
@Override
public void handleMessage(Message message, LanguageServer languageServer, URI rootPath) {
if (message instanceof ResponseMessage) {
ResponseMessage responseMessage = (ResponseMessage) message;
if (responseMessage.getResult() instanceof InitializeResult) {
this.languageServer = languageServer;
this.rootPath = rootPath;
updateLanguageServer();
addLanguageServer(this);
}
}
}
use of org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage in project ballerina by ballerina-lang.
the class CommonUtil method getLanguageServerResponseMessageAsString.
/**
* Get the definition response message as a string.
*
* @param position hovering position to get the definition.
* @param file bal file path
* @param fileContent bal file content
* @param method string name of the language feature method
* @return json string value of the response
*/
public static String getLanguageServerResponseMessageAsString(Position position, String file, String fileContent, String method) throws InterruptedException {
Gson gson = new Gson();
BallerinaLanguageServer ballerinaLanguageServer = new BallerinaLanguageServer();
Endpoint serviceEndpoint = ServiceEndpoints.toEndpoint(ballerinaLanguageServer);
TextDocumentPositionParams positionParams = new TextDocumentPositionParams();
TextDocumentIdentifier identifier = new TextDocumentIdentifier();
identifier.setUri(Paths.get(file).toUri().toString());
positionParams.setTextDocument(identifier);
positionParams.setPosition(position);
DidOpenTextDocumentParams documentParams = new DidOpenTextDocumentParams();
TextDocumentItem textDocumentItem = new TextDocumentItem();
textDocumentItem.setUri(identifier.getUri());
textDocumentItem.setText(fileContent);
documentParams.setTextDocument(textDocumentItem);
serviceEndpoint.notify("textDocument/didOpen", documentParams);
CompletableFuture result = serviceEndpoint.request(method, positionParams);
ResponseMessage jsonrpcResponse = new ResponseMessage();
try {
jsonrpcResponse.setId("324");
jsonrpcResponse.setResult(result.get());
} catch (InterruptedException e) {
ResponseError responseError = new ResponseError();
responseError.setCode(-32002);
responseError.setMessage("Attempted to retrieve the result of a task/s" + "that was aborted by throwing an exception");
jsonrpcResponse.setError(responseError);
} catch (ExecutionException e) {
ResponseError responseError = new ResponseError();
responseError.setCode(-32001);
responseError.setMessage("Current thread was interrupted");
jsonrpcResponse.setError(responseError);
}
return gson.toJson(jsonrpcResponse);
}
Aggregations