• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.componentgenerator;
18 
19 import dagger.Binds;
20 import dagger.Module;
21 import dagger.internal.codegen.base.SourceFileGenerator;
22 import dagger.internal.codegen.binding.BindingGraph;
23 import dagger.internal.codegen.binding.ComponentDescriptor;
24 
25 /** Provides bindings needed to generated the component. */
26 @Module(subcomponents = TopLevelImplementationComponent.class)
27 public interface ComponentGeneratorModule {
28 
29   @Binds
componentGenerator(ComponentGenerator generator)30   abstract SourceFileGenerator<BindingGraph> componentGenerator(ComponentGenerator generator);
31 
32   // The HjarSourceFileGenerator wrapper first generates the entire TypeSpec before stripping out
33   // things that aren't needed for the hjar. However, this can be really expensive for the component
34   // because it is usually the most expensive file to generate, and most of its content is not
35   // needed in the hjar. Thus, instead of wrapping the ComponentGenerator in HjarSourceFileGenerator
36   // we provide a completely separate processing step, ComponentHjarProcessingStep, and generator,
37   // ComponentHjarGenerator, for when generating hjars for components, which can avoid generating
38   // the parts of the component that would have been stripped out by the HjarSourceFileGenerator.
39   @Binds
componentHjarGenerator( ComponentHjarGenerator hjarGenerator)40   abstract SourceFileGenerator<ComponentDescriptor> componentHjarGenerator(
41       ComponentHjarGenerator hjarGenerator);
42 }
43