use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class ConnectorReference 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(identifier);
} else {
return resolveInPackage(packageNameNode, identifier);
}
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class ConnectorReference method getVariantsInPackage.
@NotNull
private List<LookupElement> getVariantsInPackage(@NotNull PackageNameNode packageNameNode) {
List<LookupElement> results = new LinkedList<>();
PsiElement resolvedElement = BallerinaPsiImplUtil.resolvePackage(packageNameNode);
if (resolvedElement == null || !(resolvedElement instanceof PsiDirectory)) {
return results;
}
PsiDirectory resolvedPackage = (PsiDirectory) resolvedElement;
List<IdentifierPSINode> connectors = BallerinaPsiImplUtil.getAllConnectorsFromPackage(resolvedPackage, false, false);
results.addAll(BallerinaCompletionUtils.createConnectorLookupElements(connectors, null));
return results;
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class ConnectorReference method getVariantsInCurrentPackage.
@NotNull
private List<LookupElement> getVariantsInCurrentPackage() {
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> connectors = BallerinaPsiImplUtil.getAllConnectorsFromPackage(containingPackage, true, true);
results.addAll(BallerinaCompletionUtils.createConnectorLookupElements(connectors, ParenthesisInsertHandler.INSTANCE));
}
List<LookupElement> packages = BallerinaPsiImplUtil.getPackagesAsLookups(originalFile, true, PackageCompletionInsertHandler.INSTANCE_WITH_AUTO_POPUP, true, AutoImportInsertHandler.INSTANCE_WITH_AUTO_POPUP);
results.addAll(packages);
return results;
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class ConnectorReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
List<LookupElement> results = new LinkedList<>();
IdentifierPSINode identifier = getElement();
PsiElement parent = identifier.getParent();
PackageNameNode packageNameNode = PsiTreeUtil.getChildOfType(parent, PackageNameNode.class);
if (packageNameNode == null) {
results.addAll(getVariantsInCurrentPackage());
} else {
results.addAll(getVariantsInPackage(packageNameNode));
}
return results.toArray(new LookupElement[results.size()]);
}
use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.
the class DocVariableReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
List<LookupElement> results = new LinkedList<>();
IdentifierPSINode identifier = getElement();
ResourceDefinitionNode resourceDefinitionNode = PsiTreeUtil.getParentOfType(identifier, ResourceDefinitionNode.class);
if (resourceDefinitionNode != null) {
List<IdentifierPSINode> parameters = BallerinaPsiImplUtil.getParameters(resourceDefinitionNode);
results.addAll(BallerinaCompletionUtils.createParameterLookupElements(parameters));
} else {
DocumentationAttachmentNode documentationAttachmentNode = PsiTreeUtil.getParentOfType(identifier, DocumentationAttachmentNode.class);
if (documentationAttachmentNode == null) {
return results.toArray(new LookupElement[results.size()]);
}
PsiElement nextSibling = documentationAttachmentNode.getNextSibling();
if (nextSibling == null) {
return results.toArray(new LookupElement[results.size()]);
}
}
return results.toArray(new LookupElement[results.size()]);
}
Aggregations