aboutsummaryrefslogtreecommitdiff
path: root/factory/src/test
AgeCommit message (Collapse)Author
2021-10-01Include type parameters of parent types in generated factory classes.Éamonn McManus
Suppose you have the following types: ``` interface Foo<M extends Bar> {...} interface FooFactory<M extends Bar> { Foo<M> create(); } @AutoFactory(implementing = FooFactory.class) class FooImpl<M extends Bar> implements Foo<M> {...} ``` Then the generated `FooImplFactory` class should look like this: ``` class FooImplFactory<M extends Bar> implements FooFactory<M> {...} ``` But before this change that was only the case if there was a `@Provided M` constructor parameter. Now we examine whether the requested supertypes of the generated class have type parameters, and if so we copy those onto the generated class. This may not be 100% accurate but it should work for at least the commonest cases. RELNOTES=When a requested supertype of the generated factory class has a type parameter, the generated class now always has the same parameter. PiperOrigin-RevId: 400259157
2021-06-02Reformat all the Auto projects using google-java-format. For now, javadoc ↵Éamonn McManus
reformatting is excluded. RELNOTES=n/a PiperOrigin-RevId: 377145832
2021-01-09Ensure that type annotations are placed correctly.Éamonn McManus
Treating them the same as other annotations leads to problems with nested types like `Map.Entry`. If a field or parameter is a `Map.Entry` that is `@Nullable`, and if `@Nullable` is a `TYPE_USE` annotation, then the declaration must use `Map.@Nullable Entry`. JavaPoet will do this correctly if the annotations are applied to the `TypeName` for the declaration. Also ensure that type annotations are included in the `T` of `Provider<T>` when that appears in field or parameter declarations. Fixes https://github.com/google/auto/issues/949. RELNOTES=AutoFactory type annotations are now placed correctly even for nested types. PiperOrigin-RevId: 350930373
2020-12-15Handle `@AutoFactory` constructors that throw checked exceptions.Éamonn McManus
The generated `create` method needs to declare the same exceptions. Fixes https://github.com/google/auto/issues/90. RELNOTES=`@AutoFactory` constructors can now declare checked exceptions. The same exceptions will be declared on the generated `create` method. PiperOrigin-RevId: 347657308
2020-12-14Update AutoFactory compilation tests to use the more recent compile-testing API.Éamonn McManus
In a couple of places I changed `.onLine(M).atColumn(N)` into just `onLineContaining(S)`. I don't think we care that much about the column number of the error. Also move a test input file that was in the wrong place. PiperOrigin-RevId: 347454890
2020-08-27Automatic code cleanup.Google Java Core Libraries
PiperOrigin-RevId: 326930055
2019-08-19Add support for type parameters to @AutoFactory.gsaul
RELNOTES=Add support for generics to @AutoFactory #AutoFactory ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=263154977
2019-08-19Don't crash processing classes in the default packagescushon
Fixes https://github.com/google/auto/issues/745 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=262160859
2019-05-27Don't compare TypeMirrors using Object#equalscushon
They don't override Object#equals and are not interned, so reference equality is not useful. This was causing unnecessary duplication of Provider fields in AutoFactories. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=248752047
2019-04-29Update copyrights to say Google LLC instead of Google Inc.emcmanus
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244250754
2018-02-01Fix handling of @Generated in tests after ↵cushon
715b8eb505649a4acaaa5889d4f4b51a91dd8a91, 0383c1cf7472d7444463353aa2ac956c9471130a RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=184065172
2018-01-25Add support for type-annotations and CheckerFramework nullable types to ↵ronshapiro
@AutoFactory RELNOTES=Add support for type-annotations and CheckerFramework nullable types to @AutoFactory ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183251433
2017-12-15Write the correct @Generated annotation within auto-factory.dpb
RELNOTES=Use `@javax.annotation.processing.Generated` for Java 9. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179187028
2017-07-05Do not prepend outer classnames to the generated @AutoFactory class name if acwgordon
class name has been explicitly specified. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=160310315
2017-04-28Emit a checkNotNull method in all generated factories instead of packaging a ↵ronshapiro
runtime dependency for one method. Fixes https://github.com/google/auto/issues/436 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154474844
2017-02-16Fix test which asserted the existence of a diagnostic on an annotation ↵ronshapiro
value, which was not correctly implemented by javac. This bug has been patched and will be in the next version of javac. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146784756
2016-08-29Allow varargs on @AutoFactory methodsronshapiro
Github: Fixes google/auto#326 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130784801
2016-08-29Rename FactoryImplementingGenericInterfaceExtensionFactory file to match the ↵ronshapiro
name of the class ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129673209
2016-08-29Fix Java source files under third_party/java_src/auto so that they follow ↵emcmanus
the new simplified import rules. One test, AutoFactoryProcessorTest, had to be updated with modified line numbers because unused imports in bad/MixedFinals.java were deleted. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129643318
2016-08-29Disambiguate provider field's names in generated factoriesronshapiro
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=129441115
2016-08-29Allow Provider<> parameters on a create() methodronshapiro
Also check nullness of Provider<>s passed to @Inject constructors of an @AutoFactory Github: Fixes #296 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=128983250
2016-08-29Fix name of a test data classronshapiro
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=128519974
2016-08-29Support @Nullable parameters for @AutoFactoryronshapiro
FYI This is a rollforward of [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126078797
2016-08-29Automated g4 rollback of changelist 125191485.jmittleman
*** Reason for rollback *** Breaks []. The bug is present in [] but not in able or baker, so I assume this didn't make it into a [] cut and I don't have to ship this if I get it in by Monday morning. *** Original change description *** Support @Nullable parameters for @AutoFactory FYI This is a rollforward of [] *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125289392
2016-08-29Support @Nullable parameters for @AutoFactoryronshapiro
FYI This is a rollforward of [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125191485
2016-03-21When checking FactoryMethodDescriptor's and ImplementationMethodDescriptor's ↵alanrussian
for duplicates, remove the ImplementationMethodDescriptor and set the FactoryMethodDescriptor to be overriding and have the same visibility. - The test case, which has been modified to make the concrete class package-private, would not have worked before, because the create methods were given package-private visibility instead of public visibility. - This also makes it so that these duplicate methods have the @Override annotation. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117186640
2016-03-04When deduping methods that are inherited from an interface, only check the ↵alanrussian
types to decide equality. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=116304582
2016-03-04Automated g4 rollback of changelist 115670868.ronshapiro
*** Reason for rollback *** Broke some builds *** Original change description *** Support @Nullable parameters for @AutoFactory *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115677120
2016-03-04Support @Nullable parameters for @AutoFactoryronshapiro
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115670868
2016-03-04Convert @AutoFactory to JavaPoetronshapiro
This is a rollforward a previous commit which broke due to JavaPoet's TypeName.get() not supporting TypeMirrors that aren't generated yet. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115590956
2016-03-04Automated g4 rollback of changelist 114460941.ronshapiro
*** Reason for rollback *** Some clients were broken by TypeName.get(ErrorType) *** Original change description *** Convert @AutoFactory to use JavaPoet. In the process, convert all value types to @AutoValue to allow for an easier transition for later implementing the passing of annotations to generated factories. *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=114468479
2016-03-04Convert @AutoFactory to use JavaPoet.ronshapiro
In the process, convert all value types to @AutoValue to allow for an easier transition for later implementing the passing of annotations to generated factories. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=114460941
2016-03-04Fix auto factory issue where multiple copies of the same method can be ↵oni
generated when inherited from an interface. Caveats: parameter names have to match perfectly. If an interface declares the exact same method with differently named params we will choke as before. everything needs to be public. Interface methods are inherently public, so if we have a collision on a create method, we can't downgrade its visibility to package-private. I think we can automatically upgrade it though if you'd like. I'm not emitting @Override or anything fancy like that ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=113658842
2015-08-04Name factories for nested classes using the enclosing class names, not just ↵dpb
the annotated class name. For example, the factory for Foo.Bar is named Foo_BarFactory instead of just BarFactory. Includes a small refactoring of AutoFactoryDeclaration.getFactoryName(). The factory class name is always based on the target type name, which is known when AutoFactoryDeclaration is instantiated. So getFactoryName() doesn't need any parameters. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=97771117
2015-08-04Correctly generate code when a @Provided parameter has a primitive type.dpb
"@Provides int foo" used to generate a field of type Provider<int>, which doesn't compile. Now it generates a field of type Provider<Integer>. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=96435444
2015-08-04If a @Provided parameter to an @AutoFactory constructor is a Provider<T>, ↵dpb
then the generated factory should just pass its Provider<T> rather than trying to inject a Provider<Provider<T>. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=95226468
2015-08-04This CL fixes @AutoFactory to support qualifiers with parameters.jart
This is the same as a previous change which got rolled back in error. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=94704806
2015-08-04Automated g4 rollback of changelist 94700822.cgruber
*** Reason for rollback *** Breaks several projects using the feature of qualified bindings, because it fails to re-name the params properly, and so you end up with two parameters with the same name. *** Original change description *** This CL fixes @AutoFactory to support qualifiers with parameters. *** ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=94702981
2015-08-04This CL fixes @AutoFactory to support qualifiers with parameters.jart
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=94700822
2015-05-06Fix a bug that causing invalid code generated when using multiple ↵Oleksandr Gumen
AutoFactories implementing same interface. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=92862023
2015-02-02Don't make autofactories final based on a new "allowSubclasses" parameter.sameb
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=84575988
2014-09-06Migrate from Truth.ASSERT to Truth.assert_.Christian Edward Gruber
Tested: TAP --sample for global presubmit queue [] ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72549415
2014-09-06Update Truth package name to the new location.Christian Edward Gruber
Tested: TAP --sample for global presubmit queue [] ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72339462
2014-01-17rename the aux directory to appease windowsGregory Kick
2014-01-07Fix AutoFactory to work correctly when implementing an interface that is an ↵Christian Edward Gruber
extension of a generic interface. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=57662999
2013-10-29Add RunsWith to permit execution in google's internal test environment.Christian Edward Gruber
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=54908566
2013-09-27Make sure that abstract factories without no-arg constructors cause failures.Gregory Kick
2013-09-25Add tests for invalid values for "extending" in @AutoFactory.Gregory Kick
2013-09-25Fix a line number on a testGregory Kick
2013-09-25add a missing copyrightGregory Kick