Java Code Examples for org.eclipse.lsp4j.InitializeParams#setProcessId()

The following examples show how to use org.eclipse.lsp4j.InitializeParams#setProcessId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCamelLanguageServerTest.java    From camel-language-server with Apache License 2.0 5 votes vote down vote up
private InitializeParams getInitParams() throws URISyntaxException {
	InitializeParams params = new InitializeParams();
	params.setProcessId(new Random().nextInt());
	params.setRootUri(getTestResource("/workspace/").toURI().toString());
	params.setInitializationOptions(getInitializationOptions());
	return params;
}
 
Example 2
Source File: LSPBindings.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static InitializeResult initServer(Process p, LanguageServer server, FileObject root) throws InterruptedException, ExecutionException {
   InitializeParams initParams = new InitializeParams();
   initParams.setRootUri(Utils.toURI(root));
   initParams.setRootPath(FileUtil.toFile(root).getAbsolutePath()); //some servers still expect root path
   initParams.setProcessId(0);
   TextDocumentClientCapabilities tdcc = new TextDocumentClientCapabilities();
   DocumentSymbolCapabilities dsc = new DocumentSymbolCapabilities();
   dsc.setHierarchicalDocumentSymbolSupport(true);
   dsc.setSymbolKind(new SymbolKindCapabilities(Arrays.asList(SymbolKind.values())));
   tdcc.setDocumentSymbol(dsc);
   WorkspaceClientCapabilities wcc = new WorkspaceClientCapabilities();
   wcc.setWorkspaceEdit(new WorkspaceEditCapabilities());
   wcc.getWorkspaceEdit().setDocumentChanges(true);
   wcc.getWorkspaceEdit().setResourceOperations(Arrays.asList(ResourceOperationKind.Create, ResourceOperationKind.Delete, ResourceOperationKind.Rename));
   initParams.setCapabilities(new ClientCapabilities(wcc, tdcc, null));
   CompletableFuture<InitializeResult> initResult = server.initialize(initParams);
   while (true) {
       try {
           return initResult.get(100, TimeUnit.MILLISECONDS);
       } catch (TimeoutException ex) {
           if (p != null && !p.isAlive()) {
               InitializeResult emptyResult = new InitializeResult();
               emptyResult.setCapabilities(new ServerCapabilities());
               return emptyResult;
           }
       }
   }
}
 
Example 3
Source File: AbstractLanguageServerTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected InitializeResult initialize(final Procedure1<? super InitializeParams> initializer, final boolean callInitialized) {
  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()));
      String _rootUri = it.getRootUri();
      WorkspaceFolder _workspaceFolder = new WorkspaceFolder(_rootUri, "");
      it.setWorkspaceFolders(Collections.<WorkspaceFolder>unmodifiableList(CollectionLiterals.<WorkspaceFolder>newArrayList(_workspaceFolder)));
    };
    final InitializeParams params = ObjectExtensions.<InitializeParams>operator_doubleArrow(_initializeParams, _function);
    if (initializer!=null) {
      initializer.apply(params);
    }
    Boolean _elvis = null;
    ClientCapabilities _capabilities = params.getCapabilities();
    TextDocumentClientCapabilities _textDocument = null;
    if (_capabilities!=null) {
      _textDocument=_capabilities.getTextDocument();
    }
    DocumentSymbolCapabilities _documentSymbol = null;
    if (_textDocument!=null) {
      _documentSymbol=_textDocument.getDocumentSymbol();
    }
    Boolean _hierarchicalDocumentSymbolSupport = null;
    if (_documentSymbol!=null) {
      _hierarchicalDocumentSymbolSupport=_documentSymbol.getHierarchicalDocumentSymbolSupport();
    }
    if (_hierarchicalDocumentSymbolSupport != null) {
      _elvis = _hierarchicalDocumentSymbolSupport;
    } else {
      _elvis = Boolean.valueOf(false);
    }
    this.hierarchicalDocumentSymbolSupport = (_elvis).booleanValue();
    final InitializeResult result = this.languageServer.initialize(params).get();
    if (callInitialized) {
      this.languageServer.initialized(null);
    }
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 4
Source File: InitializeParamsTypeAdapter.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
public InitializeParams read(final JsonReader in) throws IOException {
  JsonToken nextToken = in.peek();
  if (nextToken == JsonToken.NULL) {
  	return null;
  }
  
  InitializeParams result = new InitializeParams();
  in.beginObject();
  while (in.hasNext()) {
  	String name = in.nextName();
  	switch (name) {
  	case "processId":
  		result.setProcessId(readProcessId(in));
  		break;
  	case "rootPath":
  		result.setRootPath(readRootPath(in));
  		break;
  	case "rootUri":
  		result.setRootUri(readRootUri(in));
  		break;
  	case "initializationOptions":
  		result.setInitializationOptions(readInitializationOptions(in));
  		break;
  	case "capabilities":
  		result.setCapabilities(readCapabilities(in));
  		break;
  	case "clientName":
  		result.setClientName(readClientName(in));
  		break;
  	case "clientInfo":
  		result.setClientInfo(readClientInfo(in));
  		break;
  	case "trace":
  		result.setTrace(readTrace(in));
  		break;
  	case "workspaceFolders":
  		result.setWorkspaceFolders(readWorkspaceFolders(in));
  		break;
  	default:
  		in.skipValue();
  	}
  }
  in.endObject();
  return result;
}