use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class TransformerReference method resolve.
@Nullable
@Override
public PsiElement resolve() {
IdentifierPSINode identifier = getElement();
PsiFile containingFile = identifier.getContainingFile();
if (containingFile == null) {
return null;
}
PsiDirectory psiDirectory = containingFile.getParent();
if (psiDirectory == null) {
return null;
}
List<IdentifierPSINode> transformers = BallerinaPsiImplUtil.getAllTransformersFromPackage(psiDirectory, true, false);
for (IdentifierPSINode transformer : transformers) {
if (transformer == null) {
continue;
}
if (identifier.getText().equals(transformer.getText())) {
return transformer;
}
}
return null;
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class TransformerReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
List<LookupElement> results = new LinkedList<>();
IdentifierPSINode identifier = getElement();
PsiFile containingFile = identifier.getContainingFile();
PsiFile originalFile = containingFile.getOriginalFile();
PsiDirectory containingPackage = originalFile.getParent();
if (containingPackage != null) {
List<IdentifierPSINode> functions = BallerinaPsiImplUtil.getAllTransformersFromPackage(containingPackage, true, true);
results.addAll(BallerinaCompletionUtils.createTransformerLookupElements(functions));
}
return results.toArray(new LookupElement[results.size()]);
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class TypeReference method resolve.
@Nullable
public static PsiElement resolve(PsiElement typeNameNode, IdentifierPSINode identifier) {
String valueTypeName = typeNameNode.getText();
Project project = typeNameNode.getProject();
PsiFile psiFile = BallerinaPsiImplUtil.findPsiFileInSDK(project, typeNameNode, "/ballerina/builtin/" + valueTypeName + "lib.bal");
if (psiFile == null) {
return null;
}
List<IdentifierPSINode> functionDefinitions = BallerinaPsiImplUtil.getMatchingElementsFromAFile(psiFile, FunctionDefinitionNode.class, false);
for (IdentifierPSINode functionDefinition : functionDefinitions) {
if (functionDefinition != null && identifier.getText().equals(functionDefinition.getText())) {
return functionDefinition;
}
}
return null;
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class AnnotationReference method resolve.
@Nullable
@Override
public PsiElement resolve() {
IdentifierPSINode identifier = getElement();
PsiElement parent = identifier.getParent();
PackageNameNode packageNameNode = PsiTreeUtil.getChildOfType(parent, PackageNameNode.class);
if (packageNameNode == null) {
return resolveInCurrentPackage();
} else {
return resolveInPackage(packageNameNode);
}
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class AnnotationReference method getVariantsFromCurrentPackage.
@NotNull
private List<LookupElement> getVariantsFromCurrentPackage(boolean allAnnotations) {
List<LookupElement> results = new LinkedList<>();
IdentifierPSINode identifier = getElement();
PsiElement parent = identifier.getParent();
PsiFile containingFile = parent.getContainingFile();
PsiFile originalFile = containingFile.getOriginalFile();
List<LookupElement> packages = BallerinaPsiImplUtil.getPackagesAsLookups(originalFile, true, PackageCompletionInsertHandler.INSTANCE_WITH_AUTO_POPUP, true, AutoImportInsertHandler.INSTANCE_WITH_AUTO_POPUP);
results.addAll(packages);
PsiDirectory containingPackage = originalFile.getParent();
if (containingPackage == null) {
return results;
}
List<IdentifierPSINode> annotations;
if (allAnnotations) {
annotations = BallerinaPsiImplUtil.getAllAnnotationsInPackage(containingPackage, true, true);
} else {
String attachmentType = BallerinaPsiImplUtil.getAttachmentType(identifier);
if (attachmentType == null) {
return results;
}
annotations = BallerinaPsiImplUtil.getAllAnnotationAttachmentsForType(containingPackage, attachmentType, true, true);
}
results.addAll(BallerinaCompletionUtils.createAnnotationLookupElements(annotations));
return results;
}
Aggregations