forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from google/moe_writing_branch_from_6475f4779…
…9f55eb2d22af72b7c8bddf3f7b1d01c Merge out new changes from google's internal repository
- Loading branch information
Showing
89 changed files
with
2,470 additions
and
616 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
compiler/src/it/functional-tests/src/main/java/test/ComponentsWithNestedModules.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2016 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 dagger.Module; | ||
|
||
// https://github.com/google/dagger/issues/279 | ||
public class ComponentsWithNestedModules { | ||
@Component(modules = RegularComponent.SharedModule.class) | ||
public interface RegularComponent { | ||
@Module class SharedModule {} | ||
} | ||
|
||
@Component(modules = ExtendsRegularComponent.SharedModule.class) | ||
public interface ExtendsRegularComponent extends RegularComponent { | ||
@Module(includes = RegularComponent.SharedModule.class) | ||
class SharedModule {} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
compiler/src/it/functional-tests/src/main/java/test/scope/BlueModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2016 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.scope; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
import static dagger.Provides.Type.SET; | ||
|
||
@Module | ||
final class BlueModule { | ||
@Provides(type = SET) | ||
@BlueScope | ||
static Object blue() { | ||
return new Object(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
compiler/src/it/functional-tests/src/main/java/test/scope/BlueScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2016 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.scope; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import javax.inject.Scope; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Documented | ||
@Retention(RUNTIME) | ||
@Scope | ||
@interface BlueScope {} |
30 changes: 30 additions & 0 deletions
30
compiler/src/it/functional-tests/src/main/java/test/scope/GreenModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2016 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.scope; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
import static dagger.Provides.Type.SET; | ||
|
||
@Module | ||
final class GreenModule { | ||
@Provides(type = SET) | ||
@GreenScope | ||
static Object green() { | ||
return new Object(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
compiler/src/it/functional-tests/src/main/java/test/scope/GreenScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2016 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.scope; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import javax.inject.Scope; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Documented | ||
@Retention(RUNTIME) | ||
@Scope | ||
@interface GreenScope {} |
26 changes: 26 additions & 0 deletions
26
compiler/src/it/functional-tests/src/main/java/test/scope/ScopedComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (C) 2016 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.scope; | ||
|
||
import dagger.Component; | ||
import java.util.Set; | ||
|
||
@BlueScope | ||
@GreenScope | ||
@Component(modules = {BlueModule.class, GreenModule.class, TurquoiseModule.class}) | ||
interface ScopedComponent { | ||
Set<Object> set(); | ||
} |
36 changes: 36 additions & 0 deletions
36
compiler/src/it/functional-tests/src/main/java/test/scope/TurquoiseModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2016 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.scope; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
import static dagger.Provides.Type.SET; | ||
|
||
@Module | ||
final class TurquoiseModule { | ||
@Provides(type = SET) | ||
@BlueScope | ||
static Object blue() { | ||
return new Object(); | ||
} | ||
|
||
@Provides(type = SET) | ||
@GreenScope | ||
static Object green() { | ||
return new Object(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
compiler/src/it/functional-tests/src/main/java/test/subcomponent/SomeQualifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2016 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.subcomponent; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import javax.inject.Qualifier; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
@Documented | ||
@Retention(RUNTIME) | ||
@Qualifier | ||
@interface SomeQualifier {} |
31 changes: 31 additions & 0 deletions
31
compiler/src/it/functional-tests/src/main/java/test/subcomponent/Unbound.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2016 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.subcomponent; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.Retention; | ||
import javax.inject.Qualifier; | ||
|
||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* A qualifier representing an unbound type, to verify that the compiler does not attempt to | ||
* generate code depending on it. | ||
*/ | ||
@Documented | ||
@Retention(RUNTIME) | ||
@Qualifier | ||
@interface Unbound {} |
38 changes: 38 additions & 0 deletions
38
...r/src/it/functional-tests/src/main/java/test/subcomponent/UnresolvableChildComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2016 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.subcomponent; | ||
|
||
import dagger.Subcomponent; | ||
|
||
/** | ||
* A subcomponent that's not resolvable in any parent component, for testing that qualified methods | ||
* on components that return subcomponents do not trigger actual subcomponents. | ||
*/ | ||
@Subcomponent | ||
interface UnresolvableChildComponent { | ||
/** | ||
* Requests a type that is never bound in any component that this subcomponent might be installed | ||
* in. If this subcomponent is ever attempted to be installed in a component, then it will produce | ||
* a compiler error. | ||
*/ | ||
@Unbound | ||
String unboundString(); | ||
|
||
@Subcomponent.Builder | ||
interface Builder { | ||
UnresolvableChildComponent build(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...it/functional-tests/src/main/java/test/subcomponent/UnresolvableChildComponentModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2016 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.subcomponent; | ||
|
||
import dagger.Module; | ||
import dagger.Provides; | ||
|
||
@Module | ||
final class UnresolvableChildComponentModule { | ||
/** | ||
* Provides a qualified version of the {@link UnresolvableChildComponent}'s builder. If the | ||
* subcomponent were actually installed in a component, this would be a duplicate binding; but | ||
* since that doesn't happen, this binding is OK. | ||
*/ | ||
@Provides | ||
@SomeQualifier | ||
static UnresolvableChildComponent.Builder unresolvableChildComponentBuilder() { | ||
return new UnresolvableChildComponent.Builder() { | ||
@Override | ||
public UnresolvableChildComponent build() { | ||
return new UnresolvableChildComponent() { | ||
@Override | ||
public String unboundString() { | ||
return "unbound"; | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.