use of org.ballerinalang.plugins.idea.psi.ExpressionNode in project ballerina by ballerina-lang.
the class BallerinaPsiImplUtil method getType.
@Nullable
private static PsiElement getType(@NotNull AssignmentStatementNode assignmentStatementNode, @NotNull IdentifierPSINode identifier) {
if (!BallerinaPsiImplUtil.isVarAssignmentStatement(assignmentStatementNode)) {
return null;
}
ExpressionNode expressionNode = PsiTreeUtil.getChildOfType(assignmentStatementNode, ExpressionNode.class);
if (expressionNode == null) {
return null;
}
PsiElement expressionNodeFirstChild = expressionNode.getFirstChild();
if (expressionNodeFirstChild instanceof VariableReferenceNode) {
PsiElement typeNode = getTypeFromVariableReference(assignmentStatementNode, identifier, expressionNodeFirstChild);
if (typeNode != null) {
return typeNode;
}
} else if (expressionNodeFirstChild instanceof TypeCastNode) {
int index = getVariableIndexFromVarAssignment(assignmentStatementNode, identifier);
if (index == 0) {
TypeNameNode typeNameNode = PsiTreeUtil.getChildOfType(expressionNodeFirstChild, TypeNameNode.class);
if (typeNameNode == null) {
return null;
}
return getType(typeNameNode, false);
}
StructDefinitionNode errorStruct = BallerinaPsiImplUtil.getErrorStruct(assignmentStatementNode, identifier, true, false);
if (errorStruct == null) {
return null;
}
return errorStruct.getNameIdentifier();
} else if (expressionNodeFirstChild instanceof TypeConversionNode) {
int index = getVariableIndexFromVarAssignment(assignmentStatementNode, identifier);
if (index == 0) {
TypeNameNode typeNameNode = PsiTreeUtil.getChildOfType(expressionNodeFirstChild, TypeNameNode.class);
if (typeNameNode == null) {
return null;
}
return getType(typeNameNode, false);
}
StructDefinitionNode errorStruct = BallerinaPsiImplUtil.getErrorStruct(assignmentStatementNode, identifier, false, true);
if (errorStruct == null) {
return null;
}
return errorStruct.getNameIdentifier();
}
PsiReference firstChildReference = expressionNodeFirstChild.findReferenceAt(expressionNodeFirstChild.getTextLength());
if (firstChildReference == null) {
return null;
}
PsiElement resolvedElement = firstChildReference.resolve();
if (resolvedElement == null) {
return null;
}
return getType(((IdentifierPSINode) resolvedElement));
}
use of org.ballerinalang.plugins.idea.psi.ExpressionNode in project ballerina by ballerina-lang.
the class BallerinaParserDefinition method createElement.
@NotNull
public PsiElement createElement(ASTNode node) {
IElementType elementType = node.getElementType();
if (elementType instanceof TokenIElementType) {
return new ANTLRPsiNode(node);
}
if (!(elementType instanceof RuleIElementType)) {
return new ANTLRPsiNode(node);
}
RuleIElementType ruleElType = (RuleIElementType) elementType;
switch(ruleElType.getRuleIndex()) {
case BallerinaParser.RULE_functionDefinition:
return new FunctionDefinitionNode(node);
case BallerinaParser.RULE_callableUnitBody:
return new CallableUnitBodyNode(node);
case BallerinaParser.RULE_nameReference:
return new NameReferenceNode(node);
case BallerinaParser.RULE_variableReference:
return new VariableReferenceNode(node);
case BallerinaParser.RULE_variableDefinitionStatement:
return new VariableDefinitionNode(node);
case BallerinaParser.RULE_parameter:
return new ParameterNode(node);
case BallerinaParser.RULE_resourceDefinition:
return new ResourceDefinitionNode(node);
case BallerinaParser.RULE_packageName:
return new PackageNameNode(node);
case BallerinaParser.RULE_fullyQualifiedPackageName:
return new FullyQualifiedPackageNameNode(node);
case BallerinaParser.RULE_expressionList:
return new ExpressionListNode(node);
case BallerinaParser.RULE_expression:
return new ExpressionNode(node);
case BallerinaParser.RULE_functionInvocation:
return new FunctionInvocationNode(node);
case BallerinaParser.RULE_compilationUnit:
return new CompilationUnitNode(node);
case BallerinaParser.RULE_packageDeclaration:
return new PackageDeclarationNode(node);
case BallerinaParser.RULE_annotationAttachment:
return new AnnotationAttachmentNode(node);
case BallerinaParser.RULE_serviceBody:
return new ServiceBodyNode(node);
case BallerinaParser.RULE_importDeclaration:
return new ImportDeclarationNode(node);
case BallerinaParser.RULE_statement:
return new StatementNode(node);
case BallerinaParser.RULE_typeName:
return new TypeNameNode(node);
case BallerinaParser.RULE_constantDefinition:
return new ConstantDefinitionNode(node);
case BallerinaParser.RULE_structDefinition:
return new StructDefinitionNode(node);
case BallerinaParser.RULE_simpleLiteral:
return new SimpleLiteralNode(node);
case BallerinaParser.RULE_packageAlias:
return new AliasNode(node);
case BallerinaParser.RULE_parameterList:
return new ParameterListNode(node);
case BallerinaParser.RULE_fieldDefinition:
return new FieldDefinitionNode(node);
case BallerinaParser.RULE_parameterTypeNameList:
return new ParameterTypeNameList(node);
case BallerinaParser.RULE_parameterTypeName:
return new ConnectorInitNode(node);
case BallerinaParser.RULE_serviceDefinition:
return new ServiceDefinitionNode(node);
case BallerinaParser.RULE_valueTypeName:
return new ValueTypeNameNode(node);
case BallerinaParser.RULE_annotationDefinition:
return new AnnotationAttributeValueNode(node);
case BallerinaParser.RULE_structBody:
return new StructBodyNode(node);
case BallerinaParser.RULE_returnParameter:
return new ReturnParameterNode(node);
case BallerinaParser.RULE_attachmentPoint:
return new AttachmentPointNode(node);
case BallerinaParser.RULE_definition:
return new DefinitionNode(node);
case BallerinaParser.RULE_ifElseStatement:
return new IfElseStatementNode(node);
case BallerinaParser.RULE_assignmentStatement:
return new AssignmentStatementNode(node);
case BallerinaParser.RULE_variableReferenceList:
return new VariableReferenceListNode(node);
case BallerinaParser.RULE_recordLiteral:
return new RecordLiteralNode(node);
case BallerinaParser.RULE_globalVariableDefinition:
return new GlobalVariableDefinitionNode(node);
case BallerinaParser.RULE_recordKeyValue:
return new RecordKeyValueNode(node);
case BallerinaParser.RULE_forkJoinStatement:
return new ForkJoinStatementNode(node);
case BallerinaParser.RULE_returnStatement:
return new ReturnStatementNode(node);
case BallerinaParser.RULE_throwStatement:
return new ThrowStatementNode(node);
case BallerinaParser.RULE_transformerDefinition:
return new TransformerDefinitionNode(node);
case BallerinaParser.RULE_workerReply:
return new WorkerReplyNode(node);
case BallerinaParser.RULE_triggerWorker:
return new TriggerWorkerNode(node);
case BallerinaParser.RULE_workerDeclaration:
return new WorkerDeclarationNode(node);
case BallerinaParser.RULE_workerBody:
return new WorkerBodyNode(node);
case BallerinaParser.RULE_joinConditions:
return new JoinConditionNode(node);
case BallerinaParser.RULE_field:
return new FieldNode(node);
case BallerinaParser.RULE_recordKey:
return new RecordKeyNode(node);
case BallerinaParser.RULE_recordValue:
return new RecordValueNode(node);
case BallerinaParser.RULE_functionReference:
return new FunctionReferenceNode(node);
case BallerinaParser.RULE_codeBlockBody:
return new CodeBlockBodyNode(node);
case BallerinaParser.RULE_nonEmptyCodeBlockBody:
return new NonEmptyCodeBlockBodyNode(node);
case BallerinaParser.RULE_tryCatchStatement:
return new TryCatchStatementNode(node);
case BallerinaParser.RULE_catchClause:
return new CatchClauseNode(node);
case BallerinaParser.RULE_codeBlockParameter:
return new CodeBlockParameterNode(node);
case BallerinaParser.RULE_foreachStatement:
return new ForEachStatementNode(node);
case BallerinaParser.RULE_joinClause:
return new JoinClauseNode(node);
case BallerinaParser.RULE_timeoutClause:
return new TimeoutClauseNode(node);
case BallerinaParser.RULE_xmlAttrib:
return new XmlAttribNode(node);
case BallerinaParser.RULE_namespaceDeclaration:
return new NamespaceDeclarationNode(node);
case BallerinaParser.RULE_stringTemplateLiteral:
return new StringTemplateLiteralNode(node);
case BallerinaParser.RULE_stringTemplateContent:
return new StringTemplateContentNode(node);
case BallerinaParser.RULE_typeConversion:
return new TypeConversionNode(node);
case BallerinaParser.RULE_xmlContent:
return new XmlContentNode(node);
case BallerinaParser.RULE_invocation:
return new InvocationNode(node);
case BallerinaParser.RULE_enumDefinition:
return new EnumDefinitionNode(node);
case BallerinaParser.RULE_enumField:
return new EnumFieldNode(node);
case BallerinaParser.RULE_builtInReferenceTypeName:
return new BuiltInReferenceTypeNameNode(node);
case BallerinaParser.RULE_referenceTypeName:
return new ReferenceTypeNameNode(node);
case BallerinaParser.RULE_functionTypeName:
return new FunctionTypeNameNode(node);
case BallerinaParser.RULE_lambdaFunction:
return new LambdaFunctionNode(node);
case BallerinaParser.RULE_endpointDeclaration:
return new EndpointDeclarationNode(node);
case BallerinaParser.RULE_anonStructTypeName:
return new AnonStructTypeNameNode(node);
case BallerinaParser.RULE_userDefineTypeName:
return new UserDefinedTypeName(node);
case BallerinaParser.RULE_anyIdentifierName:
return new AnyIdentifierNameNode(node);
case BallerinaParser.RULE_documentationAttachment:
return new DocumentationAttachmentNode(node);
case BallerinaParser.RULE_documentationTemplateInlineCode:
return new DocumentationTemplateInlineCodeNode(node);
case BallerinaParser.RULE_singleBackTickDocInlineCode:
return new SingleBackTickDocInlineCodeNode(node);
case BallerinaParser.RULE_doubleBackTickDocInlineCode:
return new DoubleBackTickInlineCodeNode(node);
case BallerinaParser.RULE_tripleBackTickDocInlineCode:
return new TripleBackTickInlineCodeNode(node);
case BallerinaParser.RULE_deprecatedAttachment:
return new DeprecatedAttachmentNode(node);
case BallerinaParser.RULE_deprecatedText:
return new DeprecatedTextNode(node);
case BallerinaParser.RULE_singleBackTickDeprecatedInlineCode:
return new SingleBackTickDeprecatedInlineCodeNode(node);
case BallerinaParser.RULE_doubleBackTickDeprecatedInlineCode:
return new DoubleBackTickDeprecatedInlineCodeNode(node);
case BallerinaParser.RULE_tripleBackTickDeprecatedInlineCode:
return new TripleBackTickDeprecatedInlineCodeNode(node);
case BallerinaParser.RULE_documentationTemplateAttributeDescription:
return new DocumentationTemplateAttributeDescriptionNode(node);
case BallerinaParser.RULE_formalParameterList:
return new FormalParameterListNode(node);
case BallerinaParser.RULE_integerLiteral:
return new IntegerLiteralNode(node);
case BallerinaParser.RULE_matchPatternClause:
return new MatchPatternClauseNode(node);
default:
return new ANTLRPsiNode(node);
}
}
use of org.ballerinalang.plugins.idea.psi.ExpressionNode in project ballerina by ballerina-lang.
the class BallerinaKeywordsCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiElement element = parameters.getPosition();
PsiElement parent = element.getParent();
if (element instanceof LeafPsiElement) {
IElementType elementType = ((LeafPsiElement) element).getElementType();
if (elementType == BallerinaTypes.FLOATING_POINT) {
return;
}
}
if (parent instanceof NameReferenceNode) {
PsiElement prevVisibleLeaf = PsiTreeUtil.prevVisibleLeaf(element);
if (prevVisibleLeaf != null && "public".equals(prevVisibleLeaf.getText())) {
result.addAllElements(getFileLevelKeywordsAsLookups(false, true, true));
}
if (prevVisibleLeaf instanceof IdentifierPSINode) {
result.addElement(getAttachKeyword());
return;
}
ANTLRPsiNode definitionParent = PsiTreeUtil.getParentOfType(parent, CallableUnitBodyNode.class, ServiceBodyNode.class, ConnectorBodyNode.class);
if (definitionParent != null && prevVisibleLeaf != null && "=".equals(prevVisibleLeaf.getText())) {
result.addElement(getCreateKeyword());
result.addElement(getTypeOfKeyword());
result.addElement(getLengthOfKeyword());
result.addAllElements(getValueKeywords());
}
ExpressionNode expressionNode = PsiTreeUtil.getParentOfType(parent, ExpressionNode.class);
if (expressionNode != null && expressionNode.getChildren().length == 1) {
PsiReference referenceAt = parent.findReferenceAt(0);
if (referenceAt == null || referenceAt instanceof NameReference) {
result.addAllElements(getValueKeywords());
}
PsiElement nextVisibleLeaf = PsiTreeUtil.nextVisibleLeaf(element);
if ((prevVisibleLeaf != null && "(".equals(prevVisibleLeaf.getText())) || (nextVisibleLeaf != null && ")".equals(nextVisibleLeaf.getText()) && !":".equals(prevVisibleLeaf.getText()))) {
addOtherTypeAsLookup(result);
addValueTypesAsLookups(result);
addReferenceTypesAsLookups(result);
}
}
AnnotationAttachmentNode attachmentNode = PsiTreeUtil.getParentOfType(parent, AnnotationAttachmentNode.class);
if (attachmentNode != null) {
result.addAllElements(getValueKeywords());
}
TypeNameNode typeNameNode = PsiTreeUtil.getParentOfType(parent, TypeNameNode.class);
if (typeNameNode != null && prevVisibleLeaf != null && !prevVisibleLeaf.getText().matches("[:.=]")) {
AnnotationDefinitionNode annotationDefinitionNode = PsiTreeUtil.getParentOfType(typeNameNode, AnnotationDefinitionNode.class);
if (annotationDefinitionNode == null) {
addOtherTypeAsLookup(result);
addXmlnsAsLookup(result);
addValueTypesAsLookups(result);
addReferenceTypesAsLookups(result);
}
}
}
if (parent instanceof StatementNode) {
PsiElement prevVisibleSibling = PsiTreeUtil.prevVisibleLeaf(element);
if (prevVisibleSibling != null && "=".equals(prevVisibleSibling.getText())) {
result.addElement(getCreateKeyword());
result.addElement(getTypeOfKeyword());
result.addElement(getLengthOfKeyword());
}
}
if (parent instanceof ConstantDefinitionNode || parent instanceof PsiErrorElement) {
PsiElement prevVisibleSibling = PsiTreeUtil.prevVisibleLeaf(element);
if (prevVisibleSibling != null && "const".equals(prevVisibleSibling.getText())) {
addValueTypesAsLookups(result);
return;
}
}
if (parent instanceof PsiErrorElement) {
PsiElement prevVisibleSibling = PsiTreeUtil.prevVisibleLeaf(element);
PsiElement definitionNode = PsiTreeUtil.getParentOfType(element, FunctionDefinitionNode.class, ServiceDefinitionNode.class, ConnectorDefinitionNode.class, ResourceDefinitionNode.class);
if (definitionNode != null) {
if (prevVisibleSibling != null && "=".equals(prevVisibleSibling.getText())) {
result.addElement(getCreateKeyword());
result.addAllElements(getValueKeywords());
result.addElement(getTypeOfKeyword());
result.addElement(getLengthOfKeyword());
}
if (prevVisibleSibling != null && prevVisibleSibling.getText().matches("[;{}]") && !(prevVisibleSibling.getParent() instanceof AnnotationAttachmentNode)) {
// Todo - change method
addOtherTypeAsLookup(result);
addXmlnsAsLookup(result);
addValueTypesAsLookups(result);
addReferenceTypesAsLookups(result);
if (definitionNode instanceof FunctionDefinitionNode) {
result.addAllElements(getFunctionSpecificKeywords());
}
if (definitionNode instanceof ResourceDefinitionNode) {
result.addAllElements(getResourceSpecificKeywords());
}
if (definitionNode instanceof ServiceDefinitionNode) {
result.addAllElements(getServiceSpecificKeywords());
}
if (definitionNode instanceof ConnectorDefinitionNode) {
result.addAllElements(getConnectorSpecificKeywords());
}
if (!(definitionNode instanceof ServiceDefinitionNode || definitionNode instanceof ConnectorDefinitionNode)) {
result.addAllElements(getCommonKeywords());
}
}
if (prevVisibleSibling != null && !prevVisibleSibling.getText().matches("[{}]")) /*|| !(prevVisibleSibling.getParent() instanceof AnnotationAttachmentNode)*/
{
result.addAllElements(getValueKeywords());
}
}
ConnectorBodyNode connectorBodyNode = PsiTreeUtil.getParentOfType(element, ConnectorBodyNode.class);
if (connectorBodyNode != null) {
result.addAllElements(getConnectorSpecificKeywords());
}
ConnectorDefinitionNode connectorDefinitionNode = PsiTreeUtil.getParentOfType(element, ConnectorDefinitionNode.class);
if (connectorDefinitionNode != null) {
result.addAllElements(getConnectorSpecificKeywords());
}
return;
}
if (parent instanceof NameReferenceNode) {
RecordKeyValueNode recordKeyValueNode = PsiTreeUtil.getParentOfType(parent, RecordKeyValueNode.class);
if (recordKeyValueNode == null) {
PsiElement prevVisibleSibling = PsiTreeUtil.prevVisibleLeaf(element);
if (prevVisibleSibling != null && "{".equals(prevVisibleSibling.getText())) {
FunctionDefinitionNode functionDefinitionNode = PsiTreeUtil.getParentOfType(element, FunctionDefinitionNode.class);
if (functionDefinitionNode != null) {
// Todo - change method
addOtherTypeAsLookup(result);
addXmlnsAsLookup(result);
addValueTypesAsLookups(result);
addReferenceTypesAsLookups(result);
result.addAllElements(getFunctionSpecificKeywords());
result.addAllElements(getCommonKeywords());
result.addAllElements(getValueKeywords());
}
ServiceBodyNode serviceBodyNode = PsiTreeUtil.getParentOfType(element, ServiceBodyNode.class);
if (serviceBodyNode != null) {
result.addAllElements(getServiceSpecificKeywords());
}
ConnectorBodyNode connectorBodyNode = PsiTreeUtil.getParentOfType(element, ConnectorBodyNode.class);
if (connectorBodyNode != null) {
result.addAllElements(getConnectorSpecificKeywords());
}
} else if (prevVisibleSibling != null && "}".equals(prevVisibleSibling.getText())) {
result.addAllElements(getFileLevelKeywordsAsLookups(true, false, false));
}
}
}
if (parent instanceof ResourceDefinitionNode) {
result.addAllElements(getServiceSpecificKeywords());
}
if (parent.getPrevSibling() == null) {
GlobalVariableDefinitionNode globalVariableDefinitionNode = PsiTreeUtil.getParentOfType(element, GlobalVariableDefinitionNode.class);
if (globalVariableDefinitionNode != null) {
PsiElement prevVisibleSibling = PsiTreeUtil.prevVisibleLeaf(element);
if (prevVisibleSibling != null && !(";".equals(prevVisibleSibling.getText()))) {
if (!(prevVisibleSibling.getText().matches("[:=]") || prevVisibleSibling instanceof IdentifierPSINode || "create".equals(prevVisibleSibling.getText()))) {
if (prevVisibleSibling instanceof LeafPsiElement) {
IElementType elementType = ((LeafPsiElement) prevVisibleSibling).getElementType();
if (BallerinaParserDefinition.KEYWORDS.contains(elementType)) {
return;
}
}
result.addAllElements(getCommonKeywords());
}
return;
}
PsiElement definitionNode = globalVariableDefinitionNode.getParent();
PackageDeclarationNode prevPackageDeclarationNode = PsiTreeUtil.getPrevSiblingOfType(definitionNode, PackageDeclarationNode.class);
ImportDeclarationNode prevImportDeclarationNode = PsiTreeUtil.getPrevSiblingOfType(definitionNode, ImportDeclarationNode.class);
ConstantDefinitionNode prevConstantDefinitionNode = PsiTreeUtil.getPrevSiblingOfType(definitionNode, ConstantDefinitionNode.class);
DefinitionNode prevDefinitionNode = PsiTreeUtil.getPrevSiblingOfType(definitionNode, DefinitionNode.class);
GlobalVariableDefinitionNode prevGlobalVariableDefinition = PsiTreeUtil.findChildOfType(prevDefinitionNode, GlobalVariableDefinitionNode.class);
if (prevPackageDeclarationNode == null && prevImportDeclarationNode == null && prevConstantDefinitionNode == null && prevGlobalVariableDefinition == null) {
result.addAllElements(getFileLevelKeywordsAsLookups(true, true, true));
} else if ((prevPackageDeclarationNode != null || prevImportDeclarationNode != null) && prevConstantDefinitionNode == null && prevGlobalVariableDefinition == null) {
result.addAllElements(getFileLevelKeywordsAsLookups(true, false, true));
} else {
result.addAllElements(getFileLevelKeywordsAsLookups(true, false, false));
}
addTypeNamesAsLookups(result);
}
}
if (element instanceof IdentifierPSINode) {
PsiReference reference = element.findReferenceAt(element.getTextLength());
if (reference instanceof WorkerReference) {
result.addAllElements(getWorkerInteractionKeywords());
}
}
}
use of org.ballerinalang.plugins.idea.psi.ExpressionNode in project ballerina by ballerina-lang.
the class BallerinaPsiImplUtil method getStructDefinition.
/**
* Checks the RHS of the provided {@link AssignmentStatementNode} and returns the corresponding
* {@link StructDefinitionNode}.
*
* @param assignmentStatementNode an assignment statement node
* @param structReferenceNode an identifier which is a var variable in the assignment node
* @return {@code null} if cannot suggest a {@link StructDefinitionNode}, otherwise returns the corresponding
* {@link StructDefinitionNode}.
*/
@Nullable
public static StructDefinitionNode getStructDefinition(@NotNull AssignmentStatementNode assignmentStatementNode, @NotNull IdentifierPSINode structReferenceNode) {
if (!BallerinaPsiImplUtil.isVarAssignmentStatement(assignmentStatementNode)) {
return null;
}
ExpressionNode expressionNode = PsiTreeUtil.getChildOfType(assignmentStatementNode, ExpressionNode.class);
if (expressionNode == null) {
return null;
}
PsiElement expressionNodeFirstChild = expressionNode.getFirstChild();
if (expressionNodeFirstChild instanceof VariableReferenceNode) {
return getStructDefinition((VariableReferenceNode) expressionNodeFirstChild, assignmentStatementNode, structReferenceNode);
} else if (expressionNodeFirstChild instanceof TypeCastNode) {
int index = getVariableIndexFromVarAssignment(assignmentStatementNode, structReferenceNode);
if (index == 0) {
return resolveTypeNodeStruct((expressionNodeFirstChild));
} else if (index == 1) {
return getErrorStruct(assignmentStatementNode, structReferenceNode, true, false);
}
} else if (expressionNodeFirstChild instanceof TypeConversionNode) {
int index = getVariableIndexFromVarAssignment(assignmentStatementNode, structReferenceNode);
if (index == 0) {
return resolveTypeNodeStruct((expressionNodeFirstChild));
} else if (index == 1) {
return getErrorStruct(assignmentStatementNode, structReferenceNode, false, true);
}
}
return null;
}
use of org.ballerinalang.plugins.idea.psi.ExpressionNode in project ballerina by ballerina-lang.
the class LanguageInjectorUtils method isValid.
/**
* Checks whether the provided host is suitable for language injecting.
*
* @param host host string to be checked
* @param packageNames valid package names
* @param functionNames valid function names
* @return {@code true} if suitable for injecting language, {@code false} otherwise.
*/
public static boolean isValid(@NotNull PsiLanguageInjectionHost host, @NotNull Set<String> packageNames, @NotNull Set<String> functionNames) {
if (!(host instanceof QuotedLiteralString)) {
return false;
}
ExpressionListNode expressionListNode = PsiTreeUtil.getTopmostParentOfType(host, ExpressionListNode.class);
if (expressionListNode == null) {
return false;
}
PsiElement firstChild = expressionListNode.getFirstChild();
if (firstChild.getChildren().length > 1) {
return false;
}
FunctionReferenceNode functionReferenceNode = PsiTreeUtil.getPrevSiblingOfType(expressionListNode, FunctionReferenceNode.class);
if (functionReferenceNode == null) {
return false;
}
PackageNameNode packageNameNode = PsiTreeUtil.getChildOfType(functionReferenceNode, PackageNameNode.class);
if (packageNameNode == null) {
return false;
}
IdentifierPSINode functionName = PsiTreeUtil.getChildOfType(functionReferenceNode, IdentifierPSINode.class);
if (functionName == null) {
return false;
}
ExpressionNode expressionNode = PsiTreeUtil.getParentOfType(host, ExpressionNode.class);
if (expressionNode == null) {
return false;
}
Collection<QuotedLiteralString> quotedLiteralStrings = PsiTreeUtil.findChildrenOfType(expressionNode, QuotedLiteralString.class);
// We ignore this case since the string might not be identified correctly and will cause issues.
if (quotedLiteralStrings.size() > 1) {
return false;
}
return packageNames.contains(packageNameNode.getText()) && functionNames.contains(functionName.getText());
}
Aggregations