Search in sources :

Example 1 with Keyword

use of com.google.idea.blaze.base.lang.buildfile.psi.Argument.Keyword in project intellij by bazelbuild.

the class BuildTargetElementEvaluator method getParentFuncallIfNameString.

@Nullable
private static FuncallExpression getParentFuncallIfNameString(PsiElement element) {
    PsiElement parent = element.getParent();
    if (!(parent instanceof StringLiteral)) {
        return null;
    }
    parent = parent.getParent();
    if (!(parent instanceof Keyword)) {
        return null;
    }
    if (!Objects.equals(((Keyword) parent).getName(), "name")) {
        return null;
    }
    parent = parent.getParent();
    if (!(parent instanceof ArgumentList)) {
        return null;
    }
    parent = parent.getParent();
    return parent instanceof FuncallExpression ? (FuncallExpression) parent : null;
}
Also used : StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) Keyword(com.google.idea.blaze.base.lang.buildfile.psi.Argument.Keyword) ArgumentList(com.google.idea.blaze.base.lang.buildfile.psi.ArgumentList) FuncallExpression(com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression) PsiElement(com.intellij.psi.PsiElement) Nullable(javax.annotation.Nullable)

Aggregations

Keyword (com.google.idea.blaze.base.lang.buildfile.psi.Argument.Keyword)1 ArgumentList (com.google.idea.blaze.base.lang.buildfile.psi.ArgumentList)1 FuncallExpression (com.google.idea.blaze.base.lang.buildfile.psi.FuncallExpression)1 StringLiteral (com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral)1 PsiElement (com.intellij.psi.PsiElement)1 Nullable (javax.annotation.Nullable)1