Search in sources :

Example 6 with LanguageServer

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;
    }
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 7 with LanguageServer

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);
    }
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 8 with LanguageServer

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();
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 9 with LanguageServer

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;
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) LocationImpl(io.typefox.lsapi.impl.LocationImpl) Location(io.typefox.lsapi.Location) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 10 with LanguageServer

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"));
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) InitializeResult(io.typefox.lsapi.InitializeResult) InitializeParams(io.typefox.lsapi.InitializeParams) ServerCapabilities(io.typefox.lsapi.ServerCapabilities) Test(org.testng.annotations.Test)

Aggregations

LanguageServer (io.typefox.lsapi.services.LanguageServer)21 Consumes (javax.ws.rs.Consumes)15 POST (javax.ws.rs.POST)15 Path (javax.ws.rs.Path)15 Produces (javax.ws.rs.Produces)10 LocationImpl (io.typefox.lsapi.impl.LocationImpl)3 InitializeResult (io.typefox.lsapi.InitializeResult)2 Test (org.testng.annotations.Test)2 InitializeParams (io.typefox.lsapi.InitializeParams)1 Location (io.typefox.lsapi.Location)1 ServerCapabilities (io.typefox.lsapi.ServerCapabilities)1 InitializeParamsImpl (io.typefox.lsapi.impl.InitializeParamsImpl)1 ExecutionException (java.util.concurrent.ExecutionException)1 PreDestroy (javax.annotation.PreDestroy)1 LanguageServerException (org.eclipse.che.api.languageserver.exception.LanguageServerException)1 LanguageServerLauncher (org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher)1 ProjectExtensionKey (org.eclipse.che.api.languageserver.shared.ProjectExtensionKey)1 Nullable (org.eclipse.che.commons.annotation.Nullable)1