org.eclipse.lsp4j.DocumentSymbolCapabilities Java Examples
The following examples show how to use
org.eclipse.lsp4j.DocumentSymbolCapabilities.
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: XMLCapabilitiesTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
private void setAllCapabilities(boolean areAllDynamic) { textDocument.setRangeFormatting(new RangeFormattingCapabilities(areAllDynamic)); textDocument.setFormatting(new FormattingCapabilities(areAllDynamic)); CompletionCapabilities completion = new CompletionCapabilities(); completion.setDynamicRegistration(areAllDynamic); textDocument.setCompletion(completion); textDocument.setDocumentSymbol(new DocumentSymbolCapabilities(areAllDynamic)); textDocument.setHover(new HoverCapabilities(areAllDynamic)); textDocument.setDocumentHighlight(new DocumentHighlightCapabilities(areAllDynamic)); textDocument.setRename(new RenameCapabilities(areAllDynamic)); FoldingRangeCapabilities folding = new FoldingRangeCapabilities(); folding.setDynamicRegistration(areAllDynamic); textDocument.setFoldingRange(folding); textDocument.setDocumentLink(new DocumentLinkCapabilities(areAllDynamic)); textDocument.setCodeAction(new CodeActionCapabilities(areAllDynamic)); workspace.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities(areAllDynamic)); }
Example #2
Source File: XLanguageServerImpl.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * {@code true} if the {@code TextDocumentClientCapabilities} explicitly declares the hierarchical document symbol * support at LS initialization time. Otherwise, false. */ protected boolean isHierarchicalDocumentSymbolSupport() { ClientCapabilities capabilities = initializeParams.getCapabilities(); if (capabilities != null) { TextDocumentClientCapabilities textDocument = capabilities.getTextDocument(); if (textDocument != null) { DocumentSymbolCapabilities documentSymbol = textDocument.getDocumentSymbol(); if (documentSymbol != null) { Boolean hierarchicalDocumentSymbolSupport = documentSymbol.getHierarchicalDocumentSymbolSupport(); if (hierarchicalDocumentSymbolSupport != null) { return hierarchicalDocumentSymbolSupport; } } } } return false; }
Example #3
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
/** * {@code true} if the {@code TextDocumentClientCapabilities} explicitly declares the hierarchical document symbol * support at LS initialization time. Otherwise, false. */ protected boolean isHierarchicalDocumentSymbolSupport() { ClientCapabilities capabilities = initializeParams.getCapabilities(); if (capabilities == null) { return false; } TextDocumentClientCapabilities textDocument = capabilities.getTextDocument(); if (textDocument == null) { return false; } DocumentSymbolCapabilities documentSymbol = textDocument.getDocumentSymbol(); if (documentSymbol == null) { return false; } Boolean hierarchicalDocumentSymbolSupport = documentSymbol.getHierarchicalDocumentSymbolSupport(); if (hierarchicalDocumentSymbolSupport == null) { return false; } return hierarchicalDocumentSymbolSupport; }
Example #4
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 #5
Source File: ClientPreferencesTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testIsHierarchicalDocumentSymbolSupported() throws Exception { DocumentSymbolCapabilities capabilities = new DocumentSymbolCapabilities(); assertFalse(prefs.isHierarchicalDocumentSymbolSupported()); when(text.getDocumentSymbol()).thenReturn(capabilities); assertFalse(prefs.isHierarchicalDocumentSymbolSupported()); capabilities.setHierarchicalDocumentSymbolSupport(false); when(text.getDocumentSymbol()).thenReturn(capabilities); assertFalse(prefs.isHierarchicalDocumentSymbolSupported()); capabilities.setHierarchicalDocumentSymbolSupport(true); when(text.getDocumentSymbol()).thenReturn(capabilities); assertTrue(prefs.isHierarchicalDocumentSymbolSupported()); }
Example #6
Source File: XMLCapabilitiesTest.java From lemminx with Eclipse Public License 2.0 | 4 votes |
@Test public void testBothCapabilityTypes() { // Dynamic capabilities textDocument.setRangeFormatting(new RangeFormattingCapabilities(true)); textDocument.setFormatting(new FormattingCapabilities(true)); CompletionCapabilities completion = new CompletionCapabilities(); completion.setDynamicRegistration(true); textDocument.setCompletion(completion); textDocument.setDocumentSymbol(new DocumentSymbolCapabilities(true)); workspace.setDidChangeWatchedFiles(new DidChangeWatchedFilesCapabilities(true)); // Non dynamic capabilities textDocument.setHover(new HoverCapabilities(false)); textDocument.setDocumentHighlight(new DocumentHighlightCapabilities(false)); textDocument.setRename(new RenameCapabilities(false)); FoldingRangeCapabilities folding = new FoldingRangeCapabilities(); folding.setDynamicRegistration(false); textDocument.setFoldingRange(folding); textDocument.setDocumentLink(new DocumentLinkCapabilities(false)); textDocument.setCodeAction(new CodeActionCapabilities(false)); setAndInitializeCapabilities(); assertEquals(5, capabilityIDs.size()); assertEquals(true, capabilityIDs.contains(FORMATTING_ID)); assertEquals(true, capabilityIDs.contains(FORMATTING_RANGE_ID)); assertEquals(true, capabilityIDs.contains(COMPLETION_ID)); assertEquals(true, capabilityIDs.contains(DOCUMENT_SYMBOL_ID)); ServerCapabilities serverCapabilities = ServerCapabilitiesInitializer .getNonDynamicServerCapabilities(manager.getClientCapabilities(), false); assertEquals(false, serverCapabilities.getDocumentRangeFormattingProvider()); assertEquals(false, serverCapabilities.getDocumentFormattingProvider()); assertEquals(false, serverCapabilities.getDocumentSymbolProvider()); assertEquals(true, serverCapabilities.getHoverProvider()); assertEquals(true, serverCapabilities.getDocumentHighlightProvider()); assertEquals(true, serverCapabilities.getRenameProvider().getLeft()); assertEquals(true, serverCapabilities.getFoldingRangeProvider().getLeft()); assertEquals(true, serverCapabilities.getCodeActionProvider().getLeft()); assertEquals(null, serverCapabilities.getCompletionProvider()); assertEquals(DEFAULT_LINK_OPTIONS, serverCapabilities.getDocumentLinkProvider()); }
Example #7
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 #8
Source File: TextDocumentClientCapabilities.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
/** * Capabilities specific to the `textDocument/documentSymbol` */ @Pure public DocumentSymbolCapabilities getDocumentSymbol() { return this.documentSymbol; }
Example #9
Source File: TextDocumentClientCapabilities.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
/** * Capabilities specific to the `textDocument/documentSymbol` */ public void setDocumentSymbol(final DocumentSymbolCapabilities documentSymbol) { this.documentSymbol = documentSymbol; }