use of io.typefox.lsapi.InitializeResult 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);
}
}
}
use of io.typefox.lsapi.InitializeResult in project che by eclipse.
the class LanguageServerEditorProvider method createEditor.
@Override
public Promise<EditorPartPresenter> createEditor(VirtualFile file) {
if (file instanceof File) {
File resource = (File) file;
Promise<InitializeResult> promise = registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getLocation().toString());
final MessageLoader loader = loaderFactory.newLoader("Initializing Language Server for " + resource.getExtension());
loader.show();
return promise.thenPromise(new Function<InitializeResult, Promise<EditorPartPresenter>>() {
@Override
public Promise<EditorPartPresenter> apply(InitializeResult arg) throws FunctionException {
loader.hide();
return Promises.<EditorPartPresenter>resolve(createEditor(editorConfigurationFactory.build(arg.getCapabilities())));
}
});
}
return null;
}
use of io.typefox.lsapi.InitializeResult 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;
}
Aggregations