use of com.google.idea.blaze.base.lang.buildfile.psi.ForStatement in project intellij by bazelbuild.
the class ResolveUtil method searchInScope.
/**
* Walks up PSI tree of local file, checking PsiNamedElements
*/
public static void searchInScope(PsiElement originalElement, Processor<BuildElement> processor) {
// TODO: Handle list comprehension (where variable is defined *later* in the code)
boolean topLevelScope = true;
PsiElement element = originalElement;
while (!(element instanceof PsiFileSystemItem)) {
PsiElement parent = element.getParent();
if (parent instanceof BuildFile) {
if (!((BuildFile) parent).searchSymbolsInScope(processor, topLevelScope ? element : null)) {
return;
}
} else if (parent instanceof FunctionStatement) {
topLevelScope = false;
for (Parameter param : ((FunctionStatement) parent).getParameters()) {
if (!processor.process(param)) {
return;
}
}
} else if (parent instanceof ForStatement) {
for (Expression expr : ((ForStatement) parent).getForLoopVariables()) {
if (expr instanceof TargetExpression && !processor.process(expr)) {
return;
}
}
} else if (parent instanceof StatementList) {
if (!visitChildAssignmentStatements((BuildElement) parent, (Processor) processor)) {
return;
}
}
element = parent;
}
}
Aggregations