Search in sources :

Example 6 with LanguageServerException

use of org.eclipse.che.api.languageserver.exception.LanguageServerException in project che by eclipse.

the class LanguageServerRegistryImpl method extractProjectPath.

protected String extractProjectPath(String filePath) throws LanguageServerException {
    FolderEntry root;
    try {
        root = projectManagerProvider.get().getProjectsRoot();
    } catch (ServerException e) {
        throw new LanguageServerException("Project not found for " + filePath, e);
    }
    if (!filePath.startsWith(PROJECT_FOLDER_PATH)) {
        throw new LanguageServerException("Project not found for " + filePath);
    }
    VirtualFileEntry fileEntry;
    try {
        fileEntry = root.getChild(filePath.substring(PROJECT_FOLDER_PATH.length() + 1));
    } catch (ServerException e) {
        throw new LanguageServerException("Project not found for " + filePath, e);
    }
    if (fileEntry == null) {
        throw new LanguageServerException("Project not found for " + filePath);
    }
    return PROJECT_FOLDER_PATH + fileEntry.getProject();
}
Also used : LanguageServerException(org.eclipse.che.api.languageserver.exception.LanguageServerException) LanguageServerException(org.eclipse.che.api.languageserver.exception.LanguageServerException) ServerException(org.eclipse.che.api.core.ServerException) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry)

Example 7 with LanguageServerException

use of org.eclipse.che.api.languageserver.exception.LanguageServerException in project che by eclipse.

the class ServerInitializerImpl method doInitialize.

protected LanguageServer doInitialize(LanguageServerLauncher launcher, String projectPath) throws LanguageServerException {
    String languageId = launcher.getLanguageDescription().getLanguageId();
    InitializeParamsImpl initializeParams = prepareInitializeParams(projectPath);
    LanguageServer server;
    try {
        server = launcher.launch(projectPath);
    } catch (LanguageServerException e) {
        throw new LanguageServerException("Can't initialize Language Server " + languageId + " on " + projectPath + ". " + e.getMessage(), e);
    }
    registerCallbacks(server);
    CompletableFuture<InitializeResult> completableFuture = server.initialize(initializeParams);
    try {
        InitializeResult initializeResult = completableFuture.get();
        serversToInitResult.put(server, new LanguageServerDescription(initializeResult, launcher.getLanguageDescription()));
    } catch (InterruptedException | ExecutionException e) {
        server.shutdown();
        server.exit();
        throw new LanguageServerException("Error fetching server capabilities " + languageId + ". " + e.getMessage(), e);
    }
    LOG.info("Initialized Language Server {} on project {}", languageId, projectPath);
    return server;
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) LanguageServerException(org.eclipse.che.api.languageserver.exception.LanguageServerException) InitializeResult(io.typefox.lsapi.InitializeResult) InitializeParamsImpl(io.typefox.lsapi.impl.InitializeParamsImpl) ExecutionException(java.util.concurrent.ExecutionException)

Example 8 with LanguageServerException

use of org.eclipse.che.api.languageserver.exception.LanguageServerException in project che by eclipse.

the class PythonLanguageSeverLauncher method startLanguageServerProcess.

@Override
protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException {
    ProcessBuilder processBuilder = new ProcessBuilder(launchScript.toString());
    processBuilder.redirectInput(ProcessBuilder.Redirect.PIPE);
    processBuilder.redirectOutput(ProcessBuilder.Redirect.PIPE);
    try {
        return processBuilder.start();
    } catch (IOException e) {
        throw new LanguageServerException("Can't start CSharp language server", e);
    }
}
Also used : LanguageServerException(org.eclipse.che.api.languageserver.exception.LanguageServerException) IOException(java.io.IOException)

Aggregations

LanguageServerException (org.eclipse.che.api.languageserver.exception.LanguageServerException)8 IOException (java.io.IOException)6 InitializeResult (io.typefox.lsapi.InitializeResult)1 InitializeParamsImpl (io.typefox.lsapi.impl.InitializeParamsImpl)1 LanguageServer (io.typefox.lsapi.services.LanguageServer)1 File (java.io.File)1 ExecutionException (java.util.concurrent.ExecutionException)1 ServerException (org.eclipse.che.api.core.ServerException)1 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)1 VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)1