Java Code Examples for org.eclipse.lsp4j.SymbolInformation#setKind()
The following examples show how to use
org.eclipse.lsp4j.SymbolInformation#setKind() .
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: 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 2
Source File: DocumentSymbolHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private void collectChildren(ITypeRoot unit, IJavaElement[] elements, ArrayList<SymbolInformation> symbols, IProgressMonitor monitor) throws JavaModelException { for (IJavaElement element : elements) { if (monitor.isCanceled()) { throw new OperationCanceledException(); } if (element instanceof IParent) { collectChildren(unit, filter(((IParent) element).getChildren()), symbols, monitor); } int type = element.getElementType(); if (type != IJavaElement.TYPE && type != IJavaElement.FIELD && type != IJavaElement.METHOD) { continue; } Location location = JDTUtils.toLocation(element); if (location != null) { SymbolInformation si = new SymbolInformation(); String name = JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT); si.setName(name == null ? element.getElementName() : name); si.setKind(mapKind(element)); if (element.getParent() != null) { si.setContainerName(element.getParent().getElementName()); } location.setUri(ResourceUtils.toClientUri(location.getUri())); si.setLocation(location); if (!symbols.contains(si)) { symbols.add(si); } } } }
Example 3
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.16 */ protected SymbolInformation createSymbol(String uri, DocumentSymbol symbol, Function1<? super DocumentSymbol, ? extends String> containerNameProvider) { SymbolInformation symbolInformation = new SymbolInformation(); symbolInformation.setName(symbol.getName()); symbolInformation.setKind(symbol.getKind()); symbolInformation.setDeprecated(symbol.getDeprecated()); Location location = new Location(); location.setUri(uri); location.setRange(symbol.getSelectionRange()); symbolInformation.setLocation(location); symbolInformation.setContainerName(containerNameProvider.apply(symbol)); return symbolInformation; }
Example 4
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 5
Source File: SymbolInformationTypeAdapter.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
public SymbolInformation read(final JsonReader in) throws IOException { JsonToken nextToken = in.peek(); if (nextToken == JsonToken.NULL) { return null; } SymbolInformation result = new SymbolInformation(); in.beginObject(); while (in.hasNext()) { String name = in.nextName(); switch (name) { case "name": result.setName(readName(in)); break; case "kind": result.setKind(readKind(in)); break; case "deprecated": result.setDeprecated(readDeprecated(in)); break; case "location": result.setLocation(readLocation(in)); break; case "containerName": result.setContainerName(readContainerName(in)); break; default: in.skipValue(); } } in.endObject(); return result; }
Example 6
Source File: WorkspaceFolderManager.java From vscode-as3mxml with Apache License 2.0 | 4 votes |
public SymbolInformation definitionToSymbolInformation(IDefinition definition, ILspProject project) { String definitionBaseName = definition.getBaseName(); if (definitionBaseName.length() == 0) { //vscode expects all items to have a name return null; } Location location = getLocationFromDefinition(definition, project); if (location == null) { //we can't find where the source code for this symbol is located return null; } SymbolInformation symbol = new SymbolInformation(); symbol.setKind(LanguageServerCompilerUtils.getSymbolKindFromDefinition(definition)); if (!definition.getQualifiedName().equals(definitionBaseName)) { symbol.setContainerName(definition.getPackageName()); } else if (definition instanceof ITypeDefinition) { symbol.setContainerName("No Package"); } else { IDefinition parentDefinition = definition.getParent(); if (parentDefinition != null) { symbol.setContainerName(parentDefinition.getQualifiedName()); } } symbol.setName(definitionBaseName); symbol.setLocation(location); IDeprecationInfo deprecationInfo = definition.getDeprecationInfo(); if (deprecationInfo != null) { symbol.setDeprecated(true); } return symbol; }