Search in sources :

Example 1 with LanguageServer

use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.

the class TextDocumentService method definition.

@POST
@Path("definition")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends Location> definition(TextDocumentPositionParamsDTO params) throws ExecutionException, InterruptedException, LanguageServerException {
    params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri()));
    LanguageServer server = getServer(params.getTextDocument().getUri());
    if (server == null) {
        return emptyList();
    }
    List<? extends Location> locations = server.getTextDocumentService().definition(params).get();
    locations.forEach(o -> {
        if (o instanceof LocationImpl) {
            ((LocationImpl) o).setUri(removePrefixUri(o.getUri()));
        }
    });
    return locations;
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) LocationImpl(io.typefox.lsapi.impl.LocationImpl) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with LanguageServer

use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.

the class TextDocumentService method onTypeFormatting.

@POST
@Path("onTypeFormatting")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends TextEdit> onTypeFormatting(DocumentOnTypeFormattingParamsDTO params) throws InterruptedException, ExecutionException, LanguageServerException {
    params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri()));
    LanguageServer server = getServer(params.getTextDocument().getUri());
    if (server == null) {
        return emptyList();
    }
    return server.getTextDocumentService().onTypeFormatting(params).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 3 with LanguageServer

use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.

the class TextDocumentService method didOpen.

@POST
@Path("didOpen")
@Consumes(MediaType.APPLICATION_JSON)
public void didOpen(DidOpenTextDocumentParamsDTO openEvent) throws LanguageServerException {
    openEvent.getTextDocument().setUri(prefixURI(openEvent.getTextDocument().getUri()));
    openEvent.setUri(prefixURI(openEvent.getUri()));
    LanguageServer server = getServer(openEvent.getTextDocument().getUri());
    if (server != null) {
        server.getTextDocumentService().didOpen(openEvent);
    }
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 4 with LanguageServer

use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.

the class TextDocumentService method didChange.

@POST
@Path("didChange")
@Consumes(MediaType.APPLICATION_JSON)
public void didChange(DidChangeTextDocumentParamsDTO change) throws LanguageServerException {
    change.getTextDocument().setUri(prefixURI(change.getTextDocument().getUri()));
    change.setUri(prefixURI(change.getUri()));
    LanguageServer server = getServer(change.getTextDocument().getUri());
    if (server != null) {
        server.getTextDocumentService().didChange(change);
    }
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 5 with LanguageServer

use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.

the class TextDocumentService method formatting.

@POST
@Path("formatting")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public List<? extends TextEdit> formatting(DocumentFormattingParamsDTO params) throws InterruptedException, ExecutionException, LanguageServerException {
    params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri()));
    LanguageServer server = getServer(params.getTextDocument().getUri());
    if (server == null) {
        return emptyList();
    }
    return server.getTextDocumentService().formatting(params).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)

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