use of org.ballerinalang.langserver.signature.SignatureTreeVisitor in project ballerina by ballerina-lang.
the class BallerinaTextDocumentService method signatureHelp.
@Override
public CompletableFuture<SignatureHelp> signatureHelp(TextDocumentPositionParams position) {
return CompletableFuture.supplyAsync(() -> {
String uri = position.getTextDocument().getUri();
String fileContent = this.documentManager.getFileContent(Paths.get(URI.create(uri)));
TextDocumentServiceContext signatureContext = new TextDocumentServiceContext();
SignatureHelpUtil.captureCallableItemInfo(position.getPosition(), fileContent, signatureContext);
signatureContext.put(DocumentServiceKeys.POSITION_KEY, position);
signatureContext.put(DocumentServiceKeys.FILE_URI_KEY, uri);
SignatureHelp signatureHelp;
try {
BLangPackage bLangPackage = TextDocumentServiceUtil.getBLangPackage(signatureContext, documentManager, false, LSCustomErrorStrategy.class, false).get(0);
signatureContext.put(DocumentServiceKeys.CURRENT_PACKAGE_NAME_KEY, bLangPackage.symbol.getName().getValue());
SignatureTreeVisitor signatureTreeVisitor = new SignatureTreeVisitor(signatureContext);
bLangPackage.accept(signatureTreeVisitor);
signatureContext.put(DocumentServiceKeys.LS_PACKAGE_CACHE_KEY, lSPackageCache);
signatureHelp = SignatureHelpUtil.getFunctionSignatureHelp(signatureContext);
} catch (Exception e) {
signatureHelp = new SignatureHelp();
}
return signatureHelp;
});
}
Aggregations