use of com.google.devtools.build.lib.query2.engine.QueryEnvironment.TargetNotFoundException in project bazel by bazelbuild.
the class BlazeTargetAccessor method getLabelListAttr.
@Override
public List<Target> getLabelListAttr(QueryExpression caller, Target target, String attrName, String errorMsgPrefix) throws QueryException, InterruptedException {
Preconditions.checkArgument(target instanceof Rule);
List<Target> result = new ArrayList<>();
Rule rule = (Rule) target;
AggregatingAttributeMapper attrMap = AggregatingAttributeMapper.of(rule);
Type<?> attrType = attrMap.getAttributeType(attrName);
if (attrType == null) {
// Return an empty list if the attribute isn't defined for this rule.
return ImmutableList.of();
}
for (Label label : attrMap.getReachableLabels(attrName, false)) {
try {
result.add(queryEnvironment.getTarget(label));
} catch (TargetNotFoundException e) {
queryEnvironment.reportBuildFileError(caller, errorMsgPrefix + e.getMessage());
}
}
return result;
}
Aggregations