use of org.lxtk.DefaultWorkDoneProgress 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;
}
use of org.lxtk.DefaultWorkDoneProgress in project lxtk by lxtk-org.
the class RenameRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
RenameProvider[] renameProviders = getRenameProviders();
if (renameProviders.length == 0)
return RefactoringStatus.createFatalErrorStatus(Messages.RenameRefactoring_No_rename_provider);
RefactoringStatus status = checkNewName();
if (status.hasFatalError())
return status;
WorkspaceEdit workspaceEdit = null;
int i = 0;
if (prepareRenameProvider != null)
while (i < renameProviders.length && renameProviders[i] != prepareRenameProvider) i++;
SubMonitor subMonitor = SubMonitor.convert(pm, renameProviders.length - i);
while (i < renameProviders.length) {
RenameProvider renameProvider = renameProviders[i++];
RenameRequest request = newRenameRequest();
request.setProvider(renameProvider);
request.setParams(new RenameParams(DocumentUri.toTextDocumentIdentifier(target.getDocumentUri()), getPosition(), getNewName()));
request.setProgressMonitor(subMonitor.split(1));
request.setUpWorkDoneProgress(() -> new DefaultWorkDoneProgress(Either.forLeft(UUID.randomUUID().toString())));
try {
workspaceEdit = request.sendAndReceive();
} catch (CompletionException e) {
status.merge(handleError(e.getCause(), request.getErrorMessage()));
}
if (workspaceEdit != null) {
setWorkspaceEdit(workspaceEdit);
return super.checkFinalConditions(null);
}
}
// no workspace edit
if (!status.hasFatalError())
status.addFatalError(Messages.RenameRefactoring_No_workspace_edit);
return status;
}
use of org.lxtk.DefaultWorkDoneProgress in project lxtk by lxtk-org.
the class CallHierarchyUtility method getIncomingCalls.
/**
* Returns the incoming calls for the given call hierarchy item.
*
* @param item not <code>null</code>
* @param monitor a progress monitor, or <code>null</code>
* if progress reporting is not desired. The caller must not rely on
* {@link IProgressMonitor#done()} having been called by the receiver
* @return a list of incoming calls (may be <code>null</code> or empty)
*/
public List<CallHierarchyIncomingCall> getIncomingCalls(CallHierarchyItem item, IProgressMonitor monitor) {
CallHierarchyIncomingCallsRequest request = newIncomingCallsRequest();
request.setProvider(provider);
request.setParams(new CallHierarchyIncomingCallsParams(item));
request.setProgressMonitor(monitor);
request.setUpWorkDoneProgress(() -> new DefaultWorkDoneProgress(Either.forLeft(UUID.randomUUID().toString())));
request.setMayThrow(false);
return request.sendAndReceive();
}
use of org.lxtk.DefaultWorkDoneProgress in project lxtk by lxtk-org.
the class CallHierarchyUtility method getOutgoingCalls.
/**
* Returns the outgoing calls for the given call hierarchy item.
*
* @param item not <code>null</code>
* @param monitor a progress monitor, or <code>null</code>
* if progress reporting is not desired. The caller must not rely on
* {@link IProgressMonitor#done()} having been called by the receiver
* @return a list of outgoing calls (may be <code>null</code> or empty)
*/
public List<CallHierarchyOutgoingCall> getOutgoingCalls(CallHierarchyItem item, IProgressMonitor monitor) {
CallHierarchyOutgoingCallsRequest request = newOutgoingCallsRequest();
request.setProvider(provider);
request.setParams(new CallHierarchyOutgoingCallsParams(item));
request.setProgressMonitor(monitor);
request.setUpWorkDoneProgress(() -> new DefaultWorkDoneProgress(Either.forLeft(UUID.randomUUID().toString())));
request.setMayThrow(false);
return request.sendAndReceive();
}
Aggregations