use of org.ballerinalang.plugins.idea.psi.SourceNotationNode in project ballerina by ballerina-lang.
the class PackageNameReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
IdentifierPSINode identifier = getElement();
FullyQualifiedPackageNameNode fullyQualifiedPackageNameNode = PsiTreeUtil.getParentOfType(identifier, FullyQualifiedPackageNameNode.class);
if (fullyQualifiedPackageNameNode != null) {
return new LookupElement[0];
}
List<LookupElement> results = new ArrayList<>();
PsiFile containingFile = identifier.getContainingFile();
PsiFile originalFile = containingFile.getOriginalFile();
// We don't need to add ':' at the end of the package name in SourceNotationNode.
InsertHandler<LookupElement> importedPackagesInsertHandler = PackageCompletionInsertHandler.INSTANCE_WITH_AUTO_POPUP;
InsertHandler<LookupElement> unImportedPackagesInsertHandler = AutoImportInsertHandler.INSTANCE_WITH_AUTO_POPUP;
SourceNotationNode sourceNotationNode = PsiTreeUtil.getParentOfType(identifier, SourceNotationNode.class);
if (sourceNotationNode != null) {
importedPackagesInsertHandler = null;
unImportedPackagesInsertHandler = AutoImportInsertHandler.INSTANCE;
}
List<LookupElement> packages = BallerinaPsiImplUtil.getPackagesAsLookups(originalFile, true, importedPackagesInsertHandler, true, unImportedPackagesInsertHandler);
results.addAll(packages);
return results.toArray(new LookupElement[results.size()]);
}
Aggregations