项目:camel-language-server
文件:CamelLanguageServer.java
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
sendLogMessageNotification(MessageType.Info,"Initializing capabilities of the server...");
Integer processId = params.getProcessId();
if(processId != null) {
setParentProcessId(processId.longValue());
} else {
sendLogMessageNotification(MessageType.Info,"Missing Parent process ID!!");
setParentProcessId(0);
}
InitializeResult result = new InitializeResult();
ServerCapabilities capabilities = new ServerCapabilities();
capabilities.setTextDocumentSync(TextDocumentSyncKind.Full);
capabilities.setCompletionProvider(new Completionoptions(Boolean.TRUE,Arrays.asList(".","?","&","\"","=")));
capabilities.setHoverProvider(Boolean.TRUE);
result.setCapabilities(capabilities);
return CompletableFuture.completedFuture(result);
}
项目:camel-language-server
文件:AbstractCamelLanguageServerTest.java
protected CamelLanguageServer initializeLanguageServer(String text)
throws URISyntaxException,InterruptedException,ExecutionException {
InitializeParams params = new InitializeParams();
params.setProcessId(new Random().nextInt());
params.setRootUri(getTestResource("/workspace/").toURI().toString());
CamelLanguageServer camelLanguageServer = new CamelLanguageServer();
camelLanguageServer.connect(new DummyLanguageClient());
CompletableFuture<InitializeResult> initialize = camelLanguageServer.initialize(params);
assertthat(initialize).isCompleted();
assertthat(initialize.get().getCapabilities().getCompletionProvider().getResolveProvider()).isTrue();
camelLanguageServer.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(createTestTextDocument(text)));
return camelLanguageServer;
}
项目:eclipse.jdt.ls
文件:InitHandlerTest.java
private InitializeResult initialize(boolean dynamicRegistration) throws InterruptedException,ExecutionException {
InitializeParams params = new InitializeParams();
ClientCapabilities capabilities = new ClientCapabilities();
WorkspaceClientCapabilities workspaceCapabilities = new WorkspaceClientCapabilities();
workspaceCapabilities.setDidChangeConfiguration(new DidChangeConfigurationCapabilities(dynamicRegistration));
ExecuteCommandCapabilities executeCommand = new ExecuteCommandCapabilities(dynamicRegistration);
workspaceCapabilities.setExecuteCommand(executeCommand);
capabilities.setWorkspace(workspaceCapabilities);
TextDocumentClientCapabilities textDocument = new TextDocumentClientCapabilities();
SynchronizationCapabilities synchronizationCapabilities = new SynchronizationCapabilities();
synchronizationCapabilities.setwillSave(Boolean.TRUE);
synchronizationCapabilities.setwillSaveWaitUntil(Boolean.TRUE);
capabilities.setTextDocument(textDocument);
params.setCapabilities(capabilities);
CompletableFuture<InitializeResult> result = server.initialize(params);
return result.get();
}
项目:xtext-core
文件:AbstractLanguageServerTest.java
protected InitializeResult initialize(final Procedure1<? super InitializeParams> initializer) {
try {
InitializeParams _initializeParams = new InitializeParams();
final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
it.setProcessId(Integer.valueOf(1));
it.setRootUri(this._uriExtensions.toUriString(this.root.toURI().normalize()));
};
final InitializeParams params = ObjectExtensions.<InitializeParams>operator_doubleArrow(_initializeParams,_function);
if (initializer!=null) {
initializer.apply(params);
}
return this.languageServer.initialize(params).get();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
项目:xtext-core
文件:LanguageServerImpl.java
@Deprecated
private URI deprecatedToBaseDir(final InitializeParams params) {
String _rootPath = params.getRootPath();
boolean _tripleNotEquals = (_rootPath != null);
if (_tripleNotEquals) {
return this._uriExtensions.toUri(this._uriExtensions.toUriString(URI.createFileURI(params.getRootPath())));
}
return null;
}
@Test
public void initializerShouldNotifyObservers() throws Exception {
when(languageDescription.getLanguageId()).thenReturn("languageId");
when(server.initialize(any(InitializeParams.class))).thenReturn(CompletableFuture);
when(launcher.launch(anyString(),any())).thenReturn(server);
when(launcher.getDescription()).thenReturn(serverDescription);
when(serverDescription.getId()).thenReturn("launcherId");
donothing().when(initializer).registerCallbacks(any(),any());
initializer.addobserver(observer);
Pair<LanguageServer,InitializeResult> initResult =
initializer.initialize(launcher,null,"/path").get();
assertEquals(server,initResult.first);
verify(observer,timeout(2000))
.onServerInitialized(eq(launcher),eq(server),any(ServerCapabilities.class),eq("/path"));
}
项目:SOMns-vscode
文件:SomLanguageServer.java
@Override
public CompletableFuture<InitializeResult> initialize(final InitializeParams params) {
InitializeResult result = new InitializeResult();
ServerCapabilities cap = new ServerCapabilities();
cap.setTextDocumentSync(TextDocumentSyncKind.Full);
cap.setDocumentSymbolProvider(true);
cap.setWorkspaceSymbolProvider(true);
cap.setDeFinitionProvider(true);
cap.setCodeLensprovider(new CodeLensOptions(true));
cap.setExecuteCommandProvider(
new ExecuteCommandOptions(Lists.newArrayList(SomMinitest.COMMAND)));
Completionoptions completion = new Completionoptions();
List<String> autoCompltrigger = new ArrayList<>();
autoCompltrigger.add("#"); // Smalltalk symbols
autoCompltrigger.add(":"); // end of keywords,to complete arguments
autoCompltrigger.add("="); // right-hand side of assignments
completion.setTriggerCharacters(autoCompltrigger);
completion.setResolveProvider(false); // Todo: look into that
cap.setCompletionProvider(completion);
result.setCapabilities(cap);
loadWorkspace(params);
return CompletableFuture.completedFuture(result);
}
项目:SOMns-vscode
文件:SomLanguageServer.java
private void loadWorkspace(final InitializeParams params) {
try {
som.loadWorkspace(params.getRootUri());
} catch (URISyntaxException e) {
MessageParams msg = new MessageParams();
msg.setType(MessageType.Error);
msg.setMessage("Workspace root URI invalid: " + params.getRootUri());
client.logMessage(msg);
ServerLauncher.logErr(msg.getMessage());
}
}
项目:eclipse.jdt.ls
文件:InitHandler.java
项目:xtext-core
文件:LanguageServerImpl.java
项目:eclipse.jdt.ls
文件:JDTLanguageServer.java
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
logInfo(">> initialize");
InitHandler handler = new InitHandler(pm,preferenceManager,client);
return CompletableFuture.completedFuture(handler.initialize(params));
}
项目:lsp4j
文件:MockLanguageServer.java
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
throw new UnsupportedOperationException();
}
项目:lsp4j
文件:NullResponseTest.java
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
throw new UnsupportedOperationException();
}
@BeforeMethod
public void setUp() throws Exception {
this.serverCapabilities = new ServerCapabilities();
serverDescription =
new LanguageServerDescription(
"foo",Collections.singletonList("id"),Collections.emptyList());
initializeResult = new InitializeResult(serverCapabilities);
CompletableFuture = completedFuture(initializeResult);
when(languageServerLauncher.isAbletoLaunch()).thenReturn(true);
when(languageServerLauncher.getDescription()).thenReturn(serverDescription);
when(languageServerLauncher.isLocal()).thenReturn(true);
when(languageDescription.getLanguageId()).thenReturn("id");
when(languageDescription.getFileExtensions()).thenReturn(Collections.singletonList("txt"));
when(languageDescription.getMimeType()).thenReturn("plain/text");
when(languageServer.getTextDocumentService()).thenReturn(mock(TextDocumentService.class));
when(languageServer.initialize(any(InitializeParams.class))).thenReturn(CompletableFuture);
when(languageRecognizer.recognizeByPath(anyString())).thenReturn(languageDescription);
when(languageRecognizer.recognizeById(anyString())).thenReturn(languageDescription);
when(pmp.get()).thenReturn(pm);
when(clientFactory.create(anyString())).thenReturn(languageClient);
when(httpJsonRequestFactory.fromUrl(any(String.class))).thenReturn(httpJsonRequest);
when(httpJsonRequest.usegetmethod()).thenReturn(httpJsonRequest);
when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
when(httpJsonResponse.asDto(any())).thenReturn(workspace);
registry =
spy(
new LanguageServerRegistryImpl(
"","",httpJsonRequestFactory,new HashSet<>(),Collections.singleton(languageServerLauncher),Collections.singleton(languageDescription),pmp,initializer,clientFactory,languageRecognizer) {
@Override
protected String extractProjectPath(String filePath) throws LanguageServerException {
return PROJECT_PATH;
}
});
when(initializer.initialize(
any(LanguageServerLauncher.class),any(LanguageClient.class),anyString()))
.thenAnswer(invocation -> completedFuture(Pair.of(languageServer,initializeResult)));
}
项目:che
文件:MavenLanguageServer.java
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
ServerCapabilities capabilities = new ServerCapabilities();
capabilities.setTextDocumentSync(TextDocumentSyncKind.Incremental);
return CompletableFuture.completedFuture(new InitializeResult(capabilities));
}
项目:lsp4j
文件:LanguageServer.java
/**
* The initialize request is sent as the first request from the client to
* the server.
*
* If the server receives request or notification before the initialize request it should act as follows:
* - for a request the respond should be errored with code: -32001. The message can be picked by the server.
* - notifications should be dropped,except for the exit notification. This will allow the exit a server without an initialize request.
*
* Until the server has responded to the initialize request with an InitializeResult
* the client must not sent any additional requests or notifications to the server.
*
* During the initialize request the server is allowed to sent the notifications window/showMessage,* window/logMessage and telemetry/event as well as the window/showMessageRequest request to the client.
*/
@JsonRequest
CompletableFuture<InitializeResult> initialize(InitializeParams params);
项目:SOMns-vscode
文件:LanguageServer.java
/**
* The initialize request is sent as the first request from the client to
* the server.
*
* If the server receives request or notification before the initialize request it should act as follows:
* - for a request the respond should be errored with code: -32001. The message can be picked by the server.
* - notifications should be dropped,* window/logMessage and telemetry/event as well as the window/showMessageRequest request to the client.
*/
@JsonRequest
CompletableFuture<InitializeResult> initialize(InitializeParams params);
项目:xtext-core
文件:ICapabilitiesContributor.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。