use of org.ballerinalang.plugins.idea.psi.GlobalVariableDefinitionNode in project ballerina by ballerina-lang.
the class InvocationReference method resolve.
@Nullable
@Override
public PsiElement resolve() {
IdentifierPSINode identifier = getElement();
PsiElement parent = identifier.getParent();
PsiElement prevSibling = parent.getPrevSibling();
if (prevSibling == null) {
return null;
}
PsiReference reference = prevSibling.findReferenceAt(prevSibling.getTextLength());
if (reference == null) {
return null;
}
PsiElement resolvedElement = reference.resolve();
if (resolvedElement == null) {
return null;
}
PsiElement definitionNode = resolvedElement.getParent();
if (definitionNode instanceof VariableDefinitionNode || definitionNode instanceof ParameterNode || definitionNode instanceof GlobalVariableDefinitionNode) {
StructDefinitionNode structDefinitionNode = BallerinaPsiImplUtil.resolveStructFromDefinitionNode(definitionNode);
if (structDefinitionNode != null) {
List<IdentifierPSINode> attachedFunctions = BallerinaPsiImplUtil.getAttachedFunctions(structDefinitionNode);
for (IdentifierPSINode attachedFunction : attachedFunctions) {
if (identifier.getText().equals(attachedFunction.getText())) {
return attachedFunction;
}
}
}
}
return super.resolve();
}
Aggregations