use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class ServerInitializerImpl method initialize.
@Override
public LanguageServer initialize(LanguageServerLauncher launcher, String projectPath) throws LanguageServerException {
String languageId = launcher.getLanguageDescription().getLanguageId();
synchronized (launcher) {
LanguageServer server = languageIdToServers.get(languageId);
if (server != null) {
server = doInitialize(launcher, projectPath);
} else {
server = doInitialize(launcher, projectPath);
languageIdToServers.put(languageId, server);
}
onServerInitialized(server, serversToInitResult.get(server).getInitializeResult().getCapabilities(), launcher.getLanguageDescription(), projectPath);
return server;
}
}
use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class TextDocumentService method documentHighlight.
@POST
@Path("documentHighlight")
@Consumes(MediaType.APPLICATION_JSON)
public DocumentHighlight documentHighlight(TextDocumentPositionParamsDTO positionParams) throws LanguageServerException, InterruptedException, ExecutionException {
positionParams.getTextDocument().setUri(prefixURI(positionParams.getTextDocument().getUri()));
LanguageServer server = getServer(positionParams.getTextDocument().getUri());
if (server != null) {
return server.getTextDocumentService().documentHighlight(positionParams).get();
}
return null;
}
use of io.typefox.lsapi.services.LanguageServer 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;
}
use of io.typefox.lsapi.services.LanguageServer in project che by eclipse.
the class ServerInitializerImpl method shutdown.
@PreDestroy
protected void shutdown() {
for (LanguageServer server : serversToInitResult.keySet()) {
server.shutdown();
server.exit();
}
}
use of io.typefox.lsapi.services.LanguageServer 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