Search in sources :

Example 1 with ProjectExtensionKey

use of org.eclipse.che.api.languageserver.shared.ProjectExtensionKey in project che by eclipse.

the class LanguageServerRegistry method register.

/**
     * Registers language server description and capabilities.
     */
protected void register(String projectPath, LanguageDescription languageDescription, ServerCapabilities capabilities) {
    InitializeResult initializeResult = new InitializeResultImpl(capabilities, languageDescription);
    for (String ext : languageDescription.getFileExtensions()) {
        ProjectExtensionKey key = createProjectKey(projectPath, ext);
        projectToInitResult.put(key, initializeResult);
        if (callbackMap.containsKey(key)) {
            Callback<InitializeResult, Throwable> callback = callbackMap.remove(key);
            callback.onSuccess(initializeResult);
        }
    }
}
Also used : InitializeResult(io.typefox.lsapi.InitializeResult) ProjectExtensionKey(org.eclipse.che.api.languageserver.shared.ProjectExtensionKey) InitializeResultImpl(org.eclipse.che.api.languageserver.shared.model.impl.InitializeResultImpl)

Example 2 with ProjectExtensionKey

use of org.eclipse.che.api.languageserver.shared.ProjectExtensionKey in project che by eclipse.

the class LanguageServerRegistryImpl method findServer.

@Nullable
protected LanguageServer findServer(String extension, String projectPath) throws LanguageServerException {
    ProjectExtensionKey projectKey = createProjectKey(projectPath, extension);
    for (LanguageServerLauncher launcher : extensionToLauncher.get(extension)) {
        if (!projectToServer.containsKey(projectKey)) {
            synchronized (launcher) {
                if (!projectToServer.containsKey(projectKey)) {
                    LanguageServer server = initializer.initialize(launcher, projectPath);
                    projectToServer.put(projectKey, server);
                }
            }
        }
        return projectToServer.get(projectKey);
    }
    return null;
}
Also used : LanguageServer(io.typefox.lsapi.services.LanguageServer) ProjectExtensionKey(org.eclipse.che.api.languageserver.shared.ProjectExtensionKey) LanguageServerLauncher(org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher) Nullable(org.eclipse.che.commons.annotation.Nullable)

Aggregations

ProjectExtensionKey (org.eclipse.che.api.languageserver.shared.ProjectExtensionKey)2 InitializeResult (io.typefox.lsapi.InitializeResult)1 LanguageServer (io.typefox.lsapi.services.LanguageServer)1 LanguageServerLauncher (org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher)1 InitializeResultImpl (org.eclipse.che.api.languageserver.shared.model.impl.InitializeResultImpl)1 Nullable (org.eclipse.che.commons.annotation.Nullable)1