org.eclipse.lsp4j.SymbolKind Java Examples
The following examples show how to use
org.eclipse.lsp4j.SymbolKind.
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: LSPDefaultIconProvider.java From lsp4intellij with Apache License 2.0 | 6 votes |
public Icon getSymbolIcon(SymbolKind kind) { if (kind == null) { return null; } switch (kind) { case Field: case EnumMember: return Nodes.Field; case Method: return Nodes.Method; case Variable: return Nodes.Variable; case Class: return Nodes.Class; case Constructor: return Nodes.ClassInitializer; case Enum: return Nodes.Enum; default: return Nodes.Tag; } }
Example #2
Source File: N4JSDocumentSymbolMapper.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public DocumentSymbol toDocumentSymbol(EObject object) { SymbolKind symbolKind = kindCalculationHelper.getSymbolKind(object); if (symbolKind == null) { return null; } DocumentSymbol documentSymbol = super.toDocumentSymbol(object); documentSymbol.setKind(symbolKind); String symbolLabel = labelHelper.getSymbolLabel(object); if (symbolLabel != null) { documentSymbol.setName(symbolLabel); } return documentSymbol; }
Example #3
Source File: SyntaxServerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testDocumentSymbol() throws Exception { when(preferenceManager.getClientPreferences().isHierarchicalDocumentSymbolSupported()).thenReturn(Boolean.TRUE); URI fileURI = openFile("maven/salut4", "src/main/java/java/Foo.java"); TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileURI.toString()); DocumentSymbolParams params = new DocumentSymbolParams(identifier); List<Either<SymbolInformation, DocumentSymbol>> result = server.documentSymbol(params).join(); assertNotNull(result); assertEquals(2, result.size()); Either<SymbolInformation, DocumentSymbol> symbol = result.get(0); assertTrue(symbol.isRight()); assertEquals("java", symbol.getRight().getName()); assertEquals(SymbolKind.Package, symbol.getRight().getKind()); symbol = result.get(1); assertTrue(symbol.isRight()); assertEquals("Foo", symbol.getRight().getName()); assertEquals(SymbolKind.Class, symbol.getRight().getKind()); List<DocumentSymbol> children = symbol.getRight().getChildren(); assertNotNull(children); assertEquals(1, children.size()); assertEquals("main(String[])", children.get(0).getName()); assertEquals(SymbolKind.Method, children.get(0).getKind()); }
Example #4
Source File: CallHierarchyHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
/** * @param item * to assert * @param name * the expected name * @param kind * the expected kind * @param detail * the expected detail * @param deprecated * expected deprecated state * @param selectionStartLine * the start line of the selection range * @return the {@code item} */ static CallHierarchyItem assertItem(CallHierarchyItem item, String name, SymbolKind kind, String detail, boolean deprecated, int selectionStartLine) { assertNotNull(item); assertEquals(name, item.getName()); assertEquals(kind, item.getKind()); assertEquals(detail, item.getDetail()); if (deprecated) { assertNotNull(item.getTags()); assertTrue(item.getTags().stream().anyMatch(tag -> tag == SymbolTag.Deprecated)); } else { assertTrue(item.getTags() == null || item.getTags().isEmpty() || !item.getTags().stream().anyMatch(tag -> tag == SymbolTag.Deprecated)); } assertEquals(selectionStartLine, item.getSelectionRange().getStart().getLine()); return item; }
Example #5
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void externalDTD() { String xmlText = "<!ELEMENT br EMPTY>\n" + // "<!ATTLIST br\n" + // " %all;>"; String testURI = "test.dtd"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 19, xmlDocument); currentSymbolInfo = createSymbolInformation("br", SymbolKind.Property, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 34, 39, xmlDocument); currentSymbolInfo = createSymbolInformation("%all;", SymbolKind.Key, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #6
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void testAllTagsUnclosed() { String xmlText = "<a><b>"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 6, xmlDocument); currentSymbolInfo = createSymbolInformation("a", SymbolKind.Field, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 3, 6, xmlDocument); currentSymbolInfo = createSymbolInformation("b", SymbolKind.Field, currentLocation, "a"); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #7
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedUnclosedTag() { String xmlText = "<a><b></a>"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 10, xmlDocument); currentSymbolInfo = createSymbolInformation("a", SymbolKind.Field, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 3, 6, xmlDocument); currentSymbolInfo = createSymbolInformation("b", SymbolKind.Field, currentLocation, "a"); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #8
Source File: DocumentSymbolHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
@Test public void testTypes() throws Exception { String className = "org.sample.Bar"; List<? extends SymbolInformation> symbols = getSymbols(className); assertHasSymbol("Bar", "Bar.java", SymbolKind.Class, symbols); assertHasSymbol("main(String[])", "Bar", SymbolKind.Method, symbols); assertHasSymbol("MyInterface", "Bar", SymbolKind.Interface, symbols); assertHasSymbol("foo()", "MyInterface", SymbolKind.Method, symbols); assertHasSymbol("MyClass", "Bar", SymbolKind.Class, symbols); assertHasSymbol("bar()", "MyClass", SymbolKind.Method, symbols); assertHasSymbol("Foo", "Bar", SymbolKind.Enum, symbols); assertHasSymbol("Bar", "Foo", SymbolKind.EnumMember, symbols); assertHasSymbol("Zoo", "Foo", SymbolKind.EnumMember, symbols); assertHasSymbol("EMPTY", "Bar", SymbolKind.Constant, symbols); }
Example #9
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedSelfClosingTag() { String xmlText = "<a><b/></a>"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 11, xmlDocument); currentSymbolInfo = createSymbolInformation("a", SymbolKind.Field, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 3, 7, xmlDocument); currentSymbolInfo = createSymbolInformation("b", SymbolKind.Field, currentLocation, "a"); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #10
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedTwice() { String xmlText = "<a><b><c></c></b></a>"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 21, xmlDocument); currentSymbolInfo = createSymbolInformation("a", SymbolKind.Field, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 3, 17, xmlDocument); currentSymbolInfo = createSymbolInformation("b", SymbolKind.Field, currentLocation, "a"); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 6, 13, xmlDocument); currentSymbolInfo = createSymbolInformation("c", SymbolKind.Field, currentLocation, "b"); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #11
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void testTwoNestedSymbols() { String xmlText = "<a><b></b><c></c></a>"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 21, xmlDocument); currentSymbolInfo = createSymbolInformation("a", SymbolKind.Field, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 3, 10, xmlDocument); currentSymbolInfo = createSymbolInformation("b", SymbolKind.Field, currentLocation, "a"); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 10, 17, xmlDocument); currentSymbolInfo = createSymbolInformation("c", SymbolKind.Field, currentLocation, "a"); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #12
Source File: XMLSymbolInformationsTest.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Test public void testNestedSymbol() { String xmlText = "<project><inside></inside></project>"; initializeTestObjects(xmlText, testURI); List<SymbolInformation> expectedSymbolInfos = new ArrayList<SymbolInformation>(); currentLocation = createLocation(testURI, 0, 36, xmlDocument); currentSymbolInfo = createSymbolInformation("project", SymbolKind.Field, currentLocation, ""); expectedSymbolInfos.add(currentSymbolInfo); currentLocation = createLocation(testURI, 9, 26, xmlDocument); currentSymbolInfo = createSymbolInformation("inside", SymbolKind.Field, currentLocation, "project"); expectedSymbolInfos.add(currentSymbolInfo); assertSymbols(expectedSymbolInfos, actualSymbolInfos); }
Example #13
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected SymbolInformation createSymbol(EObject object) { String name = getSymbolName(object); if (name == null) { return null; } SymbolKind kind = getSymbolKind(object); if (kind == null) { return null; } Location location = getSymbolLocation(object); if (location == null) { return null; } SymbolInformation symbol = new SymbolInformation(); symbol.setName(name); symbol.setKind(kind); symbol.setLocation(location); return symbol; }
Example #14
Source File: DocumentSymbolMapper.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
/** * Converts the {@code EObject} argument into a {@link DocumentSymbol document symbol} without the * {@link DocumentSymbol#children children} information filled in. */ public DocumentSymbol toDocumentSymbol(EObject object) { DocumentSymbol documentSymbol = new DocumentSymbol(); String objectName = nameProvider.getName(object); if (objectName != null) { documentSymbol.setName(objectName); } SymbolKind objectKind = kindProvider.getSymbolKind(object); if (objectKind != null) { documentSymbol.setKind(objectKind); } Range objectRange = rangeProvider.getRange(object); if (objectRange != null) { documentSymbol.setRange(objectRange); } Range objectSelectionRange = rangeProvider.getSelectionRange(object); if (objectSelectionRange != null) { documentSymbol.setSelectionRange(objectSelectionRange); } documentSymbol.setDetail(detailsProvider.getDetails(object)); documentSymbol.setDeprecated(deprecationInfoProvider.isDeprecated(object)); documentSymbol.setChildren(new ArrayList<>()); return documentSymbol; }
Example #15
Source File: XMLSymbolsProvider.java From lemminx with Eclipse Public License 2.0 | 6 votes |
private static SymbolKind getSymbolKind(DOMNode node) { if (node.isProcessingInstruction() || node.isProlog()) { return SymbolKind.Property; } else if (node.isDoctype()) { return SymbolKind.Struct; } else if (node.isDTDElementDecl()) { return SymbolKind.Property; } else if (node.isDTDEntityDecl()) { return SymbolKind.Namespace; } else if (node.isDTDAttListDecl()) { return SymbolKind.Key; } else if (node.isDTDNotationDecl()) { return SymbolKind.Variable; } return SymbolKind.Field; }
Example #16
Source File: GroovyLanguageServerUtils.java From groovy-language-server with Apache License 2.0 | 6 votes |
public static SymbolKind astNodeToSymbolKind(ASTNode node) { if (node instanceof ClassNode) { ClassNode classNode = (ClassNode) node; if (classNode.isInterface()) { return SymbolKind.Interface; } else if (classNode.isEnum()) { return SymbolKind.Enum; } return SymbolKind.Class; } else if (node instanceof MethodNode) { return SymbolKind.Method; } else if (node instanceof Variable) { if (node instanceof FieldNode || node instanceof PropertyNode) { return SymbolKind.Field; } return SymbolKind.Variable; } return SymbolKind.Property; }
Example #17
Source File: XMLDocumentSymbolsTest.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Test public void internalDTD() { String xml = "<?xml version = \"1.0\"?>\r\n" + // "<!DOCTYPE Folks [\r\n" + // " <!ELEMENT Folks (Person*)>\r\n" + // " <!ELEMENT Person (Name,Email?)>\r\n" + // " <!ATTLIST Person Pin ID #REQUIRED>\r\n" + // " <!ATTLIST Person Friend IDREF #IMPLIED>\r\n" + // " <!ATTLIST Person Likes IDREFS #IMPLIED>\r\n" + // " <!ELEMENT Name (#PCDATA)>\r\n" + // " <!ELEMENT Email (#PCDATA)>\r\n" + // " ]>\r\n" + // "<Folks>\r\n" + // " \r\n" + // "</Folks>"; XMLAssert.testDocumentSymbolsFor(xml, "test.xml", // ds("xml", SymbolKind.Property, r(0, 0, 0, 23), r(0, 0, 0, 23), null, // Collections.emptyList()), // ds("DOCTYPE:Folks", SymbolKind.Struct, r(1, 0, 9, 3), r(1, 0, 9, 3), null, Arrays.asList( ds("Folks", SymbolKind.Property, r(2, 1, 2, 27), r(2, 1, 2, 27), null, Collections.emptyList()), // ds("Person", SymbolKind.Property, r(3, 1, 3, 32), r(3, 1, 3, 32), null, // Arrays.asList( // ds("Pin", SymbolKind.Key, r(4, 18, 4, 21), r(4, 18, 4, 21), null, Collections.emptyList()), // ds("Friend", SymbolKind.Key, r(5, 18, 5, 24), r(5, 18, 5, 24), null, Collections.emptyList()), // ds("Likes", SymbolKind.Key, r(6, 18, 6, 23), r(6, 18, 6, 23), null, Collections.emptyList()))), // ds("Name", SymbolKind.Property, r(7, 1, 7, 26), r(7, 1, 7, 26), null, Collections.emptyList()), // ds("Email", SymbolKind.Property, r(8, 1, 8, 27), r(8, 1, 8, 27), null, Collections.emptyList()) // )), // ds("Folks", SymbolKind.Field, r(10, 0, 12, 8), r(10, 0, 12, 8), null, Collections.emptyList())); }
Example #18
Source File: JSONDocumentSymbolKindProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public SymbolKind getSymbolKind(EObject object) { if (object instanceof NameValuePair) { JSONValue value = ((NameValuePair) object).getValue(); if (value != null && !(value instanceof JSONStringLiteral)) { return getSymbolKind(value); } } return super.getSymbolKind(object); }
Example #19
Source File: XMLDocumentSymbolsTest.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Test public void exceedSymbolLimit() { String xml = "<?xml version = \"1.0\"?>\r\n" + // "<!DOCTYPE Folks [\r\n" + // " <!ELEMENT Folks (Person*)>\r\n" + // " <!ELEMENT Person (Name,Email?)>\r\n" + // " <!ATTLIST Person Pin ID #REQUIRED>\r\n" + // " <!ATTLIST Person Friend IDREF #IMPLIED>\r\n" + // " <!ATTLIST Person Likes IDREFS #IMPLIED>\r\n" + // " <!ELEMENT Name (#PCDATA)>\r\n" + // " <!ELEMENT Email (#PCDATA)>\r\n" + // " ]>\r\n" + // "<Folks>\r\n" + // " \r\n" + // "</Folks>"; DocumentSymbol symbol1 = ds("xml", SymbolKind.Property, r(0, 0, 0, 23), r(0, 0, 0, 23), null, // Collections.emptyList()); DocumentSymbol symbol2 = ds("DOCTYPE:Folks", SymbolKind.Struct, r(1, 0, 9, 3), r(1, 0, 9, 3), null, Arrays.asList( ds("Folks", SymbolKind.Property, r(2, 1, 2, 27), r(2, 1, 2, 27), null, Collections.emptyList()), // ds("Person", SymbolKind.Property, r(3, 1, 3, 32), r(3, 1, 3, 32), null, // Arrays.asList( // ds("Pin", SymbolKind.Key, r(4, 18, 4, 21), r(4, 18, 4, 21), null, Collections.emptyList()), // ds("Friend", SymbolKind.Key, r(5, 18, 5, 24), r(5, 18, 5, 24), null, Collections.emptyList()), // ds("Likes", SymbolKind.Key, r(6, 18, 6, 23), r(6, 18, 6, 23), null, Collections.emptyList()))), // ds("Name", SymbolKind.Property, r(7, 1, 7, 26), r(7, 1, 7, 26), null, Collections.emptyList()), // ds("Email", SymbolKind.Property, r(8, 1, 8, 27), r(8, 1, 8, 27), null, Collections.emptyList()))); DocumentSymbol symbol3 = ds("Folks", SymbolKind.Field, r(10, 0, 12, 8), r(10, 0, 12, 8), null, Collections.emptyList()); XMLSymbolSettings settings = new XMLSymbolSettings(); settings.setMaxItemsComputed(10); XMLAssert.testDocumentSymbolsFor(xml, "test.xml", settings, symbol1, symbol2, symbol3); settings.setMaxItemsComputed(15); XMLAssert.testDocumentSymbolsFor(xml, "test.xml", settings, symbol1, symbol2, symbol3); settings.setMaxItemsComputed(9); XMLAssert.testDocumentSymbolsFor(xml, "test.xml", settings, symbol1, symbol2); }
Example #20
Source File: JSONDocumentSymbolKindProvider.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected SymbolKind getSymbolKind(EClass clazz) { if (clazz.getEPackage() == JSONPackage.eINSTANCE) { switch (clazz.getClassifierID()) { case JSONPackage.JSON_DOCUMENT: { return SymbolKind.File; } case JSONPackage.JSON_OBJECT: { return SymbolKind.Object; } case JSONPackage.JSON_ARRAY: { return SymbolKind.Array; } case JSONPackage.NAME_VALUE_PAIR: { return SymbolKind.Field; } case JSONPackage.JSON_STRING_LITERAL: { // The outline does not look like something super exciting with this symbol // kind, but its likely the best choice here return SymbolKind.String; } case JSONPackage.JSON_NUMERIC_LITERAL: { return SymbolKind.Number; } case JSONPackage.JSON_BOOLEAN_LITERAL: { return SymbolKind.Boolean; } case JSONPackage.JSON_NULL_LITERAL: { return SymbolKind.Null; } } } throw new UnsupportedOperationException("Not supported for " + clazz.getName()); }
Example #21
Source File: TextDocumentServiceImpl.java From netbeans with Apache License 2.0 | 5 votes |
private static SymbolKind elementKind2SymbolKind(ElementKind kind) { switch (kind) { case PACKAGE: return SymbolKind.Package; case ENUM: return SymbolKind.Enum; case CLASS: return SymbolKind.Class; case ANNOTATION_TYPE: return SymbolKind.Interface; case INTERFACE: return SymbolKind.Interface; case ENUM_CONSTANT: return SymbolKind.EnumMember; case FIELD: return SymbolKind.Field; //TODO: constant case PARAMETER: return SymbolKind.Variable; case LOCAL_VARIABLE: return SymbolKind.Variable; case EXCEPTION_PARAMETER: return SymbolKind.Variable; case METHOD: return SymbolKind.Method; case CONSTRUCTOR: return SymbolKind.Constructor; case TYPE_PARAMETER: return SymbolKind.TypeParameter; case RESOURCE_VARIABLE: return SymbolKind.Variable; case MODULE: return SymbolKind.Module; case STATIC_INIT: case INSTANCE_INIT: case OTHER: default: return SymbolKind.File; //XXX: what here? } }
Example #22
Source File: DocumentSymbolHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testTypes_hierarchical() throws Exception { String className = "org.sample.Bar"; List<? extends DocumentSymbol> symbols = getHierarchicalSymbols(className); assertHasHierarchicalSymbol("main(String[]) : void", "Bar", SymbolKind.Method, symbols); assertHasHierarchicalSymbol("MyInterface", "Bar", SymbolKind.Interface, symbols); assertHasHierarchicalSymbol("foo() : void", "MyInterface", SymbolKind.Method, symbols); assertHasHierarchicalSymbol("MyClass", "Bar", SymbolKind.Class, symbols); assertHasHierarchicalSymbol("bar() : void", "MyClass", SymbolKind.Method, symbols); }
Example #23
Source File: Icons.java From netbeans with Apache License 2.0 | 5 votes |
public static String getSymbolIconBase(SymbolKind symbolKind) { if (symbolKind == null) { return ICON_BASE + "empty.png"; } for (String variant : new String[] { ICON_BASE + symbolKind.name().toLowerCase(Locale.US) + PNG_EXTENSION, ICON_BASE + symbolKind.name().toLowerCase(Locale.US) + GIF_EXTENSION, ICON_BASE + "variable" + GIF_EXTENSION }) { if (ImageUtilities.loadImage(variant) != null) return variant; } return null; }
Example #24
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 #25
Source File: WorkspaceSymbolHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testProjectSearch() { String query = "IFoo"; List<SymbolInformation> results = handler.search(query, monitor); assertNotNull(results); assertEquals("Found " + results.size() + " results", 2, results.size()); SymbolInformation symbol = results.get(0); assertEquals(SymbolKind.Interface, symbol.getKind()); assertEquals("java", symbol.getContainerName()); assertEquals(query, symbol.getName()); Location location = symbol.getLocation(); assertNotEquals("Range should not equal the default range", JDTUtils.newRange(), location.getRange()); assertTrue("Unexpected uri "+ location.getUri(), location.getUri().endsWith("Foo.java")); }
Example #26
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected SymbolInformation createSymbol(IEObjectDescription description) { String symbolName = getSymbolName(description); if (symbolName == null) { return null; } SymbolKind symbolKind = getSymbolKind(description); if (symbolKind == null) { return null; } SymbolInformation symbol = new SymbolInformation(); symbol.setName(symbolName); symbol.setKind(symbolKind); return symbol; }
Example #27
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void createSymbol(IEObjectDescription description, IReferenceFinder.IResourceAccess resourceAccess, Procedure1<? super SymbolInformation> acceptor) { String name = getSymbolName(description); if (name == null) { return; } SymbolKind kind = getSymbolKind(description); if (kind == null) { return; } getSymbolLocation(description, resourceAccess, (Location location) -> { SymbolInformation symbol = new SymbolInformation(name, kind, location); acceptor.apply(symbol); }); }
Example #28
Source File: DocumentSymbolHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void assertHasHierarchicalSymbol(String expectedType, String expectedParent, SymbolKind expectedKind, Collection<? extends DocumentSymbol> symbols) { Optional<? extends DocumentSymbol> parent = asStream(symbols).filter(s -> expectedParent.equals(s.getName() + s.getDetail())).findFirst(); assertTrue("Cannot find parent with name: " + expectedParent, parent.isPresent()); Optional<? extends DocumentSymbol> symbol = asStream(symbols) .filter(s -> expectedType.equals(s.getName() + s.getDetail()) && parent.get().getChildren().contains(s)) .findFirst(); assertTrue(expectedType + " (" + expectedParent + ")" + " is missing from " + symbols, symbol.isPresent()); assertKind(expectedKind, symbol.get()); }
Example #29
Source File: DocumentSymbolHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Test public void testSyntheticMember_hierarchical_noSourceAttached() throws Exception { String className = "foo.bar"; List<? extends DocumentSymbol> symbols = asStream(internalGetHierarchicalSymbols(noSourceProject, monitor, className)).collect(Collectors.toList()); assertHasHierarchicalSymbol("bar()", "bar", SymbolKind.Constructor, symbols); assertHasHierarchicalSymbol("add(int...) : int", "bar", SymbolKind.Method, symbols); }
Example #30
Source File: DocumentSymbolHandlerTest.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void assertHasSymbol(String expectedType, String expectedParent, SymbolKind expectedKind, Collection<? extends SymbolInformation> symbols) { Optional<? extends SymbolInformation> symbol = symbols.stream() .filter(s -> expectedType.equals(s.getName()) && expectedParent.equals(s.getContainerName())) .findFirst(); assertTrue(expectedType + " (" + expectedParent + ")" + " is missing from " + symbols, symbol.isPresent()); assertKind(expectedKind, symbol.get()); }