Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ private static ImmutableMap<ComponentPath, String> disambiguateConflictingSimple
UniqueNameSet nameSet = new UniqueNameSet();
ImmutableMap.Builder<ComponentPath, String> uniqueNames = ImmutableMap.builder();
for (ComponentPath componentPath : componentsWithConflictingNames) {
if (componentPath.atRoot()) {
uniqueNames.put(componentPath, simpleName(componentPath));
continue;
}
String simpleName = simpleName(componentPath);
String basePrefix = uniquingPrefix(componentPath);
uniqueNames.put(
Expand All @@ -181,7 +185,9 @@ private static ImmutableMap<ComponentPath, String> disambiguateConflictingSimple
}

private static String simpleName(ComponentPath componentPath) {
return getSimpleName(componentPath.currentComponent().xprocessing());
return componentPath.atRoot()
? ""
: getSimpleName(componentPath.currentComponent().xprocessing());
}

/** Returns a prefix that could make the component's simple name more unique. */
Expand Down
3 changes: 1 addition & 2 deletions javatests/dagger/functional/cycle/LongCycleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public void longCycleHasMoreThanOneInitializeMethod() throws Exception {
ClassName componentImpl =
System.getProperty("dagger.mode").contains("ExtendsComponent")
? ClassName.get(DaggerLongCycle_LongCycleComponent.class)
: ClassName.get(DaggerLongCycle_LongCycleComponent.class)
.nestedClass("LongCycleComponentImpl");
: ClassName.get(DaggerLongCycle_LongCycleComponent.class).nestedClass("Impl");
boolean hasInitialize2 =
stream(
DaggerLongCycle_LongCycleComponent.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.google.common.truth.Truth.assertThat
import com.google.common.truth.TruthJUnit.assume
import com.squareup.javapoet.ClassName
import java.lang.reflect.Method
import java.util.Arrays
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
Expand Down
2 changes: 1 addition & 1 deletion javatests/dagger/hilt/android/MultiTestRoot1Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void testMissingMultiTestRoot2EntryPoint() throws Exception {
.hasMessageThat()
.isEqualTo(
"Cannot cast dagger.hilt.android.internal.testing.root."
+ "DaggerMultiTestRoot1Test_HiltComponents_SingletonC$SingletonCImpl"
+ "DaggerMultiTestRoot1Test_HiltComponents_SingletonC$Impl"
+ " to dagger.hilt.android.MultiTestRoot2Test$BarEntryPoint");
}

Expand Down
2 changes: 1 addition & 1 deletion javatests/dagger/hilt/android/MultiTestRoot2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public void testMissingMultiTestRoot1EntryPoint() throws Exception {
.hasMessageThat()
.isEqualTo(
"Cannot cast dagger.hilt.android.internal.testing.root."
+ "DaggerMultiTestRoot2Test_HiltComponents_SingletonC$SingletonCImpl"
+ "DaggerMultiTestRoot2Test_HiltComponents_SingletonC$Impl"
+ " to dagger.hilt.android.MultiTestRoot1Test$BarEntryPoint");
}

Expand Down
6 changes: 3 additions & 3 deletions javatests/dagger/hilt/android/UsesComponentHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class UsesComponentHelper {

public static String defaultComponentName() {
return "dagger.hilt.android.internal.testing.root."
+ "DaggerDefault_HiltComponents_SingletonC$SingletonCImpl";
+ "DaggerDefault_HiltComponents_SingletonC$Impl";
}

/**
Expand All @@ -33,7 +33,7 @@ public static String defaultComponentName() {
public static String perTestComponentName(Object testInstance) {
return "dagger.hilt.android.internal.testing.root.Dagger"
+ testInstance.getClass().getSimpleName()
+ "_HiltComponents_SingletonC$SingletonCImpl";
+ "_HiltComponents_SingletonC$Impl";
}

/**
Expand All @@ -45,7 +45,7 @@ public static String perTestComponentNameWithDedupePrefix(
return "dagger.hilt.android.internal.testing.root.Dagger"
+ expectedPrefix
+ testInstance.getClass().getSimpleName()
+ "_HiltComponents_SingletonC$SingletonCImpl";
+ "_HiltComponents_SingletonC$Impl";
}

private UsesComponentHelper() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

Foo_Factory fooProvider;

Provider<FooFactory> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

Provider<Bar> barProvider;

Provider<FooFactory> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

}

@SuppressWarnings("unchecked")
private void initialize() {
this.barProvider = new SwitchingProvider<>(testComponentImpl, 1);
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<FooFactory>(testComponentImpl, 0));
this.barProvider = new SwitchingProvider<>(impl, 1);
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<FooFactory>(impl, 0));
}

@Override
Expand All @@ -65,12 +65,12 @@ final class DaggerTestComponent {
}

private static final class SwitchingProvider<T> implements Provider<T> {
private final TestComponentImpl testComponentImpl;
private final Impl impl;

private final int id;

SwitchingProvider(TestComponentImpl testComponentImpl, int id) {
this.testComponentImpl = testComponentImpl;
SwitchingProvider(Impl impl, int id) {
this.impl = impl;
this.id = id;
}

Expand All @@ -81,8 +81,8 @@ final class DaggerTestComponent {
case 0: // test.FooFactory
return (T) new FooFactory() {
@Override
public Foo create(String testComponentImpl2) {
return new Foo(testComponentImpl2, testComponentImpl.barProvider);
public Foo create(String testComponentImpl) {
return new Foo(testComponentImpl, impl.barProvider);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

Foo_Factory fooProvider;

Expand All @@ -49,7 +49,7 @@ final class DaggerTestComponent {
*/
Provider<?> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

/**
* {@code Provider<Bar>}
Expand All @@ -53,16 +53,16 @@ final class DaggerTestComponent {
*/
Provider<?> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

}

@SuppressWarnings("unchecked")
private void initialize() {
this.barProvider = new SwitchingProvider<>(testComponentImpl, 1);
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<>(testComponentImpl, 0));
this.barProvider = new SwitchingProvider<>(impl, 1);
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<>(impl, 0));
}

@Override
Expand All @@ -71,12 +71,12 @@ final class DaggerTestComponent {
}

private static final class SwitchingProvider<T> implements Provider<T> {
private final TestComponentImpl testComponentImpl;
private final Impl impl;

private final int id;

SwitchingProvider(TestComponentImpl testComponentImpl, int id) {
this.testComponentImpl = testComponentImpl;
SwitchingProvider(Impl impl, int id) {
this.impl = impl;
this.id = id;
}

Expand All @@ -87,8 +87,8 @@ final class DaggerTestComponent {
case 0: // test.FooFactory
return (T) new FooFactory() {
@Override
public Foo create(String testComponentImpl2) {
return (Foo) (Foo_Factory.newInstance(testComponentImpl2, testComponentImpl.barProvider));
public Foo create(String testComponentImpl) {
return (Foo) (Foo_Factory.newInstance(testComponentImpl, impl.barProvider));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

Foo_Factory fooProvider;

Provider<FooFactory> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

Provider<FooFactory> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

}

@SuppressWarnings("unchecked")
private void initialize() {
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<FooFactory>(testComponentImpl, 0));
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<FooFactory>(impl, 0));
}

@Override
Expand All @@ -62,12 +62,12 @@ final class DaggerTestComponent {
}

private static final class SwitchingProvider<T> implements Provider<T> {
private final TestComponentImpl testComponentImpl;
private final Impl impl;

private final int id;

SwitchingProvider(TestComponentImpl testComponentImpl, int id) {
this.testComponentImpl = testComponentImpl;
SwitchingProvider(Impl impl, int id) {
this.impl = impl;
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

Foo_Factory fooProvider;

Expand All @@ -49,7 +49,7 @@ final class DaggerTestComponent {
*/
Provider<?> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ final class DaggerTestComponent {
}

public TestComponent build() {
return new TestComponentImpl();
return new Impl();
}
}

private static final class TestComponentImpl implements TestComponent {
private final TestComponentImpl testComponentImpl = this;
private static final class Impl implements TestComponent {
private final Impl impl = this;

/**
* {@code Provider<FooFactory>}
*/
Provider<?> fooFactoryProvider;

TestComponentImpl() {
Impl() {

initialize();

}

@SuppressWarnings("unchecked")
private void initialize() {
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<>(testComponentImpl, 0));
this.fooFactoryProvider = SingleCheck.provider(new SwitchingProvider<>(impl, 0));
}

@Override
Expand All @@ -65,12 +65,12 @@ final class DaggerTestComponent {
}

private static final class SwitchingProvider<T> implements Provider<T> {
private final TestComponentImpl testComponentImpl;
private final Impl impl;

private final int id;

SwitchingProvider(TestComponentImpl testComponentImpl, int id) {
this.testComponentImpl = testComponentImpl;
SwitchingProvider(Impl impl, int id) {
this.impl = impl;
this.id = id;
}

Expand Down
Loading
Loading