1 /*
2  * Copyright (C) 2019 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.hilt.processor.internal;
18 
19 import static com.squareup.javapoet.ClassName.get;
20 
21 import com.squareup.javapoet.ClassName;
22 
23 /** Holder for commonly used class names. */
24 public final class ClassNames {
25   public static final ClassName ORIGINATING_ELEMENT =
26       get("dagger.hilt.codegen", "OriginatingElement");
27   public static final ClassName AGGREGATED_DEPS =
28       get("dagger.hilt.processor.internal.aggregateddeps", "AggregatedDeps");
29   public static final ClassName GENERATED_COMPONENT =
30       get("dagger.hilt.internal", "GeneratedComponent");
31   public static final ClassName GENERATED_COMPONENT_MANAGER =
32       get("dagger.hilt.internal", "GeneratedComponentManager");
33   public static final ClassName GENERATED_COMPONENT_MANAGER_HOLDER =
34       get("dagger.hilt.internal", "GeneratedComponentManagerHolder");
35   public static final ClassName IGNORE_MODULES =
36       get("dagger.hilt.android.testing", "UninstallModules");
37 
38   public static final ClassName DEFINE_COMPONENT = get("dagger.hilt", "DefineComponent");
39   public static final ClassName DEFINE_COMPONENT_BUILDER =
40       get("dagger.hilt", "DefineComponent", "Builder");
41   public static final ClassName DEFINE_COMPONENT_NO_PARENT =
42       get("dagger.hilt.internal.definecomponent", "DefineComponentNoParent");
43   public static final ClassName DEFINE_COMPONENT_CLASSES =
44       get("dagger.hilt.internal.definecomponent", "DefineComponentClasses");
45 
46   public static final ClassName ASSISTED_INJECT = get("dagger.assisted", "AssistedInject");
47   public static final ClassName BINDS =
48       get("dagger", "Binds");
49   public static final ClassName BINDS_OPTIONAL_OF =
50       get("dagger", "BindsOptionalOf");
51   public static final ClassName MODULE = get("dagger", "Module");
52   public static final ClassName MULTIBINDS =
53       get("dagger.multibindings", "Multibinds");
54   public static final ClassName INTO_MAP = get("dagger.multibindings", "IntoMap");
55   public static final ClassName INTO_SET = get("dagger.multibindings", "IntoSet");
56   public static final ClassName STRING_KEY = get("dagger.multibindings", "StringKey");
57   public static final ClassName PROVIDES =
58       get("dagger", "Provides");
59   public static final ClassName COMPONENT = get("dagger", "Component");
60   public static final ClassName COMPONENT_BUILDER = get("dagger", "Component", "Builder");
61   public static final ClassName SUBCOMPONENT = get("dagger", "Subcomponent");
62   public static final ClassName SUBCOMPONENT_BUILDER =
63       get("dagger", "Subcomponent", "Builder");
64   public static final ClassName PRODUCTION_COMPONENT =
65       get("dagger.producers", "ProductionComponent");
66 
67   public static final ClassName CONTRIBUTES_ANDROID_INJECTOR =
68       get("dagger.android", "ContributesAndroidInjector");
69 
70   public static final ClassName INJECT =
71       get("javax.inject", "Inject");
72   public static final ClassName QUALIFIER =
73       get("javax.inject", "Qualifier");
74   public static final ClassName SCOPE =
75       get("javax.inject", "Scope");
76   public static final ClassName PROVIDER = get("javax.inject", "Provider");
77   public static final ClassName DISABLE_INSTALL_IN_CHECK =
78       get("dagger.hilt.migration", "DisableInstallInCheck");
79   public static final ClassName ALIAS_OF = get("dagger.hilt.migration", "AliasOf");
80   public static final ClassName ALIAS_OF_PROPAGATED_DATA =
81       get("dagger.hilt.internal.aliasof", "AliasOfPropagatedData");
82 
83   public static final ClassName GENERATES_ROOT_INPUT = get("dagger.hilt", "GeneratesRootInput");
84   public static final ClassName GENERATES_ROOT_INPUT_PROPAGATED_DATA =
85       get("dagger.hilt.internal.generatesrootinput", "GeneratesRootInputPropagatedData");
86 
87   public static final ClassName ACTIVITY_SCOPED =
88       get("dagger.hilt.android.scopes", "ActivityScoped");
89   public static final ClassName FRAGMENT_SCOPED =
90       get("dagger.hilt.android.scopes", "FragmentScoped");
91   public static final ClassName SERVICE_SCOPED = get("dagger.hilt.android.scopes", "ServiceScoped");
92   public static final ClassName VIEW_SCOPED = get("dagger.hilt.android.scopes", "ViewScoped");
93 
94   public static final ClassName INSTALL_IN =
95       get("dagger.hilt", "InstallIn");
96   public static final ClassName TEST_INSTALL_IN = get("dagger.hilt.testing", "TestInstallIn");
97   public static final ClassName ENTRY_POINT =
98       get("dagger.hilt", "EntryPoint");
99   public static final ClassName ENTRY_POINTS = get("dagger.hilt", "EntryPoints");
100   public static final ClassName COMPONENT_ENTRY_POINT =
101       get("dagger.hilt.internal", "ComponentEntryPoint");
102   public static final ClassName GENERATED_ENTRY_POINT =
103       get("dagger.hilt.internal", "GeneratedEntryPoint");
104   public static final ClassName UNSAFE_CASTS = get("dagger.hilt.internal", "UnsafeCasts");
105   public static final ClassName ROOT_PROCESSOR =
106       get("dagger.hilt.processor.internal.root", "RootProcessor");
107 
108   public static final ClassName SINGLETON = get("javax.inject", "Singleton");
109 
110   // TODO(erichang): Move these class names out when we factor out the android portion
111   public static final ClassName APPLICATION = get("android.app", "Application");
112   public static final ClassName MULTI_DEX_APPLICATION =
113       get("androidx.multidex", "MultiDexApplication");
114   public static final ClassName ANDROID_ENTRY_POINT =
115       get("dagger.hilt.android", "AndroidEntryPoint");
116   public static final ClassName HILT_ANDROID_APP =
117       get("dagger.hilt.android", "HiltAndroidApp");
118   public static final ClassName CONTEXT = get("android.content", "Context");
119   public static final ClassName APPLICATION_PROVIDER =
120       get("androidx.test.core.app", "ApplicationProvider");
121   public static final ClassName COMPONENT_SUPPLIER =
122       get("dagger.hilt.android.internal.managers", "ComponentSupplier");
123   public static final ClassName APPLICATION_CONTEXT_MODULE =
124       get("dagger.hilt.android.internal.modules", "ApplicationContextModule");
125   public static final ClassName INTERNAL_TEST_ROOT =
126       get("dagger.hilt.android.internal.testing", "InternalTestRoot");
127   public static final ClassName TEST_INJECTOR =
128       get("dagger.hilt.android.internal.testing", "TestInjector");
129   public static final ClassName TEST_APPLICATION_INJECTOR =
130       get("dagger.hilt.android.internal.testing", "TestApplicationInjector");
131   public static final ClassName TEST_APPLICATION_COMPONENT_MANAGER =
132       get("dagger.hilt.android.internal.testing", "TestApplicationComponentManager");
133   public static final ClassName TEST_APPLICATION_COMPONENT_MANAGER_HOLDER =
134       get("dagger.hilt.android.internal.testing", "TestApplicationComponentManagerHolder");
135   public static final ClassName TEST_INSTANCE_HOLDER =
136       get("dagger.hilt.android.internal.testing", "TestInstanceHolder");
137   public static final ClassName HILT_ANDROID_TEST =
138       get("dagger.hilt.android.testing", "HiltAndroidTest");
139   public static final ClassName CUSTOM_TEST_APPLICATION =
140       get("dagger.hilt.android.testing", "CustomTestApplication");
141   public static final ClassName ON_COMPONENT_READY_RUNNER =
142       get("dagger.hilt.android.testing", "OnComponentReadyRunner");
143   public static final ClassName ON_COMPONENT_READY_RUNNER_HOLDER =
144       get("dagger.hilt.android.testing", "OnComponentReadyRunner", "OnComponentReadyRunnerHolder");
145   public static final ClassName ANDROID_BIND_VALUE =
146       get("dagger.hilt.android.testing", "BindValue");
147   public static final ClassName ANDROID_BIND_ELEMENTS_INTO_SET =
148       get("dagger.hilt.android.testing", "BindElementsIntoSet");
149   public static final ClassName ANDROID_BIND_VALUE_INTO_MAP =
150       get("dagger.hilt.android.testing", "BindValueIntoMap");
151   public static final ClassName ANDROID_BIND_VALUE_INTO_SET =
152       get("dagger.hilt.android.testing", "BindValueIntoSet");
153   public static final ClassName APPLICATION_CONTEXT =
154       get("dagger.hilt.android.qualifiers", "ApplicationContext");
155   public static final ClassName TEST_COMPONENT_DATA =
156       get("dagger.hilt.android.internal.testing", "TestComponentData");
157   public static final ClassName TEST_COMPONENT_DATA_SUPPLIER =
158       get("dagger.hilt.android.internal.testing", "TestComponentDataSupplier");
159 
160   public static final ClassName CLASS = get("java.lang", "Class");
161   public static final ClassName LIST = get("java.util", "List");
162   public static final ClassName SET = get("java.util", "Set");
163   public static final ClassName MAP = get("java.util", "Map");
164   public static final ClassName HASH_MAP = get("java.util", "HashMap");
165   public static final ClassName HASH_SET = get("java.util", "HashSet");
166   public static final ClassName COLLECTIONS = get("java.util", "Collections");
167   public static final ClassName ARRAYS = get("java.util", "Arrays");
168 
169   // Standard components
170   public static final ClassName SINGLETON_COMPONENT =
171       get("dagger.hilt.components", "SingletonComponent");
172   public static final ClassName ACTIVITY_COMPONENT =
173       get("dagger.hilt.android.components", "ActivityComponent");
174 
175   public static final ClassName PRECONDITIONS = get("dagger.hilt.internal", "Preconditions");
176 
177   public static final ClassName OBJECT = get("java.lang", "Object");
178 
179   // Kotlin-specific class names
180   public static final ClassName KOTLIN_METADATA = get("kotlin", "Metadata");
181 
ClassNames()182   private ClassNames() {}
183 }
184