Java Code Examples for org.eclipse.lsp4j.InitializeParams#setRootUri()
The following examples show how to use
org.eclipse.lsp4j.InitializeParams#setRootUri() .
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: RdfLintLanguageServerTest.java From rdflint with MIT License | 6 votes |
@Test public void diagnosticsNoTarget() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); lsp.refreshFileTripleSet(); verify(client, never()).publishDiagnostics(any()); }
Example 2
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 6 votes |
@Test public void diagnosticsClose() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidCloseTextDocumentParams closeParams = new DidCloseTextDocumentParams(); closeParams.setTextDocument(new TextDocumentIdentifier()); closeParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); lsp.didClose(closeParams); verify(client, times(2)).publishDiagnostics(any()); }
Example 3
Source File: AbstractIdeTest.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** Connects, initializes and waits for the initial build of the test project. */ protected void startLspServer(File root) { ClientCapabilities capabilities = new ClientCapabilities(); WorkspaceClientCapabilities wcc = new WorkspaceClientCapabilities(); wcc.setExecuteCommand(new ExecuteCommandCapabilities()); capabilities.setWorkspace(wcc); InitializeParams initParams = new InitializeParams(); initParams.setCapabilities(capabilities); initParams.setRootUri(new FileURI(root).toString()); languageClient.addListener(this); languageServer.connect(languageClient); languageServer.initialize(initParams); languageServer.initialized(null); joinServerRequests(); }
Example 4
Source File: ProjectsManagerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testCancelInitJob() throws Exception { File workspaceDir = copyFiles("maven/salut", true); String rootPathURI = workspaceDir.toURI().toString(); Collection<IPath> rootPaths = Collections.singleton(ResourceUtils.canonicalFilePathFromURI(rootPathURI)); InitializeParams params = new InitializeParams(); params.setRootUri(rootPathURI); server.initialize(params); Job[] initWorkspaceJobs = Job.getJobManager().find(rootPaths); assertEquals(1, initWorkspaceJobs.length); Job initWorkspaceJob = initWorkspaceJobs[0]; assertNotNull(initWorkspaceJob); projectsManager.updateWorkspaceFolders(Collections.emptySet(), rootPaths); waitForBackgroundJobs(); assertTrue("the init job hasn't been cancelled, status is: " + initWorkspaceJob.getResult().getSeverity(), initWorkspaceJob.getResult().matches(IStatus.CANCEL)); }
Example 5
Source File: LanguageServerWrapper.java From lsp4intellij with Apache License 2.0 | 5 votes |
private InitializeParams getInitParams() { InitializeParams initParams = new InitializeParams(); initParams.setRootUri(FileUtils.pathToUri(projectRootPath)); //TODO update capabilities when implemented WorkspaceClientCapabilities workspaceClientCapabilities = new WorkspaceClientCapabilities(); workspaceClientCapabilities.setApplyEdit(true); workspaceClientCapabilities.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities()); workspaceClientCapabilities.setExecuteCommand(new ExecuteCommandCapabilities()); workspaceClientCapabilities.setWorkspaceEdit(new WorkspaceEditCapabilities()); workspaceClientCapabilities.setSymbol(new SymbolCapabilities()); workspaceClientCapabilities.setWorkspaceFolders(false); workspaceClientCapabilities.setConfiguration(false); TextDocumentClientCapabilities textDocumentClientCapabilities = new TextDocumentClientCapabilities(); textDocumentClientCapabilities.setCodeAction(new CodeActionCapabilities()); textDocumentClientCapabilities.setCompletion(new CompletionCapabilities(new CompletionItemCapabilities(true))); textDocumentClientCapabilities.setDefinition(new DefinitionCapabilities()); textDocumentClientCapabilities.setDocumentHighlight(new DocumentHighlightCapabilities()); textDocumentClientCapabilities.setFormatting(new FormattingCapabilities()); textDocumentClientCapabilities.setHover(new HoverCapabilities()); textDocumentClientCapabilities.setOnTypeFormatting(new OnTypeFormattingCapabilities()); textDocumentClientCapabilities.setRangeFormatting(new RangeFormattingCapabilities()); textDocumentClientCapabilities.setReferences(new ReferencesCapabilities()); textDocumentClientCapabilities.setRename(new RenameCapabilities()); textDocumentClientCapabilities.setSemanticHighlightingCapabilities(new SemanticHighlightingCapabilities(false)); textDocumentClientCapabilities.setSignatureHelp(new SignatureHelpCapabilities()); textDocumentClientCapabilities.setSynchronization(new SynchronizationCapabilities(true, true, true)); initParams.setCapabilities( new ClientCapabilities(workspaceClientCapabilities, textDocumentClientCapabilities, null)); initParams.setInitializationOptions( serverDefinition.getInitializationOptions(URI.create(initParams.getRootUri()))); return initParams; }
Example 6
Source File: AbstractCamelLanguageServerTest.java From camel-language-server with Apache License 2.0 | 5 votes |
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 7
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 5 votes |
@Test public void diagnosticsOpen() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidOpenTextDocumentParams openParams = new DidOpenTextDocumentParams(); openParams.setTextDocument(new TextDocumentItem()); openParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); openParams.getTextDocument().setText("<rdf:RDF\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + " xmlns:schema=\"http://schema.org/\"\n" + " >\n" + "\n" + " <rdf:Description rdf:about=\"something\">\n" + " <schema:familyName xml:lang=\"ja\">familyName </schema:familyName>\n" + " </rdf:Description>\n" + "\n" + "</rdf:RDF>"); lsp.didOpen(openParams); verify(client, times(1)).publishDiagnostics(any()); }
Example 8
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 5 votes |
@Test public void diagnosticsChange() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams(); changeParams.setTextDocument(new VersionedTextDocumentIdentifier()); changeParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); List<TextDocumentContentChangeEvent> changeEvents = new LinkedList<>(); changeParams.setContentChanges(changeEvents); changeEvents.add(new TextDocumentContentChangeEvent()); changeEvents.get(0).setText("<rdf:RDF\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + " xmlns:schema=\"http://schema.org/\"\n" + " >\n" + "\n" + " <rdf:Description rdf:about=\"something\">\n" + " <schema:familyName xml:lang=\"ja\">familyName </schema:familyName>\n" + " </rdf:Description>\n" + "\n" + "</rdf:RDF>"); lsp.didChange(changeParams); verify(client, times(1)).publishDiagnostics(any()); }
Example 9
Source File: RdfLintLanguageServerTest.java From rdflint with MIT License | 5 votes |
@Test public void diagnosticsChangeParseError() throws Exception { RdfLintLanguageServer lsp = new RdfLintLanguageServer(); InitializeParams initParams = new InitializeParams(); String rootPath = this.getClass().getClassLoader().getResource("testValidatorsImpl/").getPath(); String parentPath = rootPath + "TrimValidator/turtle_needtrim"; initParams.setRootUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath)); lsp.initialize(initParams); LanguageClient client = mock(LanguageClient.class); lsp.connect(client); DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams(); changeParams.setTextDocument(new VersionedTextDocumentIdentifier()); changeParams.getTextDocument() .setUri(RdfLintLanguageServer.convertFilePath2Uri(parentPath + "/needtrim.rdf")); List<TextDocumentContentChangeEvent> changeEvents = new LinkedList<>(); changeParams.setContentChanges(changeEvents); changeEvents.add(new TextDocumentContentChangeEvent()); changeEvents.get(0).setText("<rdf:RDF\n" + " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + " xmlns:schema=\"http://schema.org/\"\n" + " >\n" + "\n" + " <rdf:Description rdf:about=\"something\">\n" + " <schema:familyName xml:lang=\"ja\">familyName</schema:familyN>\n" + " </rdf:Description>\n" + "\n" + "</rdf:RDF>"); lsp.didChange(changeParams); verify(client, times(1)).publishDiagnostics(any()); }
Example 10
Source File: N4jscCompiler.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Starts the compiler in a blocking fashion */ public N4jscExitState start() throws Exception { InitializeParams params = new InitializeParams(); File baseDir = options.getDir(); if (baseDir == null) { throw new N4jscException(N4jscExitCode.ARGUMENT_DIRS_INVALID, "No base directory"); } params.setRootUri(baseDir.toURI().toString()); languageServer.initialize(params).get(); warnIfNoProjectsFound(); verbosePrintAllProjects(); switch (options.getGoal()) { case clean: performClean(); break; case compile: performCompile(); break; default: break; } languageServer.shutdown(); languageServer.exit(); writeTestCatalog(); return determineExitState(); }
Example 11
Source File: LSPBindings.java From netbeans with Apache License 2.0 | 5 votes |
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 12
Source File: DefaultLanguageServerWrapper.java From MSPaintIDE with MIT License | 4 votes |
@Override public InitializeParams getInitParams() { InitializeParams initParams = new InitializeParams(); if (this.rootPath != null) { var root = rootPath.toURI().toString(); if (this.useInputForWorkspace) { root = rootPath.toPath().relativize(inputFile.toPath()).toUri().toString(); } initParams.setRootUri(root); LOGGER.info("Workspace root is {}", root); } WorkspaceClientCapabilities workspaceClientCapabilities = new WorkspaceClientCapabilities(); workspaceClientCapabilities.setApplyEdit(true); workspaceClientCapabilities.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities()); workspaceClientCapabilities.setExecuteCommand(new ExecuteCommandCapabilities()); workspaceClientCapabilities.setWorkspaceEdit(new WorkspaceEditCapabilities()); // workspaceClientCapabilities.setSymbol(new SymbolCapabilities()); workspaceClientCapabilities.setWorkspaceFolders(true); workspaceClientCapabilities.setConfiguration(true); TextDocumentClientCapabilities textDocumentClientCapabilities = new TextDocumentClientCapabilities(); textDocumentClientCapabilities.setCodeAction(new CodeActionCapabilities()); textDocumentClientCapabilities.setCompletion(new CompletionCapabilities(new CompletionItemCapabilities(false))); textDocumentClientCapabilities.setDefinition(new DefinitionCapabilities()); // textDocumentClientCapabilities.setDocumentHighlight(new DocumentHighlightCapabilities()); textDocumentClientCapabilities.setFormatting(new FormattingCapabilities()); // textDocumentClientCapabilities.setHover(new HoverCapabilities()); // textDocumentClientCapabilities.setOnTypeFormatting(new OnTypeFormattingCapabilities()); // textDocumentClientCapabilities.setRangeFormatting(new RangeFormattingCapabilities()); textDocumentClientCapabilities.setReferences(new ReferencesCapabilities()); textDocumentClientCapabilities.setRename(new RenameCapabilities()); textDocumentClientCapabilities.setSemanticHighlightingCapabilities(new SemanticHighlightingCapabilities(false)); textDocumentClientCapabilities.setSignatureHelp(new SignatureHelpCapabilities()); textDocumentClientCapabilities.setSynchronization(new SynchronizationCapabilities(true, true, true)); initParams.setCapabilities( new ClientCapabilities(workspaceClientCapabilities, textDocumentClientCapabilities, null)); // initParams.setInitializationOptions(null); // initParams.setInitializationOptions( // serverDefinition.getInitializationOptions(URI.create(initParams.getRootUri()))); return initParams; }
Example 13
Source File: AbstractLanguageServerTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
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 14
Source File: InitializeParamsTypeAdapter.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
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; }