• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.android.processor;
18 
19 import androidx.room.compiler.processing.XProcessingEnv;
20 import androidx.room.compiler.processing.XProcessingEnvConfig;
21 import androidx.room.compiler.processing.XProcessingStep;
22 import com.google.common.collect.ImmutableList;
23 import dagger.BindsInstance;
24 import dagger.Component;
25 import javax.inject.Singleton;
26 
27 /** An implementation of Dagger Android processor that is shared between Javac and KSP. */
28 final class DelegateAndroidProcessor {
29   static final XProcessingEnvConfig PROCESSING_ENV_CONFIG =
30       new XProcessingEnvConfig.Builder().build();
31   static final String FLAG_EXPERIMENTAL_USE_STRING_KEYS =
32       "dagger.android.experimentalUseStringKeys";
33 
34   private XProcessingEnv env;
35 
initialize(XProcessingEnv env)36   public void initialize(XProcessingEnv env) {
37     this.env = env;
38   }
39 
processingSteps()40   public ImmutableList<XProcessingStep> processingSteps() {
41     return ImmutableList.of(
42         new AndroidMapKeyProcessingStep(env), new ContributesAndroidInjectorProcessingStep(env));
43   }
44 
45   @Singleton
46   @Component
47   interface Injector {
inject(DelegateAndroidProcessor delegateAndroidProcessor)48     void inject(DelegateAndroidProcessor delegateAndroidProcessor);
49 
50     @Component.Factory
51     interface Factory {
create(@indsInstance XProcessingEnv env)52       Injector create(@BindsInstance XProcessingEnv env);
53     }
54   }
55 }
56