Lines Matching full:binding
24 import static dagger.internal.codegen.binding.AssistedInjectionAnnotations.assistedInjectedConstruc…
25 import static dagger.internal.codegen.binding.InjectionAnnotations.injectedConstructors;
26 import static dagger.internal.codegen.binding.SourceFiles.generatedClassNameForBinding;
40 import dagger.internal.codegen.binding.Binding;
41 import dagger.internal.codegen.binding.BindingFactory;
42 import dagger.internal.codegen.binding.InjectBindingRegistry;
43 import dagger.internal.codegen.binding.KeyFactory;
44 import dagger.internal.codegen.binding.MembersInjectionBinding;
45 import dagger.internal.codegen.binding.ProvisionBinding;
82 final class BindingsCollection<B extends Binding> {
93 for (B binding = bindingsRequiringGeneration.poll(); in generateBindings()
94 binding != null; in generateBindings()
95 binding = bindingsRequiringGeneration.poll()) { in generateBindings()
96 checkState(!binding.unresolved().isPresent()); in generateBindings()
97 if (injectValidatorWhenGeneratingCode.isValidType(binding.key().type())) { in generateBindings()
98 generator.generate(binding); in generateBindings()
100 materializedBindingKeys.add(binding.key()); in generateBindings()
107 /** Returns a previously cached binding. */
112 /** Caches the binding and generates it if it needs generation. */
113 void tryRegisterBinding(B binding, boolean warnIfNotAlreadyGenerated) { in tryRegisterBinding() argument
114 tryToCacheBinding(binding); in tryRegisterBinding()
115 tryToGenerateBinding(binding, warnIfNotAlreadyGenerated); in tryRegisterBinding()
119 * Tries to generate a binding, not generating if it already is generated. For resolved
120 * bindings, this will try to generate the unresolved version of the binding.
122 void tryToGenerateBinding(B binding, boolean warnIfNotAlreadyGenerated) { in tryToGenerateBinding() argument
123 if (shouldGenerateBinding(binding)) { in tryToGenerateBinding()
124 bindingsRequiringGeneration.offer(binding); in tryToGenerateBinding()
133 types.erasure(binding.key().type()))); // erasure to strip <T> from msgs. in tryToGenerateBinding()
138 /** Returns true if the binding needs to be generated. */
139 private boolean shouldGenerateBinding(B binding) { in shouldGenerateBinding() argument
140 return !binding.unresolved().isPresent() in shouldGenerateBinding()
141 && !materializedBindingKeys.contains(binding.key()) in shouldGenerateBinding()
142 && !bindingsRequiringGeneration.contains(binding) in shouldGenerateBinding()
143 && elements.getTypeElement(generatedClassNameForBinding(binding)) == null; in shouldGenerateBinding()
146 /** Caches the binding for future lookups by key. */
147 private void tryToCacheBinding(B binding) { in tryToCacheBinding() argument
150 if (binding.unresolved().isPresent() in tryToCacheBinding()
151 || binding.bindingTypeElement().get().getTypeParameters().isEmpty()) { in tryToCacheBinding()
152 Key key = binding.key(); in tryToCacheBinding()
153 Binding previousValue = bindingsByKey.put(key, binding); in tryToCacheBinding()
154 checkState(previousValue == null || binding.equals(previousValue), in tryToCacheBinding()
156 binding, previousValue, key); in tryToCacheBinding()
197 * Registers the binding for generation and later lookup. If the binding is resolved, we also
200 private void registerBinding(ProvisionBinding binding, boolean warnIfNotAlreadyGenerated) { in registerBinding() argument
201 provisionBindings.tryRegisterBinding(binding, warnIfNotAlreadyGenerated); in registerBinding()
202 if (binding.unresolved().isPresent()) { in registerBinding()
203 provisionBindings.tryToGenerateBinding(binding.unresolved().get(), warnIfNotAlreadyGenerated); in registerBinding()
208 * Registers the binding for generation and later lookup. If the binding is resolved, we also
211 private void registerBinding(MembersInjectionBinding binding, boolean warnIfNotAlreadyGenerated) { in registerBinding() argument
223 !(injectedConstructors(binding.membersInjectedType()).isEmpty() in registerBinding()
224 && assistedInjectedConstructors(binding.membersInjectedType()).isEmpty()); in registerBinding()
227 ? !binding.injectionSites().isEmpty() in registerBinding()
228 : binding.hasLocalInjectionSites(); in registerBinding()
231 membersInjectionBindings.tryRegisterBinding(binding, warnIfNotAlreadyGenerated); in registerBinding()
232 if (binding.unresolved().isPresent()) { in registerBinding()
234 binding.unresolved().get(), warnIfNotAlreadyGenerated); in registerBinding()
259 ProvisionBinding binding = bindingFactory.injectionBinding(constructorElement, resolvedType); in tryRegisterConstructor() local
260 registerBinding(binding, warnIfNotAlreadyGenerated); in tryRegisterConstructor()
261 if (!binding.injectionSites().isEmpty()) { in tryRegisterConstructor()
264 return Optional.of(binding); in tryRegisterConstructor()
290 MembersInjectionBinding binding = bindingFactory.membersInjectionBinding(type, resolvedType); in tryRegisterMembersInjectedType() local
291 registerBinding(binding, warnIfNotAlreadyGenerated); in tryRegisterMembersInjectedType()
297 return Optional.of(binding); in tryRegisterMembersInjectedType()
309 ProvisionBinding binding = provisionBindings.getBinding(key); in getOrFindProvisionBinding() local
310 if (binding != null) { in getOrFindProvisionBinding()
311 return Optional.of(binding); in getOrFindProvisionBinding()
340 MembersInjectionBinding binding = membersInjectionBindings.getBinding(key); in getOrFindMembersInjectionBinding() local
341 if (binding != null) { in getOrFindMembersInjectionBinding()
342 return Optional.of(binding); in getOrFindMembersInjectionBinding()
357 .map(binding -> bindingFactory.membersInjectorBinding(key, binding)); in getOrFindMembersInjectorProvisionBinding()