use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class TextDocumentService method hover.
@POST
@Path("hover")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Hover hover(TextDocumentPositionParamsDTO positionParams) throws LanguageServerException, ExecutionException, InterruptedException {
positionParams.getTextDocument().setUri(prefixURI(positionParams.getTextDocument().getUri()));
positionParams.setUri(prefixURI(positionParams.getUri()));
LanguageServer server = getServer(positionParams.getTextDocument().getUri());
if (server != null) {
return server.getTextDocumentService().hover(positionParams).get();
} else {
return null;
}
}
use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class TextDocumentService method didClose.
@POST
@Path("didClose")
@Consumes(MediaType.APPLICATION_JSON)
public void didClose(DidCloseTextDocumentParamsDTO closeEvent) throws LanguageServerException {
closeEvent.getTextDocument().setUri(prefixURI(closeEvent.getTextDocument().getUri()));
LanguageServer server = getServer(closeEvent.getTextDocument().getUri());
if (server != null) {
server.getTextDocumentService().didClose(closeEvent);
}
}
use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class TextDocumentService method documentSymbol.
@POST
@Path("documentSymbol")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends SymbolInformation> documentSymbol(DocumentSymbolParamsDTO documentSymbolParams) throws ExecutionException, InterruptedException, LanguageServerException {
documentSymbolParams.getTextDocument().setUri(prefixURI(documentSymbolParams.getTextDocument().getUri()));
LanguageServer server = getServer(documentSymbolParams.getTextDocument().getUri());
if (server == null) {
return emptyList();
}
return server.getTextDocumentService().documentSymbol(documentSymbolParams).get();
}
use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class WorkspaceService method documentSymbol.
@POST
@Path("symbol")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends SymbolInformation> documentSymbol(WorkspaceSymbolParamsDTO workspaceSymbolParams) throws ExecutionException, InterruptedException, LanguageServerException {
LanguageServer server = getServer(TextDocumentService.prefixURI(workspaceSymbolParams.getFileUri()));
if (server == null) {
return emptyList();
}
List<? extends SymbolInformation> informations = server.getWorkspaceService().symbol(workspaceSymbolParams).get();
informations.forEach(o -> {
Location location = o.getLocation();
if (location instanceof LocationImpl) {
((LocationImpl) location).setUri(TextDocumentService.removePrefixUri(location.getUri()));
}
});
return informations;
}
use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class ServerInitializerImplTest method initializerShouldNotifyObservers.
@Test
public void initializerShouldNotifyObservers() throws Exception {
when(languageDescription.getLanguageId()).thenReturn("languageId");
when(server.initialize(any(InitializeParams.class))).thenReturn(completableFuture);
when(completableFuture.get()).thenReturn(mock(InitializeResult.class));
when(launcher.getLanguageDescription()).thenReturn(languageDescription);
when(launcher.launch(anyString())).thenReturn(server);
doNothing().when(initializer).registerCallbacks(server);
initializer.addObserver(observer);
LanguageServer languageServer = initializer.initialize(launcher, "/path");
assertEquals(server, languageServer);
verify(observer).onServerInitialized(eq(server), any(ServerCapabilities.class), eq(languageDescription), eq("/path"));
}
Aggregations