diff --git a/compiler/src/main/java/dagger/internal/codegen/MapKeys.java b/compiler/src/main/java/dagger/internal/codegen/MapKeys.java index 46ab6c2e9f0..17643d2d118 100644 --- a/compiler/src/main/java/dagger/internal/codegen/MapKeys.java +++ b/compiler/src/main/java/dagger/internal/codegen/MapKeys.java @@ -48,7 +48,7 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.transform; import static dagger.internal.codegen.CodeBlocks.makeParametersCodeBlock; -import static dagger.internal.codegen.SourceFiles.canonicalName; +import static dagger.internal.codegen.SourceFiles.classFileName; import static javax.lang.model.util.ElementFilter.methodsIn; /** @@ -138,7 +138,7 @@ public DeclaredType visitDeclared(DeclaredType t, Void p) { */ public static ClassName getMapKeyCreatorClassName(TypeElement mapKeyType) { ClassName mapKeyTypeName = ClassName.get(mapKeyType); - return mapKeyTypeName.topLevelClassName().peerClass(canonicalName(mapKeyTypeName) + "Creator"); + return mapKeyTypeName.topLevelClassName().peerClass(classFileName(mapKeyTypeName) + "Creator"); } /** diff --git a/compiler/src/main/java/dagger/internal/codegen/SourceFiles.java b/compiler/src/main/java/dagger/internal/codegen/SourceFiles.java index ab7c6493791..e7885d99bd9 100644 --- a/compiler/src/main/java/dagger/internal/codegen/SourceFiles.java +++ b/compiler/src/main/java/dagger/internal/codegen/SourceFiles.java @@ -49,7 +49,6 @@ class SourceFiles { private static final Joiner CLASS_FILE_NAME_JOINER = Joiner.on('_'); - private static final Joiner CANONICAL_NAME_JOINER = Joiner.on('$'); /** * Sorts {@link DependencyRequest} instances in an order likely to reflect their logical @@ -159,7 +158,7 @@ static ClassName generatedClassNameForBinding(Binding binding) { return enclosingClassName .topLevelClassName() .peerClass( - canonicalName(enclosingClassName) + classFileName(enclosingClassName) + "_" + factoryPrefix(contribution) + "Factory"); @@ -239,15 +238,6 @@ static ClassName membersInjectorNameForType(TypeElement typeElement) { return siblingClassName(typeElement, "_MembersInjector"); } - /** - * @deprecated prefer {@link #classFileName(ClassName)} instead and avoid dollar signs in - * generated source. - */ - @Deprecated - static String canonicalName(ClassName className) { - return CANONICAL_NAME_JOINER.join(className.simpleNames()); - } - static String classFileName(ClassName className) { return CLASS_FILE_NAME_JOINER.join(className.simpleNames()); } @@ -265,7 +255,7 @@ static ClassName generatedProductionExecutorModuleName(TypeElement componentElem // which could use this. private static ClassName siblingClassName(TypeElement typeElement, String suffix) { ClassName className = ClassName.get(typeElement); - return className.topLevelClassName().peerClass(canonicalName(className) + suffix); + return className.topLevelClassName().peerClass(classFileName(className) + suffix); } private static String factoryPrefix(ContributionBinding binding) { diff --git a/compiler/src/test/java/dagger/internal/codegen/ComponentProcessorTest.java b/compiler/src/test/java/dagger/internal/codegen/ComponentProcessorTest.java index 3e0d2b003ef..a9ff10681c6 100644 --- a/compiler/src/test/java/dagger/internal/codegen/ComponentProcessorTest.java +++ b/compiler/src/test/java/dagger/internal/codegen/ComponentProcessorTest.java @@ -378,12 +378,12 @@ public class ComponentProcessorTest { " @SuppressWarnings(\"unchecked\")", " private void initialize(final Builder builder) {", " this.bMembersInjector =", - " OuterType$B_MembersInjector.create(OuterType$A_Factory.create());", + " OuterType_B_MembersInjector.create(OuterType_A_Factory.create());", " }", "", " @Override", " public OuterType.A a() {", - " return OuterType$A_Factory.create().get();", + " return OuterType_A_Factory.create().get();", " }", "", " @Override", diff --git a/compiler/src/test/java/dagger/internal/codegen/InjectConstructorFactoryGeneratorTest.java b/compiler/src/test/java/dagger/internal/codegen/InjectConstructorFactoryGeneratorTest.java index 2c4643ad5bc..ccfd6117e05 100644 --- a/compiler/src/test/java/dagger/internal/codegen/InjectConstructorFactoryGeneratorTest.java +++ b/compiler/src/test/java/dagger/internal/codegen/InjectConstructorFactoryGeneratorTest.java @@ -1205,14 +1205,14 @@ public void noDeps() { " }", "}"); JavaFileObject aFactory = JavaFileObjects.forSourceLines( - "test.OuterType$A_Factory", + "test.OuterType_A_Factory", "package test;", "", "import dagger.internal.Factory;", "import javax.annotation.Generated;", "", GENERATED_ANNOTATION, - "public enum OuterType$A_Factory implements Factory {", + "public enum OuterType_A_Factory implements Factory {", " INSTANCE;", "", " @Override public OuterType.A get() {", diff --git a/compiler/src/test/java/dagger/internal/codegen/MapKeyProcessorTest.java b/compiler/src/test/java/dagger/internal/codegen/MapKeyProcessorTest.java index bd1cc483fe6..388a26ad0f6 100644 --- a/compiler/src/test/java/dagger/internal/codegen/MapKeyProcessorTest.java +++ b/compiler/src/test/java/dagger/internal/codegen/MapKeyProcessorTest.java @@ -100,20 +100,20 @@ public void nestedMapKeyCreatorFile() { "}"); JavaFileObject generatedKeyCreator = JavaFileObjects.forSourceLines( - "test.Container$PathKeyCreator", + "test.Container_PathKeyCreator", "package test;", "", "import com.google.auto.value.AutoAnnotation;", "import javax.annotation.Generated;", "", GENERATED_ANNOTATION, - "public final class Container$PathKeyCreator {", - " private Container$PathKeyCreator() {}", + "public final class Container_PathKeyCreator {", + " private Container_PathKeyCreator() {}", "", " @AutoAnnotation", " public static Container.PathKey createPathKey(" + "PathEnum value, String relativePath) {", - " return new AutoAnnotation_Container$PathKeyCreator_createPathKey(", + " return new AutoAnnotation_Container_PathKeyCreator_createPathKey(", " value, relativePath);", " }", "}"); diff --git a/compiler/src/test/java/dagger/internal/codegen/MembersInjectionTest.java b/compiler/src/test/java/dagger/internal/codegen/MembersInjectionTest.java index 5443aac0117..b14e913deff 100644 --- a/compiler/src/test/java/dagger/internal/codegen/MembersInjectionTest.java +++ b/compiler/src/test/java/dagger/internal/codegen/MembersInjectionTest.java @@ -737,7 +737,7 @@ public void simpleComponentWithNesting() { " }", "}"); JavaFileObject bMembersInjector = JavaFileObjects.forSourceLines( - "test.OuterType$B_MembersInjector", + "test.OuterType_B_MembersInjector", "package test;", "", "import dagger.MembersInjector;", @@ -745,16 +745,17 @@ public void simpleComponentWithNesting() { "import javax.inject.Provider;", "", GENERATED_ANNOTATION, - "public final class OuterType$B_MembersInjector implements MembersInjector {", + "public final class OuterType_B_MembersInjector", + " implements MembersInjector {", " private final Provider aProvider;", "", - " public OuterType$B_MembersInjector(Provider aProvider) {", + " public OuterType_B_MembersInjector(Provider aProvider) {", " assert aProvider != null;", " this.aProvider = aProvider;", " }", "", " public static MembersInjector create(Provider aProvider) {", - " return new OuterType$B_MembersInjector(aProvider);", + " return new OuterType_B_MembersInjector(aProvider);", " }", "", " @Override", @@ -802,7 +803,7 @@ public void componentWithNestingAndGeneratedType() { "}"); JavaFileObject bMembersInjector = JavaFileObjects.forSourceLines( - "test.OuterType$B_MembersInjector", + "test.OuterType_B_MembersInjector", "package test;", "", "import dagger.MembersInjector;", @@ -810,16 +811,17 @@ public void componentWithNestingAndGeneratedType() { "import javax.inject.Provider;", "", GENERATED_ANNOTATION, - "public final class OuterType$B_MembersInjector implements MembersInjector {", + "public final class OuterType_B_MembersInjector", + " implements MembersInjector {", " private final Provider aProvider;", "", - " public OuterType$B_MembersInjector(Provider aProvider) {", + " public OuterType_B_MembersInjector(Provider aProvider) {", " assert aProvider != null;", " this.aProvider = aProvider;", " }", "", " public static MembersInjector create(Provider aProvider) {", - " return new OuterType$B_MembersInjector(aProvider);", + " return new OuterType_B_MembersInjector(aProvider);", " }", "", " @Override", diff --git a/compiler/src/test/java/dagger/internal/codegen/ProductionComponentProcessorTest.java b/compiler/src/test/java/dagger/internal/codegen/ProductionComponentProcessorTest.java index b494e9d88c2..1b62f487554 100644 --- a/compiler/src/test/java/dagger/internal/codegen/ProductionComponentProcessorTest.java +++ b/compiler/src/test/java/dagger/internal/codegen/ProductionComponentProcessorTest.java @@ -241,22 +241,22 @@ public void simpleComponent() { " @SuppressWarnings(\"unchecked\")", " private void initialize(final Builder builder) {", " this.executorProvider =", - " TestClass$BModule_ExecutorFactory.create(builder.bModule);", + " TestClass_BModule_ExecutorFactory.create(builder.bModule);", " this.executorProvider2 =", " DoubleCheck.provider(", - " TestClass$SimpleComponent_ProductionExecutorModule_ExecutorFactory.create(", - " executorProvider));", + " TestClass_SimpleComponent_ProductionExecutorModule_ExecutorFactory", + " .create(executorProvider));", " this.simpleComponentProvider =", " InstanceFactory.create(this);", " this.monitorProvider =", " DoubleCheck.provider(", - " TestClass$SimpleComponent_MonitoringModule_MonitorFactory.create(", + " TestClass_SimpleComponent_MonitoringModule_MonitorFactory.create(", " simpleComponentProvider,", " SetFactory.create());", - " this.bProvider = TestClass$BModule_BFactory.create(", - " builder.bModule, TestClass$C_Factory.create());", + " this.bProvider = TestClass_BModule_BFactory.create(", + " builder.bModule, TestClass_C_Factory.create());", " this.bProducer = Producers.producerFromProvider(bProvider);", - " this.aProducer = new TestClass$AModule_AFactory(", + " this.aProducer = new TestClass_AModule_AFactory(", " builder.aModule,", " executorProvider2,", " monitorProvider,", @@ -296,18 +296,18 @@ public void simpleComponent() { " }", "", " @Deprecated", - " public Builder testClass$SimpleComponent_MonitoringModule(", - " TestClass$SimpleComponent_MonitoringModule", - " testClass$SimpleComponent_MonitoringModule) {", - " Preconditions.checkNotNull(testClass$SimpleComponent_MonitoringModule);", + " public Builder testClass_SimpleComponent_MonitoringModule(", + " TestClass_SimpleComponent_MonitoringModule", + " testClass_SimpleComponent_MonitoringModule) {", + " Preconditions.checkNotNull(testClass_SimpleComponent_MonitoringModule);", " return this;", " }", "", " @Deprecated", - " public Builder testClass$SimpleComponent_ProductionExecutorModule(", - " TestClass$SimpleComponent_ProductionExecutorModule", - " testClass$SimpleComponent_ProductionExecutorModule) {", - " Preconditions.checkNotNull(testClass$SimpleComponent_ProductionExecutorModule);", + " public Builder testClass_SimpleComponent_ProductionExecutorModule(", + " TestClass_SimpleComponent_ProductionExecutorModule", + " testClass_SimpleComponent_ProductionExecutorModule) {", + " Preconditions.checkNotNull(testClass_SimpleComponent_ProductionExecutorModule);", " return this;", " }", "}"); diff --git a/core/src/main/java/dagger/Binds.java b/core/src/main/java/dagger/Binds.java index 78b9a7fec08..4bdb3e2bae1 100644 --- a/core/src/main/java/dagger/Binds.java +++ b/core/src/main/java/dagger/Binds.java @@ -25,13 +25,13 @@ /** * Annotates abstract methods of a {@link Module} that delegate bindings. For example, to * bind {@link java.util.Random} to {@link java.security.SecureRandom} a module could declare the - * following: {@code @Bind abstract Random bindRandom(SecureRandom secureRandom);} + * following: {@code @Binds abstract Random bindRandom(SecureRandom secureRandom);} * - *

{@code @Bind} methods are a drop-in replacement for {@link Provides} methods that simply - * return an injected parameter. Prefer {@code @Bind} because the generated implementation is + *

{@code @Binds} methods are a drop-in replacement for {@link Provides} methods that simply + * return an injected parameter. Prefer {@code @Binds} because the generated implementation is * likely to be more efficient. * - *

A {@code @Bind} method: + *

A {@code @Binds} method: *

    *
  • Must be {@code abstract}. *
  • Must have a single parameter whose type is assignable to the return type. The return type is diff --git a/pom.xml b/pom.xml index dde2b225db3..91692ec3a5e 100644 --- a/pom.xml +++ b/pom.xml @@ -53,7 +53,7 @@ 1.2 2.0.8 19.0 - 0.1-alpha + 1.0