Search in sources :

Example 1 with ListLiteral

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

the class GlobReference method resolveListContents.

private static List<String> resolveListContents(Expression expr) {
    if (expr == null) {
        return ImmutableList.of();
    }
    PsiElement rootElement = PsiUtils.getReferencedTargetValue(expr);
    if (!(rootElement instanceof ListLiteral)) {
        return ImmutableList.of();
    }
    Expression[] children = ((ListLiteral) rootElement).getElements();
    List<String> strings = Lists.newArrayListWithCapacity(children.length);
    for (Expression child : children) {
        if (child instanceof StringLiteral) {
            strings.add(((StringLiteral) child).getStringContents());
        }
    }
    return strings;
}
Also used : ListLiteral(com.google.idea.blaze.base.lang.buildfile.psi.ListLiteral) StringLiteral(com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral) GlobExpression(com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression) Expression(com.google.idea.blaze.base.lang.buildfile.psi.Expression) PsiElement(com.intellij.psi.PsiElement)

Aggregations

Expression (com.google.idea.blaze.base.lang.buildfile.psi.Expression)1 GlobExpression (com.google.idea.blaze.base.lang.buildfile.psi.GlobExpression)1 ListLiteral (com.google.idea.blaze.base.lang.buildfile.psi.ListLiteral)1 StringLiteral (com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral)1 PsiElement (com.intellij.psi.PsiElement)1