use of org.ballerinalang.plugins.idea.psi.AnnotationAttachmentNode in project ballerina by ballerina-lang.
the class AnnotationAttributeReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
IdentifierPSINode identifier = getElement();
AnnotationAttachmentNode annotationAttachmentNode = PsiTreeUtil.getParentOfType(identifier, AnnotationAttachmentNode.class);
if (annotationAttachmentNode == null) {
return new Object[0];
}
AnnotationReferenceNode annotationReferenceNode = PsiTreeUtil.getChildOfType(annotationAttachmentNode, AnnotationReferenceNode.class);
if (annotationReferenceNode == null) {
return new Object[0];
}
int textLength = annotationReferenceNode.getTextLength();
PsiReference reference = annotationReferenceNode.findReferenceAt(textLength);
if (reference == null) {
return new Object[0];
}
PsiElement annotationName = reference.resolve();
if (annotationName == null || !(annotationName instanceof IdentifierPSINode)) {
return new Object[0];
}
PsiElement annotationDefinition = annotationName.getParent();
Collection<FieldDefinitionNode> fieldDefinitionNodes = PsiTreeUtil.findChildrenOfType(annotationDefinition, FieldDefinitionNode.class);
List<LookupElement> results = BallerinaCompletionUtils.createFieldLookupElements(fieldDefinitionNodes, (IdentifierPSINode) annotationName, PackageCompletionInsertHandler.INSTANCE_WITH_AUTO_POPUP);
return results.toArray(new LookupElement[results.size()]);
}
Aggregations