Пример #1
0
  private ImmutableSet<AspectWithParameters> requiredAspects(
      AspectDefinition aspectDefinition,
      AspectParameters aspectParameters,
      Attribute attribute,
      Target target,
      Rule originalRule) {
    if (!(target instanceof Rule)) {
      return ImmutableSet.of();
    }

    Set<AspectWithParameters> aspectCandidates =
        extractAspectCandidates(aspectDefinition, aspectParameters, attribute, originalRule);
    RuleClass ruleClass = ((Rule) target).getRuleClassObject();
    ImmutableSet.Builder<AspectWithParameters> result = ImmutableSet.builder();
    for (AspectWithParameters candidateClass : aspectCandidates) {
      ConfiguredAspectFactory candidate =
          (ConfiguredAspectFactory) AspectFactory.Util.create(candidateClass.getAspectFactory());
      if (Sets.difference(
              candidate.getDefinition().getRequiredProviders(), ruleClass.getAdvertisedProviders())
          .isEmpty()) {
        result.add(candidateClass);
      }
    }
    return result.build();
  }
Пример #2
0
  @Override
  public ImmutableMultimap<Attribute, Label> computeAspectDependencies(Target target)
      throws InterruptedException {
    if (!(target instanceof Rule)) {
      return ImmutableMultimap.of();
    }

    Multimap<Attribute, Label> result = LinkedHashMultimap.create();
    for (Attribute attribute : ((Rule) target).getAttributes()) {
      for (Class<? extends AspectFactory<?, ?, ?>> aspectFactory : attribute.getAspects()) {
        AspectDefinition.addAllAttributesOfAspect(
            (Rule) target,
            result,
            AspectFactory.Util.create(aspectFactory).getDefinition(),
            Rule.ALL_DEPS);
      }
    }

    return ImmutableMultimap.copyOf(result);
  }