示例#1
0
 // CAUTION: keep in sync with ConfiguredTargetFactory#convertVisibility()
 private void convertVisibility(
     ImmutableSet.Builder<QueryVisibility<Target>> packageSpecifications, Target target)
     throws QueryException {
   RuleVisibility ruleVisibility = target.getVisibility();
   if (ruleVisibility instanceof ConstantRuleVisibility) {
     if (((ConstantRuleVisibility) ruleVisibility).isPubliclyVisible()) {
       packageSpecifications.add(QueryVisibility.<Target>everything());
     }
     return;
   } else if (ruleVisibility instanceof PackageGroupsRuleVisibility) {
     PackageGroupsRuleVisibility packageGroupsVisibility =
         (PackageGroupsRuleVisibility) ruleVisibility;
     for (Label groupLabel : packageGroupsVisibility.getPackageGroups()) {
       try {
         convertGroupVisibility(
             (PackageGroup) queryEnvironment.getTarget(groupLabel), packageSpecifications);
       } catch (TargetNotFoundException e) {
         throw new QueryException(e.getMessage());
       }
     }
     for (PackageSpecification spec : packageGroupsVisibility.getDirectPackages()) {
       packageSpecifications.add(new BlazeQueryVisibility(spec));
     }
     return;
   } else {
     throw new IllegalStateException("unknown visibility: " + ruleVisibility.getClass());
   }
 }
示例#2
0
 @Override
 public Set<QueryVisibility<Target>> getVisibility(Target target) throws QueryException {
   ImmutableSet.Builder<QueryVisibility<Target>> result = ImmutableSet.builder();
   result.add(QueryVisibility.samePackage(target, this));
   convertVisibility(result, target);
   return result.build();
 }