aboutsummaryrefslogtreecommitdiff
path: root/value/src/test/java/com/google
AgeCommit message (Collapse)Author
2019-08-19Include type annotations in bounds of type parameter declarations. For ↵emcmanus
example, if we have `@AutoValue abstract class Foo<T extends @NullableType Object>`, then we should generate `class AutoValue_Foo<T extends @NullableType Object> extends Foo<T>`, rather than just `class AutoValue_Foo<T> extends Foo<T>` as at present. RELNOTES=In AutoValue code, include type annotations in bounds of type-parameter declarations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=254752026
2019-08-19Handle inner classes correctly when the outer class has a type parameter.emcmanus
RELNOTES=Handle inner classes correctly when the outer class has a type parameter. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=254205692
2019-08-14Use the short form of annotations in generated code. For example, instead of ↵emcmanus
@SuppressWarnings(value = {"mutable"}), write @SuppressWarnings("mutable"). RELNOTES=Use the short form of annotations in generated code. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=253993453
2019-06-06Update to Truth 0.45, and address deprecations.cpovirk
Renames may include: - containsAllOf => containsAtLeast - containsAllIn => containsAtLeastElementsIn - isSameAs => isSameInstanceAs - isOrdered => isInOrder - isStrictlyOrdered => isInStrictOrder The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted). Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().) Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=251495286
2019-05-27Improve the logic for setter type conversion. Setter type conversion is when ↵emcmanus
for example we have a property `Optional<String> foo()` or `ImmutableList<String> bar()` and a setter like `setFoo(String x)` or `setBar(String[] x)`. The generated setter will need to do `Optional.of(x)` or `ImmutableList.copyOf(x)`. Previously the logic to do this was split into two places: (a) where we determined whether a conversion was possible, and (b) where we generated the code. In (b) we had to guess the name of the copy method (`of` or `copyOf` for example) even though we knew it in (a). Now we arrange for the information about the method name to be copied from (a) to (b). This change will allow us to add logic to support ImmutableSortedSet.copyOfSorted and ImmutableSortedMap.copyOfSorted. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=249476752
2019-05-27Allow @AutoOneOf properties to be void.emcmanus
An abstract void method means that the associated kind has no value. The factory method has no parameter and calling the implementation of the void method does nothing unless the instance is of another kind. RELNOTES=Allow @AutoOneOf properties to be void. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=249301961
2019-05-08Instead of calling Subject.actual(), store the actual value in a field, and ↵cpovirk
read that. actual() is being removed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=246997654
2019-05-07Migrate from assertThat(foo).named("foo") to assertWithMessage("foo").that(foo).cpovirk
(The exact change is slightly different in some cases, like when using custom subjects or check(), but it's always a migration from named(...) to [assert]WithMessage(...).) named(...) is being removed. This CL may slightly modify the failure messages produced, but all the old information will still be present. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=246871370
2019-05-05Migrate from is(Not)SameAs to is(Not)SameInstanceAs.cpovirk
They behave identically, and the old names are being removed. Open-source note: The new methods are available in Truth as of version 0.44. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=246151837
2019-05-05Migrate from isNotSameAs to isNotSameInstanceAs.cpovirk
The two behave identically, and isNotSameAs is being removed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=245851407
2019-04-29Migrate from assertThat(foo).named("foo") to assertWithMessage("foo").that(foo).cpovirk
(The exact change is slightly different in some cases, like when using custom subjects or check(), but it's always a migration from named(...) to [assert]WithMessage(...).) named(...) is being removed. This CL may slightly modify the failure messages produced, but all the old information will still be present. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=245027656
2019-04-29Use the newer compile-testing API in AutoAnnotationCompilationTest.emcmanus
RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244721908
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
2019-04-10Ensure that setUseCaches(false) is called when reading extensions.emcmanus
Fixes https://github.com/google/auto/issues/718. RELNOTES=Fix an intermittent issue with AutoValue extensions and Gradle. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=242786899
2019-04-04Output the full exception trace if ServiceLoader fails when looking for ↵emcmanus
AutoValue extensions. See https://github.com/google/auto/issues/718. RELNOTES=More detailed exception information if AutoValue extensions cannot be loaded. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=241929228
2019-04-03Expand the exceptions covered by the workaround for a JDK8 jar bug.emcmanus
Fixes https://github.com/google/auto/issues/715. RELNOTES=Expand the exceptions covered by the workaround for a JDK8 jar bug. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=240859625
2019-04-03Support @CopyAnnotations in classes generated by MemoizeExtension.stabai
Note: Several methods are copied from the com.google.auto.value.processor that should be moved to a common location. RELNOTES=Support @CopyAnnotations in classes generated by MemoizeExtension. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=240174112
2019-03-22Refactor exception-message assertions to use ↵diamondm
ThrowableSubject.hasMessageThat(). This replaces assertions of the form assertThat(e).hasMessage(...) and assertThat(e.getMessage()) with assertThat(e).hasMessageThat(). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=239181584
2019-03-22Further improve the logic for checking setter types.emcmanus
In the case where the setter parameter is supposed to be the same as the getter type, we use appropriate logic to take inheritance into account. We also verify that the type of a parameter that we are thinking of feeding to ImmutableSet.copyOf (for example) will actually lead to an ImmutableSet of the right type. RELNOTES=Improved type checking for builder setter parameters. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=238503171
2019-03-12Improve the logic for checking setter parameter types against getter return ↵emcmanus
types. We translate the getter return types into the type context of the builder. For example, if the @AutoValue class is Foo<T> then its builder must be Foo.Builder<T>. A getter like `abstract List<T> getList()` is compatible with a setter like `Builder setList(List<T> list)`, even though the <T> parameter in each case is different. So we convert `List<T-{Foo}> getList()` into `List<T{Foo.Builder}> getList()` before comparing types. RELNOTES=Better checking of types in setters against types in getters. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=238100041
2019-02-21Check for instance equality before attempting to check for the @Memoized ↵ronshapiro
hashCode optimization RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233968723
2019-01-16Make it a compilation error for an @AutoOneOf property to be @Nullable.emcmanus
The generated code already rejects null values, whether or not @Nullable is present, so this just lets users know earlier that what they are trying is not going to work. RELNOTES=It is a compilation error for an @AutoOneOf property to be @Nullable since null values are not in fact accepted. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=229442655
2019-01-16Allow AutoValue extensions to declare supported options.Zac Sweers
The options will then be returned by AutoValueProcessor.getSupportedOptions(). This change is based on code by Zac Sweers. Closes https://github.com/google/auto/pull/680. RELNOTES=AutoValue extensions can now declare supported options. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=229202570
2019-01-02Update TemplateVarsTest so it doesn't interfere with JaCoCo.emcmanus
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=227518597
2018-11-05When hashCode() is @Memoized, check the hash code before checking equality ↵ronshapiro
as an optimization RELNOTES=When `hashCode()` is `@Memoized`, `equals()` will be optimized to check hash codes first before other properies ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=219306578
2018-10-29Check for null in autooneof.vm instead of calling foo.getClass() (in the ↵antoinebouchie
case where one of the types is of type "Class", it triggers an "Error Prone" error: http://errorprone.info/bugpattern/GetClassOnClass RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=219005298
2018-10-23Have MemoizeExtension recognise @Nullable as a type annotation.emcmanus
It currently only recognises @Nullable as a method annotation, typically for javax.annotation.Nullable, but does not recognise the TYPE_USE version from the checker framework. We also annotate the corresponding constructor parameter, though currently only for the TYPE_USE case. While testing this I discovered that we can pick up two versions of MemoizeExtension because it changed packages. Specifically I saw Maven picking up AutoValue 1.5.3 via compile-testing. The way ServiceLoader works means that we will load and run both versions of MemoizeExtension in this case. So I added a hack to AutoValueProcessor so it will ignore the old version if it sees it. RELNOTES=MemoizeExtension recognises @Nullable type annotations, not just method annotations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218175594
2018-10-23Remove unnecessary parentheses from the generated equals(Object) method.emcmanus
Fixes https://github.com/google/auto/issues/670. RELNOTES=Remove unnecessary parentheses from the generated equals(Object) method in @AutoValue classes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218164872
2018-07-02Remove dependency on java.beans.Introspectorbuchgr
This eliminates the need to include the giant java.desktop module on Java 9+. Based on https://github.com/google/auto/pull/647 by Jakob Buchgraber. RELNOTES=Remove the need for the java.desktop module on Java 9+. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=202499735
2018-06-12Delete AutoValue's copy of EscapeVelocity.emcmanus
RELNOTES=Delete AutoValue's copy of EscapeVelocity. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199745763
2018-06-12Rename CompilationTest to AutoValueCompilationTest for consistency with ↵emcmanus
AutoAnnotationCompilationTest and AutoOneOfCompilationTest. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199736684
2018-06-12Switch AutoValue to using the separate EscapeVelocity project rather than ↵emcmanus
its own copy. A later change will delete that copy. RELNOTES=Use separate EscapeVelocity project rather than AutoValue's own copy. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199709073
2018-06-12Add capability to annotate individual AutoValue fieldscroyer
RELNOTES=Add capability to annotate individual AutoValue fields ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199491872
2018-05-31Reformat AutoValue source code using google-java-format. A few of the ↵emcmanus
changes are arguably for the worse, but it's worth having a consistent format. RELNOTES=Reformatted AutoValue source code using google-java-format. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=198512874
2018-05-08Allow an Optional property to be set in a builder through a method with a ↵Kenzie Togami
@Nullable parameter. This is based on https://github.com/google/auto/pull/353 by Kenzie Togami. Closes https://github.com/google/auto/pull/353. RELNOTES: Allow an Optional property to be set in a builder through a method with a @Nullable parameter. NOTE: As a side-effect of this change, a setter for a @Nullable property must have its parameter also marked @Nullable. Previously, if the @Nullable was not a TYPE_USE @Nullable, it was copied from the getter to the parameter of the generated setter implementation. For TYPE_USE @Nullable it was already necessary to mark the setter parameter @Nullable. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=195471227
2018-03-27If an @AutoOneOf class has @CopyAnnotations, copy class annotations to the ↵emcmanus
generated subclasses. This CL also includes a certain amount of refactoring to share more code between AutoValue and AutoOneOf. RELNOTES=If an `@AutoOneOf` class has `@CopyAnnotations`, copy class annotations to the generated subclasses. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=190293950
2018-03-08Stop depending on Memoized.class, and move the extension+processor to its ↵ronshapiro
own class RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188329311
2018-02-13Change generated AutoOneOf code to use Parent_ rather than Parent$ as an ↵emcmanus
internal class name to avoid confusing Proguard. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=185534047
2018-01-31Fix handling of @Generated in tests after ↵cushon
715b8eb505649a4acaaa5889d4f4b51a91dd8a91, 0383c1cf7472d7444463353aa2ac956c9471130a RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=184027387
2018-01-29Choose @Generated based on the source version, not the classpath.cushon
RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183442436
2018-01-29Avoid java.lang.Compiler, which is deprecated in JDK 9cushon
The deprecation warnings currently cause the test to fail when running on JDK 9. RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183417231
2018-01-24Suppress some sources of warnings in AutoOneOfCompilationTest, to avoid a ↵emcmanus
test failure that only shows up on Travis. I'm still trying to understand why we get these failures in the first place. My theory is that, in this environment only, the test is finding com/google/auto/value/AutoOneOf.java when it sees `import com.google.auto.value.AutoOneOf`, so that file is "implicitly compiled". I'm not sure if that might be considered a bug in compile-testing, or in the Travis configuration. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183085105
2018-01-24Ensure that @AutoValue classes have correct code even if redeclarations of ↵emcmanus
Object or String are in scope. Fixes https://github.com/google/auto/issues/403. RELNOTES=Handle redeclared Object or String in @AutoValue classes. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182927083
2018-01-24Make reference handling in odd cases more similar to Velocity. If you have ↵emcmanus
`${` not followed by an identifier (so not `${foo.bar}` or whatever) then those are just two plain-text characters. If you have `$foo.!` rather than `$foo.bar` then the `.!` are just plain-text characters. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182860539
2018-01-24Add support for block comments to EscapeVelocity. Block comments are spelled ↵emcmanus
#*...*# and can span lines. Also add a couple of extra test cases around $ when it is not followed by an identifier. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182584435
2018-01-24First version of @AutoOneOf processoremcmanus
RELNOTES=Introduced @AutoOneOf for tagged-union types in Java. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182536936
2018-01-18Step 1 of the implementation of @AutoOneOf. Split AutoValueProcessor into ↵emcmanus
code that is specific to @AutoValue and code that will be shared with @AutoOneOf. Move template code that will be shared into a new equalshashcode.vm. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182381197
2018-01-08In AutoValue's CompilationTest, ignore irrelevant warnings.emcmanus
Always supply -Xlint:-processing -implicit:none in test methods that call compilation.succeededWithoutWarnings(). That suppresses warnings that "@SomeAnnotation was not consumed by any processor" and "Implicitly compiled files were not subject to annotation processing". RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=181179743
2018-01-08Extend EscapeVelocity with the #parse directive and the #[[...]]# quoting ↵emcmanus
construct. Also allow # not followed by an identifier, which is treated as a plain # character. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180868803
2018-01-08Remove JSR250 annotations from AutoValue tests, and use @Deprecated for ↵dpb
testing copying annotations instead of one from javax.annotations. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180717772