Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge change from google internal #115

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3500539
Fix bug in ClassName.fromClass which causes an infinite loop if you p…
sethnel99 Jan 22, 2015
2a0f0c6
Comment out javawriter pending migration to javapoet (it's left there…
cgruber Jan 22, 2015
475a606
Fix dependency request formatting so that it prints out resolved meth…
sameb Jan 23, 2015
0d49be8
Add support for subclassing modules to specify generic types. In the…
sameb Jan 23, 2015
ca9c82b
Add lookup of ProductionBindings to BindingGraph.
jbeder Jan 24, 2015
69667a2
Fix NPE when map bindings are used without producers, and added corre…
jbeder Jan 24, 2015
cc08719
Add a method to MoreTypes that does the same operation as Types.asEle…
gk5885 Jan 26, 2015
e33a27c
Make `@Component` a runtime-retained annotation, which can allow more…
Jan 27, 2015
e78eb21
Remove the Guava dependency from the Dagger functional tests. The tes…
jbeder Jan 27, 2015
36acd6a
Add producers functional tests.
jbeder Jan 27, 2015
a5bf53f
Produce sane error messages if for members injection requests of raw …
sameb Jan 28, 2015
56f8f00
Allow dagger @Component interfaces to depend upon interfaces which ar…
sethnel99 Jan 29, 2015
959f5cd
An initial implementation of @Subcomponent. It elides validation, so…
gk5885 Jan 29, 2015
725e783
Add static analysis @Nullable checks. Injected parameters that aren'…
sameb Jan 30, 2015
905358f
Implement basic component generation for producers.
jbeder Jan 30, 2015
cd57feb
Enable subcomponents of subcomponents (in addition to components).
gk5885 Jan 30, 2015
e2e97ad
Change the default dagger.nullableValidation to ERROR.
sameb Feb 1, 2015
abb9ea8
Fix handling of dependencies attribute of ProductionComponent.
Feb 3, 2015
307126b
Fix @ProductionComponent depending on @ProductionComponent. The inter…
Feb 4, 2015
627a521
Don't rely on Java8-style type inferencing
cgruber Feb 4, 2015
847e2ae
Cause the functional tests to use Java7 syntax, since they do. We ne…
cgruber Feb 5, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/pom.xml
Expand Up @@ -50,10 +50,12 @@
<artifactId>auto-service</artifactId>
<optional>true</optional>
</dependency>
<!-- TODO(gak): Restore this presumably as javapoet when appropriate.
<dependency>
<groupId>com.squareup</groupId>
<artifactId>javawriter</artifactId>
</dependency>
-->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand All @@ -63,6 +65,7 @@
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<optional>true</optional>
<version>1.0</version>
</dependency>

<dependency>
Expand Down
20 changes: 8 additions & 12 deletions compiler/src/it/functional-tests/pom.xml
Expand Up @@ -33,12 +33,12 @@ limitations under the License.
<artifactId>dagger</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand All @@ -50,19 +50,15 @@ limitations under the License.
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
<annotationProcessors>
<annotationProcessor>dagger.internal.codegen.ComponentProcessor</annotationProcessor>
</annotationProcessors>
Expand Down
Expand Up @@ -15,12 +15,10 @@
*/
package test;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import dagger.Module;
import dagger.Provides;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
Expand All @@ -40,38 +38,44 @@ Double provideDouble() {

@Provides
ArrayList<String> provideArrayListString() {
return Lists.newArrayList("arrayListOfString");
ArrayList<String> list = new ArrayList<>();
list.add("arrayListOfString");
return list;
}

@Provides
LinkedList<String> provideLinkedListString() {
return BoundedGenericModule.newLinkedList("linkedListOfString");
LinkedList<String> list = new LinkedList<>();
list.add("linkedListOfString");
return list;
}

@Provides
LinkedList<CharSequence> provideLinkedListCharSeq() {
return BoundedGenericModule.<CharSequence>newLinkedList("linkedListOfCharSeq");
LinkedList<CharSequence> list = new LinkedList<>();
list.add("linkedListOfCharSeq");
return list;
}

@Provides
@SuppressWarnings("unchecked")
LinkedList<Comparable<String>> provideArrayListOfComparableString() {
return BoundedGenericModule.<Comparable<String>>newLinkedList("arrayListOfComparableOfString");
LinkedList<Comparable<String>> list = new LinkedList<>();
list.add("arrayListOfComparableOfString");
return list;
}

@Provides
List<Integer> provideListOfInteger() {
return Lists.newArrayList(3);
LinkedList<Integer> list = new LinkedList<>();
list.add(3);
return list;
}

@Provides
Set<Double> provideSetOfDouble() {
return Sets.newHashSet(4d);
}

private static <E> LinkedList<E> newLinkedList(E... elements) {
LinkedList<E> list = Lists.newLinkedList();
Collections.addAll(list, elements);
return list;
Set<Double> set = new HashSet<>();
set.add(4d);
return set;
}
}
@@ -0,0 +1,21 @@
package test;

import dagger.Module;
import dagger.Provides;
import java.util.ArrayList;
import java.util.List;

@Module
class ChildDoubleModule extends ParentModule<Double, String, List<Double>> {

@Provides Double provideDouble() {
return 3d;
}

@Provides List<Double> provideListOfDouble() {
List<Double> list = new ArrayList<>();
list.add(4d);
return list;
}

}
@@ -0,0 +1,21 @@
package test;

import dagger.Module;
import dagger.Provides;
import java.util.ArrayList;
import java.util.List;

@Module
class ChildIntegerModule extends ParentModule<Integer, String, List<Integer>> {

@Provides Integer provideInteger() {
return 1;
}

@Provides List<Integer> provideListOfInteger() {
List<Integer> list = new ArrayList<>();
list.add(2);
return list;
}

}
Expand Up @@ -19,18 +19,21 @@
import test.sub.Exposed;
import test.sub.PublicSubclass;

@Component
@Component(modules = {ChildDoubleModule.class, ChildIntegerModule.class})
interface GenericComponent {
ReferencesGeneric referencesGeneric();
GenericDoubleReferences<A> doubleGenericA();
GenericDoubleReferences<B> doubleGenericB();
ComplexGenerics complexGenerics();
GenericNoDeps<A> noDepsA();
GenericNoDeps<B> noDepsB();

void injectA(GenericChild<A> childA);
void injectB(GenericChild<B> childB);

Exposed exposed();
PublicSubclass publicSubclass();

Iterable<Integer> iterableInt();
Iterable<Double> iterableDouble();
}
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2015 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;

import dagger.Component;
import java.util.Map;

@Component(modules = MultibindingModule.class)
interface MultibindingComponent {
Map<String, String> map();
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2015 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;

import dagger.Module;
import dagger.Provides;

import static dagger.Provides.Type.MAP;

@Module
class MultibindingModule {
@Provides(type = MAP) @TestKey("foo") String provideFooKey() {
return "foo value";
}

@Provides(type = MAP) @TestKey("bar") String provideBarKey() {
return "bar value";
}
}
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2015 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;

import dagger.Component;
import javax.inject.Inject;

@Component(dependencies = {NonComponentDependencyComponent.ThingComponent.class})
interface NonComponentDependencyComponent {
ThingTwo thingTwo();

static class ThingTwo {
@Inject
ThingTwo(Thing thing) {}
}

// A non-component interface which this interface depends upon.
interface ThingComponent {
Thing thing();
}

// The implementation for that interface.
static class ThingComponentImpl implements ThingComponent {
@Override
public Thing thing() {
return new Thing();
}
}
}
@@ -0,0 +1,18 @@
package test;

import dagger.Module;
import dagger.Provides;
import java.util.ArrayList;
import java.util.List;

@Module
abstract class ParentModule<A extends Number & Comparable<A>, B, C extends Iterable<A>> {
@Provides Iterable<A> provideIterableOfAWithC(A a, C c) {
List<A> list = new ArrayList<>();
list.add(a);
for (A elt : c) {
list.add(elt);
}
return list;
}
}
23 changes: 23 additions & 0 deletions compiler/src/it/functional-tests/src/main/java/test/TestKey.java
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2015 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;

import dagger.MapKey;

@MapKey(unwrapValue = true)
@interface TestKey {
String value();
}
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2015 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.nullables;

import javax.inject.Provider;

import dagger.Component;

@Component(modules = NullModule.class)
interface NullComponent {
NullFoo nullFoo();
@Nullable String string();
Provider<String> stringProvider();
Number number();
Provider<Number> numberProvider();
}