use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class GotoSymbolDialog method getTarget.
/**
* Determine the 'target' for the dialog's action.
*/
private SymbolInformation getTarget(TreeViewer list) {
ISelection sel = list.getSelection();
if (sel instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) sel;
Object selected = ss.getFirstElement();
if (selected instanceof Match) {
selected = ((Match<?>) selected).value;
if (selected instanceof SymbolInformation) {
return (SymbolInformation) selected;
}
}
}
// This allows user to execute the action without explicitly selecting an element.
return getFirstElement(list);
}
use of org.eclipse.lsp4j.SymbolInformation in project sts4 by spring-projects.
the class InWorkspaceSymbolsProvider method fetchFor.
@Override
public Collection<SymbolInformation> fetchFor(String query) throws Exception {
// TODO: if we want decent support for multiple language servers...
// consider changing SymbolsProvider api and turning the stuff in here into something producing a
// Flux<Collection<SymbolInformation>>
// This will help in
// - supporting cancelation
// - executing multiple requests to different servers in parallel.
// - producing results per server so don't have to wait for one slow server to see the rest.
// However it will also add complexity to the code that consumes this and at this time we only
// really use this with a single language server anyways.
WorkspaceSymbolParams params = new WorkspaceSymbolParams(query);
Flux<SymbolInformation> symbols = Flux.fromIterable(this.languageServers).flatMap(server -> Mono.fromFuture(server.getWorkspaceService().symbol(params)).timeout(TIMEOUT).doOnError(e -> log(e)).onErrorReturn(ImmutableList.of()).flatMapMany(Flux::fromIterable));
// Consider letting the Flux go out from here instead of blocking and collecting elements.
return symbols.take(MAX_RESULTS).collect(Collectors.toList()).block();
}
use of org.eclipse.lsp4j.SymbolInformation in project freemarker-languageserver by angelozerr.
the class FMLanguageService method provideFileSymbolsInternal.
private void provideFileSymbolsInternal(TextDocumentItem document, Node node, String container, List<SymbolInformation> symbols) {
String name = nodeToName(node);
Position start = null;
Position end = null;
Range range = new Range(start, end);
Location location = new Location(document.getUri(), range);
//
// Location.create(document.getUri(),
// Range.create(document.positionAt(node.start), document.positionAt(node.end)));
SymbolInformation symbol = new SymbolInformation(name, SymbolKind.Field, location, container);
symbols.add(symbol);
node.children.forEach(child -> {
provideFileSymbolsInternal(document, child, name, symbols);
});
}
use of org.eclipse.lsp4j.SymbolInformation in project eclipse.jdt.ls by eclipse.
the class MoveHandler method resolveTargetTypeName.
private static String resolveTargetTypeName(Object destinationObj) throws IllegalArgumentException {
if (destinationObj instanceof String) {
return (String) destinationObj;
}
String json = (destinationObj == null ? null : new Gson().toJson(destinationObj));
SymbolInformation destination = JSONUtility.toLsp4jModel(json, SymbolInformation.class);
if (destination == null) {
throw new IllegalArgumentException("Invalid destination object: " + destinationObj);
}
String typeName = destination.getName();
if (StringUtils.isNotBlank(destination.getContainerName())) {
typeName = destination.getContainerName() + "." + destination.getName();
}
return typeName;
}
use of org.eclipse.lsp4j.SymbolInformation in project eclipse.jdt.ls by eclipse.
the class DocumentSymbolHandler method collectChildren.
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 (JDTUtils.isDeprecated(element)) {
if (preferenceManager.getClientPreferences().isSymbolTagSupported()) {
si.setTags(List.of(SymbolTag.Deprecated));
} else {
si.setDeprecated(true);
}
}
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);
}
}
}
}
Aggregations