use of org.ballerinalang.plugins.idea.psi.references.AnnotationReference in project ballerina by ballerina-lang.
the class BallerinaCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
// The file will be loaded to memory and and will be edited. parameters.getOriginalFile()
// contains the original file. parameters.getPosition().getContainingFile() will return null
// because it only exists in the memory. So use parameters.getOriginalFile().getContainingFile()
// if you want to get the details like containing directory, etc.
PsiElement element = parameters.getPosition();
PsiElement parent = element.getParent();
if (parent instanceof PackageNameNode) {
handlePackageNameNode(parameters, result);
} else if (parent instanceof ImportDeclarationNode) {
handleImportDeclarationNode(parameters, result);
}
// Otherwise we only suggest attachable annotations only.
if (parameters.isExtendedCompletion()) {
PsiReference reference = element.findReferenceAt(0);
if (reference instanceof AnnotationReference) {
List<LookupElement> variants = ((AnnotationReference) reference).getVariants(true);
result.addAllElements(variants);
result.addLookupAdvertisement("Showing all annotations in the package");
}
}
}
Aggregations