Search in sources :

Example 41 with IdentifierPSINode

use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.

the class BallerinaCompletionUtils method createFunctionLookupElements.

@NotNull
public static List<LookupElement> createFunctionLookupElements(@NotNull List<IdentifierPSINode> functions) {
    List<LookupElement> lookupElements = new LinkedList<>();
    for (IdentifierPSINode function : functions) {
        if (function == null) {
            continue;
        }
        LookupElement lookupElement = createFunctionLookupElement(function, ParenthesisInsertHandler.INSTANCE);
        lookupElements.add(lookupElement);
    }
    return lookupElements;
}
Also used : IdentifierPSINode(org.ballerinalang.plugins.idea.psi.IdentifierPSINode) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PrioritizedLookupElement(com.intellij.codeInsight.completion.PrioritizedLookupElement) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with IdentifierPSINode

use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.

the class BallerinaCompletionUtils method createEnumFieldLookupElements.

@NotNull
public static List<LookupElement> createEnumFieldLookupElements(@NotNull Collection<EnumFieldNode> enumFieldNodes, @NotNull IdentifierPSINode definitionName) {
    List<LookupElement> lookupElements = new LinkedList<>();
    for (EnumFieldNode fieldDefinitionNode : enumFieldNodes) {
        IdentifierPSINode fieldName = PsiTreeUtil.getChildOfType(fieldDefinitionNode, IdentifierPSINode.class);
        if (fieldName == null) {
            continue;
        }
        LookupElement lookupElement = BallerinaCompletionUtils.createEnumFieldLookupElement(fieldName, definitionName);
        lookupElements.add(lookupElement);
    }
    return lookupElements;
}
Also used : EnumFieldNode(org.ballerinalang.plugins.idea.psi.EnumFieldNode) IdentifierPSINode(org.ballerinalang.plugins.idea.psi.IdentifierPSINode) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PrioritizedLookupElement(com.intellij.codeInsight.completion.PrioritizedLookupElement) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Example 43 with IdentifierPSINode

use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.

the class BallerinaCompletionUtils method createFieldLookupElements.

@NotNull
public static List<LookupElement> createFieldLookupElements(@NotNull Collection<FieldDefinitionNode> fieldDefinitionNodes, @NotNull IdentifierPSINode definitionName, @Nullable InsertHandler<LookupElement> insertHandler) {
    List<LookupElement> lookupElements = new LinkedList<>();
    for (FieldDefinitionNode fieldDefinitionNode : fieldDefinitionNodes) {
        IdentifierPSINode fieldName = PsiTreeUtil.getChildOfType(fieldDefinitionNode, IdentifierPSINode.class);
        TypeNameNode fieldType = PsiTreeUtil.getChildOfType(fieldDefinitionNode, TypeNameNode.class);
        if (fieldName == null || fieldType == null) {
            continue;
        }
        LookupElement lookupElement = BallerinaCompletionUtils.createFieldLookupElement(fieldName, fieldType, definitionName, insertHandler);
        lookupElements.add(lookupElement);
    }
    return lookupElements;
}
Also used : TypeNameNode(org.ballerinalang.plugins.idea.psi.TypeNameNode) IdentifierPSINode(org.ballerinalang.plugins.idea.psi.IdentifierPSINode) FieldDefinitionNode(org.ballerinalang.plugins.idea.psi.FieldDefinitionNode) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PrioritizedLookupElement(com.intellij.codeInsight.completion.PrioritizedLookupElement) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Example 44 with IdentifierPSINode

use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.

the class BallerinaCompletionUtils method createConnectorLookupElements.

@NotNull
public static List<LookupElement> createConnectorLookupElements(@NotNull List<IdentifierPSINode> connectors, @Nullable InsertHandler<LookupElement> insertHandler) {
    List<LookupElement> lookupElements = new LinkedList<>();
    for (IdentifierPSINode connector : connectors) {
        if (connector == null) {
            continue;
        }
        LookupElement lookupElement = createConnectorLookupElement(connector, insertHandler);
        lookupElements.add(lookupElement);
    }
    return lookupElements;
}
Also used : IdentifierPSINode(org.ballerinalang.plugins.idea.psi.IdentifierPSINode) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PrioritizedLookupElement(com.intellij.codeInsight.completion.PrioritizedLookupElement) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Example 45 with IdentifierPSINode

use of org.ballerinalang.plugins.idea.psi.IdentifierPSINode in project ballerina by ballerina-lang.

the class BallerinaCompletionUtils method createGlobalVariableLookupElements.

@NotNull
public static List<LookupElement> createGlobalVariableLookupElements(@NotNull List<IdentifierPSINode> variables) {
    List<LookupElement> lookupElements = new LinkedList<>();
    for (IdentifierPSINode variable : variables) {
        if (variable == null) {
            continue;
        }
        LookupElement lookupElement = createGlobalVariableLookupElement(variable);
        lookupElements.add(lookupElement);
    }
    return lookupElements;
}
Also used : IdentifierPSINode(org.ballerinalang.plugins.idea.psi.IdentifierPSINode) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PrioritizedLookupElement(com.intellij.codeInsight.completion.PrioritizedLookupElement) LinkedList(java.util.LinkedList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IdentifierPSINode (org.ballerinalang.plugins.idea.psi.IdentifierPSINode)109 PsiElement (com.intellij.psi.PsiElement)70 NotNull (org.jetbrains.annotations.NotNull)63 LinkedList (java.util.LinkedList)58 LookupElement (com.intellij.codeInsight.lookup.LookupElement)48 Nullable (org.jetbrains.annotations.Nullable)32 PsiDirectory (com.intellij.psi.PsiDirectory)29 PsiReference (com.intellij.psi.PsiReference)25 PsiFile (com.intellij.psi.PsiFile)24 PackageNameNode (org.ballerinalang.plugins.idea.psi.PackageNameNode)20 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)17 ScopeNode (org.antlr.jetbrains.adaptor.psi.ScopeNode)15 PrioritizedLookupElement (com.intellij.codeInsight.completion.PrioritizedLookupElement)12 FieldDefinitionNode (org.ballerinalang.plugins.idea.psi.FieldDefinitionNode)12 StructDefinitionNode (org.ballerinalang.plugins.idea.psi.StructDefinitionNode)12 VariableDefinitionNode (org.ballerinalang.plugins.idea.psi.VariableDefinitionNode)10 GlobalVariableDefinitionNode (org.ballerinalang.plugins.idea.psi.GlobalVariableDefinitionNode)9 TypeNameNode (org.ballerinalang.plugins.idea.psi.TypeNameNode)9 ArrayList (java.util.ArrayList)8 NameReferenceNode (org.ballerinalang.plugins.idea.psi.NameReferenceNode)8