use of org.eclipse.lsp4j.SymbolInformation in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method documentSymbol.
/**
* Searches by name for a symbol in a specific document (not the whole
* workspace)
*/
@Override
public CompletableFuture<List<? extends SymbolInformation>> documentSymbol(DocumentSymbolParams params) {
TextDocumentIdentifier textDocument = params.getTextDocument();
Path path = LanguageServerUtils.getPathFromLanguageServerURI(textDocument.getUri());
if (path == null) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
ICompilationUnit unit = getCompilationUnit(path);
if (unit == null) {
//we couldn't find a compilation unit with the specified path
return CompletableFuture.completedFuture(Collections.emptyList());
}
IASScope[] scopes;
try {
scopes = unit.getFileScopeRequest().get().getScopes();
} catch (Exception e) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
List<SymbolInformation> result = new ArrayList<>();
for (IASScope scope : scopes) {
scopeToSymbols(scope, result);
}
return CompletableFuture.completedFuture(result);
}
use of org.eclipse.lsp4j.SymbolInformation in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method workspaceSymbol.
/**
* Searches by name for a symbol in the workspace.
*/
public CompletableFuture<List<? extends SymbolInformation>> workspaceSymbol(WorkspaceSymbolParams params) {
if (compilationUnits == null) {
//if we haven't successfully compiled the project, we can't do this
return CompletableFuture.completedFuture(Collections.emptyList());
}
List<SymbolInformation> result = new ArrayList<>();
String query = params.getQuery();
for (ICompilationUnit unit : compilationUnits) {
if (unit == null || unit instanceof SWCCompilationUnit) {
continue;
}
IASScope[] scopes;
try {
scopes = unit.getFileScopeRequest().get().getScopes();
} catch (Exception e) {
return CompletableFuture.completedFuture(Collections.emptyList());
}
for (IASScope scope : scopes) {
querySymbolsInScope(query, scope, result);
}
}
return CompletableFuture.completedFuture(result);
}
use of org.eclipse.lsp4j.SymbolInformation in project xtext-core by eclipse.
the class DocumentSymbolService method getSymbols.
public List<? extends SymbolInformation> getSymbols(final IResourceDescription resourceDescription, final String query, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) {
final LinkedList<SymbolInformation> symbols = CollectionLiterals.<SymbolInformation>newLinkedList();
Iterable<IEObjectDescription> _exportedObjects = resourceDescription.getExportedObjects();
for (final IEObjectDescription description : _exportedObjects) {
{
this.operationCanceledManager.checkCanceled(cancelIndicator);
boolean _filter = this.filter(description, query);
if (_filter) {
final Procedure1<SymbolInformation> _function = (SymbolInformation symbol) -> {
symbols.add(symbol);
};
this.createSymbol(description, resourceAccess, _function);
}
}
}
return symbols;
}
use of org.eclipse.lsp4j.SymbolInformation in project xtext-core by eclipse.
the class WorkspaceSymbolService method getSymbols.
public List<? extends SymbolInformation> getSymbols(final String query, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) {
final LinkedList<SymbolInformation> result = CollectionLiterals.<SymbolInformation>newLinkedList();
Iterable<IResourceDescription> _allResourceDescriptions = indexData.getAllResourceDescriptions();
for (final IResourceDescription resourceDescription : _allResourceDescriptions) {
{
this.operationCanceledManager.checkCanceled(cancelIndicator);
final IResourceServiceProvider resourceServiceProvider = this._registry.getResourceServiceProvider(resourceDescription.getURI());
DocumentSymbolService _get = null;
if (resourceServiceProvider != null) {
_get = resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
}
final DocumentSymbolService documentSymbolService = _get;
if ((documentSymbolService != null)) {
List<? extends SymbolInformation> _symbols = documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator);
Iterables.<SymbolInformation>addAll(result, _symbols);
}
}
}
return result;
}
use of org.eclipse.lsp4j.SymbolInformation in project eclipse.jdt.ls by eclipse.
the class DocumentSymbolHandlerTest method testClass.
private void testClass(String className) throws JavaModelException, UnsupportedEncodingException, InterruptedException, ExecutionException {
List<? extends SymbolInformation> symbols = getSymbols(className);
for (SymbolInformation symbol : symbols) {
Location loc = symbol.getLocation();
assertTrue("Class: " + className + ", Symbol:" + symbol.getName() + " - invalid location.", loc != null && isValid(loc.getRange()));
}
}
Aggregations