use of org.lxtk.lx4e.requests.DocumentSymbolRequest in project lxtk by lxtk-org.
the class LanguageSourceFile method getDocumentSymbols.
private List<DocumentSymbol> getDocumentSymbols(DocumentSymbolProvider provider, URI documentUri, IProgressMonitor monitor) throws CoreException {
DocumentSymbolRequest request = newDocumentSymbolRequest();
request.setProvider(provider);
request.setParams(new DocumentSymbolParams(DocumentUri.toTextDocumentIdentifier(documentUri)));
request.setTimeout(getDocumentSymbolTimeout());
request.setProgressMonitor(monitor);
request.setUpWorkDoneProgress(() -> new DefaultWorkDoneProgress(Either.forLeft(UUID.randomUUID().toString())));
List<Either<SymbolInformation, DocumentSymbol>> result;
try {
result = request.sendAndReceive();
} catch (CompletionException e) {
throw new CoreException(Activator.createErrorStatus(request.getErrorMessage(), e.getCause()));
}
if (result == null || result.isEmpty() || result.get(0).isLeft())
return Collections.emptyList();
List<DocumentSymbol> symbols = new ArrayList<>(result.size());
for (Either<SymbolInformation, DocumentSymbol> item : result) {
if (item.isRight())
symbols.add(item.getRight());
}
return symbols;
}
Aggregations