added cancel handling to definition requests
This commit is contained in:
@@ -15,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -22,6 +23,7 @@ import org.eclipse.lsp4j.DefinitionParams;
|
||||
import org.eclipse.lsp4j.Location;
|
||||
import org.eclipse.lsp4j.LocationLink;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.jsonrpc.CancelChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ide.vscode.commons.languageserver.definition.SimpleDefinitionFinder;
|
||||
@@ -73,18 +75,31 @@ public class BoshDefintionFinder extends SimpleDefinitionFinder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocationLink> handle(DefinitionParams params) {
|
||||
public List<LocationLink> handle(CancelChecker cancelToken, DefinitionParams params) {
|
||||
try {
|
||||
TextDocument doc = server.getTextDocumentService().getLatestSnapshot(params);
|
||||
|
||||
if (doc != null) {
|
||||
|
||||
cancelToken.checkCanceled();
|
||||
|
||||
YamlFileAST ast = asts.getSafeAst(doc, false);
|
||||
if (ast!=null) {
|
||||
if (ast != null) {
|
||||
|
||||
cancelToken.checkCanceled();
|
||||
|
||||
Node refNode = ast.findNode(doc.toOffset(params.getPosition()));
|
||||
if (refNode!=null) {
|
||||
|
||||
cancelToken.checkCanceled();
|
||||
|
||||
YType type = astTypes.getType(ast, refNode);
|
||||
if (type!=null) {
|
||||
if (type != null) {
|
||||
|
||||
cancelToken.checkCanceled();
|
||||
|
||||
Handler handler = handlers.get(type);
|
||||
|
||||
if (handler!=null) {
|
||||
int start = refNode.getStartMark().getIndex();
|
||||
int end = refNode.getEndMark().getIndex();
|
||||
@@ -97,6 +112,8 @@ public class BoshDefintionFinder extends SimpleDefinitionFinder {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CancellationException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("", e);;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user