use of org.eclipse.lsp4j.SymbolKind in project eclipse.jdt.ls by eclipse.
the class WorkspaceSymbolHandler method search.
public List<SymbolInformation> search(String query, IProgressMonitor monitor) {
if (query == null || query.trim().isEmpty()) {
return Collections.emptyList();
}
try {
ArrayList<SymbolInformation> symbols = new ArrayList<>();
new SearchEngine().searchAllTypeNames(null, SearchPattern.R_PATTERN_MATCH, query.toCharArray(), SearchPattern.R_CAMELCASE_MATCH, IJavaSearchConstants.TYPE, createSearchScope(), new TypeNameMatchRequestor() {
@Override
public void acceptTypeNameMatch(TypeNameMatch match) {
SymbolInformation symbolInformation = new SymbolInformation();
symbolInformation.setContainerName(match.getTypeContainerName());
symbolInformation.setName(match.getSimpleTypeName());
symbolInformation.setKind(mapKind(match));
Location location;
try {
if (match.getType().isBinary()) {
location = JDTUtils.toLocation(match.getType().getClassFile());
} else {
location = JDTUtils.toLocation(match.getType());
}
} catch (Exception e) {
JavaLanguageServerPlugin.logException("Unable to determine location for " + match.getSimpleTypeName(), e);
return;
}
symbolInformation.setLocation(location);
symbols.add(symbolInformation);
}
private SymbolKind mapKind(TypeNameMatch match) {
int flags = match.getModifiers();
if (Flags.isInterface(flags)) {
return SymbolKind.Interface;
}
if (Flags.isAnnotation(flags)) {
return SymbolKind.Property;
}
if (Flags.isEnum(flags)) {
return SymbolKind.Enum;
}
return SymbolKind.Class;
}
}, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
return symbols;
} catch (Exception e) {
JavaLanguageServerPlugin.logException("Problem getting search for" + query, e);
}
return Collections.emptyList();
}
use of org.eclipse.lsp4j.SymbolKind in project xtext-core by eclipse.
the class DocumentSymbolService method createSymbol.
protected SymbolInformation createSymbol(final EObject object) {
final String name = this.getSymbolName(object);
if ((name == null)) {
return null;
}
final SymbolKind kind = this.getSymbolKind(object);
if ((kind == null)) {
return null;
}
final Location location = this.getSymbolLocation(object);
if ((location == null)) {
return null;
}
final SymbolInformation symbol = new SymbolInformation();
symbol.setName(name);
symbol.setKind(kind);
symbol.setLocation(location);
return symbol;
}
use of org.eclipse.lsp4j.SymbolKind in project xtext-core by eclipse.
the class DocumentSymbolService method createSymbol.
protected SymbolInformation createSymbol(final IEObjectDescription description) {
final String symbolName = this.getSymbolName(description);
if ((symbolName == null)) {
return null;
}
final SymbolKind symbolKind = this.getSymbolKind(description);
if ((symbolKind == null)) {
return null;
}
final SymbolInformation symbol = new SymbolInformation();
symbol.setName(symbolName);
symbol.setKind(symbolKind);
return symbol;
}
use of org.eclipse.lsp4j.SymbolKind in project xtext-core by eclipse.
the class DocumentSymbolService method createSymbol.
protected void createSymbol(final IEObjectDescription description, final IReferenceFinder.IResourceAccess resourceAccess, final Procedure1<? super SymbolInformation> acceptor) {
final String name = this.getSymbolName(description);
if ((name == null)) {
return;
}
final SymbolKind kind = this.getSymbolKind(description);
if ((kind == null)) {
return;
}
final Procedure1<Location> _function = (Location location) -> {
final SymbolInformation symbol = new SymbolInformation(name, kind, location);
acceptor.apply(symbol);
};
this.getSymbolLocation(description, resourceAccess, _function);
}
use of org.eclipse.lsp4j.SymbolKind in project ballerina by ballerina-lang.
the class SymbolFindingVisitor method visit.
public void visit(BLangVariable variableNode) {
SymbolKind kind;
String btype = variableNode.getTypeNode().toString();
switch(btype) {
case "boolean":
kind = SymbolKind.Boolean;
break;
case "int":
kind = SymbolKind.Number;
break;
case "float":
kind = SymbolKind.Number;
break;
default:
if (btype.endsWith("[]")) {
kind = SymbolKind.Array;
} else {
kind = SymbolKind.Variable;
}
}
this.addSymbol(variableNode, variableNode.symbol, kind);
}
Aggregations