微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.eclipse.lsp4j.InitializeParams的实例源码

项目: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;
}
项目:che    文件ServerInitializerImpltest.java   
@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   
private Map<?,?> getinitializationoptions(InitializeParams params) {
    Object initializationoptions = params.getinitializationoptions();
    if (initializationoptions instanceof Map<?,?>) {
        return (Map<?,?>) initializationoptions;
    }
    return null;
}
项目:xtext-core    文件LanguageServerImpl.java   
protected URI getBaseDir(final InitializeParams params) {
  String _rootUri = params.getRootUri();
  boolean _tripleNotEquals = (_rootUri != null);
  if (_tripleNotEquals) {
    return this._uriExtensions.toUri(params.getRootUri());
  }
  return this.deprecatedToBaseDir(params);
}
项目: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();
}
项目:che    文件LanguageServerRegistryImpltest.java   
@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   
/**
 * Allows an individual language to contribute to and overwrite properties in the server's capabilities.
 */
public abstract ServerCapabilities contribute(final ServerCapabilities capabilities,final InitializeParams params);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。