aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
diff options
context:
space:
mode:
authorGravatar Luis Fernando Pino Duque <lpino@google.com>2016-04-26 16:22:38 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-04-27 11:47:20 +0000
commite82713de767ea4f002f49ba75427698989c47edd (patch)
tree96ce693a26e062bda56e79435a655441569773fc /src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
parent8b999982958d9b63321e6295f5a66d0d2ce7c925 (diff)
Delete the interface NativeAspectFactory and make native aspects extend from NativeAspectClass.
This a large refactoring of the aspects, currently we have the following: - AspectClasses: The interface AspectClass is a implemented by either SkylarkAspectClass or NativeAspectClass<NativeAspectFactory>. They are wrappers for the AspectFactories and they hold the information about the Class<> of the factory. - AspectFactories (FooAspect.java): Represented by the interfaces ConfiguredAspectFactory and NativeAspectFactory, also by the interface ConfiguredNativeAspectFactory which is the union of the two aforementioned interfaces. All aspects implement ConfiguredNativeAspectFactory except Skylark aspects which implement only ConfiguredAspectFactory. After this CL the distinction between NativeAspectFactories and NativeAspectClasses dissappear, namely aspect that extends NativeAspectClass is considered native and if it implements ConfiguredAspectFactory it is configured. Therefore the interfaces NativeAspectFactory and ConfiguredNativeAspectFactory both disappear. With this refactoring the aspectFactoryMap in the ConfiguredRuleClassProvider changes its type from (String -> Class<? extends NativeAspectClass>) to (String -> NativeAspectClass) which means it is now able to have an instance of the aspect instead of its Class only. By doing this, it is now possible to pass parameters when creating an aspect in the ConfiguredRuleClassProvider. -- MOS_MIGRATED_REVID=120819647
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java b/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
index be1bd0bb6f..c9b8a3b3a8 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
@@ -23,7 +23,6 @@ import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.packages.ConfigurationFragmentPolicy.MissingFragmentPolicy;
-import com.google.devtools.build.lib.packages.NativeAspectClass.NativeAspectFactory;
import com.google.devtools.build.lib.util.Preconditions;
import java.util.Collection;
@@ -249,13 +248,10 @@ public final class AspectDefinition {
* but we cannot reference that interface here.
*/
@SafeVarargs
- public final Builder attributeAspect(
- String attribute, Class<? extends NativeAspectFactory>... aspectFactories) {
+ public final Builder attributeAspect(String attribute, NativeAspectClass... aspectClasses) {
Preconditions.checkNotNull(attribute);
- for (Class<? extends NativeAspectFactory> aspectFactory : aspectFactories) {
- this
- .attributeAspect(
- attribute, new NativeAspectClass<>(Preconditions.checkNotNull(aspectFactory)));
+ for (NativeAspectClass aspectClass : aspectClasses) {
+ this.attributeAspect(attribute, Preconditions.checkNotNull(aspectClass));
}
return this;
}