1 /* 2 * Copyright (C) 2018 The Dagger Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dagger.internal.codegen.bindinggraphvalidation; 18 19 import com.google.common.collect.ImmutableSet; 20 import dagger.Module; 21 import dagger.Provides; 22 import dagger.internal.codegen.compileroption.CompilerOptions; 23 import dagger.internal.codegen.validation.CompositeBindingGraphPlugin; 24 import dagger.internal.codegen.validation.Validation; 25 import dagger.spi.model.BindingGraphPlugin; 26 27 /** Binds the set of {@link BindingGraphPlugin}s used to implement Dagger validation. */ 28 @Module 29 public interface BindingGraphValidationModule { 30 31 @Provides 32 @Validation providePlugins( CompositeBindingGraphPlugin.Factory factory, CompilerOptions compilerOptions, DependencyCycleValidator validation1, DependsOnProductionExecutorValidator validation2, DuplicateBindingsValidator validation3, IncompatiblyScopedBindingsValidator validation4, InjectBindingValidator validation5, MapMultibindingValidator validation6, MissingBindingValidator validation7, NullableBindingValidator validation8, ProvisionDependencyOnProducerBindingValidator validation9, SetMultibindingValidator validation10, SubcomponentFactoryMethodValidator validation11)33 static ImmutableSet<BindingGraphPlugin> providePlugins( 34 CompositeBindingGraphPlugin.Factory factory, 35 CompilerOptions compilerOptions, 36 DependencyCycleValidator validation1, 37 DependsOnProductionExecutorValidator validation2, 38 DuplicateBindingsValidator validation3, 39 IncompatiblyScopedBindingsValidator validation4, 40 InjectBindingValidator validation5, 41 MapMultibindingValidator validation6, 42 MissingBindingValidator validation7, 43 NullableBindingValidator validation8, 44 ProvisionDependencyOnProducerBindingValidator validation9, 45 SetMultibindingValidator validation10, 46 SubcomponentFactoryMethodValidator validation11) { 47 ImmutableSet<BindingGraphPlugin> plugins = ImmutableSet.of( 48 validation1, 49 validation2, 50 validation3, 51 validation4, 52 validation5, 53 validation6, 54 validation7, 55 validation8, 56 validation9, 57 validation10, 58 validation11); 59 if (compilerOptions.experimentalDaggerErrorMessages()) { 60 return ImmutableSet.of(factory.create(plugins, "Dagger/Validation")); 61 } else { 62 return plugins; 63 } 64 } 65 } 66