use of com.google.idea.blaze.base.lang.buildfile.psi.NamedBuildElement in project intellij by bazelbuild.
the class BuildReferenceSearcher method processQuery.
@Override
public void processQuery(SearchParameters params, Processor<PsiReference> consumer) {
PsiElement element = params.getElementToSearch();
if (element instanceof NamedBuildElement) {
String fnName = ((NamedBuildElement) element).getName();
if (fnName != null) {
searchForString(params, element, fnName);
}
return;
}
PsiFile file = ResolveUtil.asFileSearch(element);
if (file != null) {
processFileReferences(params, file);
return;
}
if (!(element instanceof FuncallExpression)) {
return;
}
FuncallExpression funcall = (FuncallExpression) element;
PsiFile localFile = element.getContainingFile();
if (localFile == null) {
return;
}
Label label = funcall.resolveBuildLabel();
if (label == null) {
searchForExternalWorkspace(params, localFile, funcall);
return;
}
List<String> stringsToSearch = LabelUtils.getAllValidLabelStrings(label, true);
for (String string : stringsToSearch) {
if (LabelUtils.isAbsolute(string)) {
searchForString(params, element, string);
} else {
// only a valid reference from local package -- restrict the search scope accordingly
SearchScope scope = limitScopeToFile(params.getScopeDeterminedByUser(), localFile);
if (scope != null) {
searchForString(params, scope, element, string);
}
}
}
}
Aggregations