* Suppress common warnings in generated classes
Followup from #1023 (Resolves#1023 too). Since we can't do targeted deprecation suppressions, we can just stick with blanket deprecations suppressions for now. This also suppresses a couple other common issues with all our generated adapters.
Have just eyeballed the results for now, can add a proper test as a followup once #1014 is in
* Add redundant projection and re-enable -Werror
* Add tests for deprecation suppression
With -Werror enabled now we can actually check this
* Only allow public or internal classes
* Ensure consistent ordering of supertypes
* Eagerly load supertype typespecs for reuse
* Add regression test for https://github.com/square/moshi/issues/1022
* Add MoshiCachedClassInspector, wire in
* Check visibility of enclosed types too
Resolves#1022
* Fix comments
* Fix: force object type for type arguments
* Add outDeclaration regression test for #1009
* Create mapTypesUtility for reusing recursive type mapping
* Strip typevar variance where appropriate
Resolves#1009
* Fix missing nullability/annotations when unwrapping typealiases
Fixes#990
* Add extra nullable properties test + more nullability in alias test
* Add more complex typeAliasNullability test
* Recursively check nullability and track annotations in typealiases
* Check against non-nullable known primitives when rendering class blocks
`Int?` will not equal `Int` in KotlinPoet, so this was always falling through to the default `::class.java` code.
Resolves#991
* Nix comment
* Flesh out test to include all primitives
* Add parameter-only param in multi-masks test
* Add type to target parameters for later reference
* Ensure parameters are ordered
* Reword AdapterGenerator fromJson logic to use sealed FromJsonComponent
This allows us to handle parameter-only types separately (needed for mask index calculation). Resolves#979
* Add more tests
* Add MultipleMasksTest test
* Use multiple masks for constructors with more than 32 parameters
Resolves#977
* Add non-default arg to test
* Emit hex literals
* Simpler int math
* Don't allocate a mask if there's no properties
* Fix broken test
This test suite doesn't run on CI builds but fails locally since the method was moved
* Add multiple constructors test case
* Implement TypeName.asTypeBlock()
* Make DEFAULT_CONSTRUCTOR_MARKER public
* Look up constructor via getDeclaredConstructor with exact param types
Resolves#975
* Remove dead code
* Unwrap typealiases
This was a change in 1.4.2 left over from moshi's prior metadata logic. We need the unwrapped type for class references
* Add toe-hold for testing shared adapter behavior
* Add regression test for abstractSuperProperties
* Kotlinpoet 1.4.2
* KotlinPoet 1.4.1 & Kotlin 1.3.50
KotlinPoet uses 1.3.50, so this just matches that now
* Remove now-unnecessary custom shade
This uses the same common package prefix in kotlinpoet now
* Add backwardReferencingTypeVars() regression test
Coverage for #955
* Add regression test for field json annotations
* Make json name null if absent rather than default to name
This fixes incorrect behavior where the parameter json name would always win out over the property value
* Report json name in code gen if different from property name
Resolves#800
* Unify required property name error message
* Report json name in kotlinjsonadapter, match code gen
* Upper case JSON
Co-Authored-By: Jake Wharton <jakew@google.com>
* Upper case JSON
Co-Authored-By: Jake Wharton <jakew@google.com>
* Don't keep constants
* Inline json name - property name comparison to util methods
* Remove unnecessary constructor keyword
* Consolidate non-null/missing property tests to parameterized suite
* Add custom json name tests for nonNull property checks
* Rename test to make maven happy
Maven won't run the test unless it ends with `Test` or `TestCase`
* Use raw type for kclass references in dynamic invocation code gen
Added a compile-only regression test
Resolves#905
* Make it actually generic
* Mostly fix generation
Will need to wait for inlined instantiation to merge
* Fix rebase issues and use newInstance
* Differentiate local naming from properties with constructor defaults
* Remove constructor invocation and mask creation methods
We're inlining all this
* Add explanatory comment for why we use the default primitive value
* Inline mask generation and constructor invocation to generated adapters
* Remove unused argument
Co-Authored-By: Jake Wharton <jakew@google.com>
* Compute masks directly during code gen
* Opportunistic: remove extraneous double space from control flow
* Just mask and invert directly
* Add Util#invokeDefaultConstructor
* Add defaultPrimitiveValue
This will be used to initialize required properties for later invocation of the default constructor
* Move isTransient into PropertyGenerator
We will need this in order to know how to invoke constructors even if they have transient parameters
* Add notion of hasLocalIsPresentName to PropertyGenerator
* Switch to using invokeDefaultConstructor for any default property types
* Add code gen versions of default constructor test
* Fix mismatched names
* Use Arrays.copyOf
* Unwrap InvocationTargetException
* Use name allocator
* Rename createMask to createDefaultValuesParametersMask, use it directly
* Opportunistically clean up result variable holder
Only needs to be made if we have non-parameter instances, otherwise we can just return directly
* Fix mask name
* Remove unnecessary mod
* Switch to local lazily-initialized constructor reference
Not working because of some issue in kotlinpoet I don't understand
* Fix named usage
* Clean up debugging dots
* Add proguard/R8 rule for keeping defaults constructor in targets
* Make constructor lookup property private
* Add another defensive dot
* Rework invokeDefaultConstructor to accept vararg args
A little more idiomatic
* Update proguard rules
* Start MoshiKotlinExtensions
* Add Moshi.Builder.add() with reified typeOf
* Use non-shadowing name for addAdapter
* Implement KType.toType()
.javaType isn't implemented
* Don't re-wrap wrapped adapters
* Use new adapter functions in tests to smoke test
* Don't enable uses experimental in kotlin-reflect, only the test
* Use internal leniency API
* Use toType in addAdapter too
* Update error message in test
* Extract generatedJsonAdapterName to public API for other generators/consumers
* Fix kapt location in tests
* Add IDE-generated dependency-reduced-pom.xml to gitignore
This always bites me
* Add generator property to JsonClass and skip in processor
* Opportunistically fix formatting for generateAdapter doc
* Extract NullSafeJsonAdapter for delegate testing
* Add custom adapter tests
* Allow no-moshi constructors for generated adapters
* Fix rebase issue
* Use something other than nullSafe() for lenient check
This no longer propagates lenient
* Add missing copyrights
* Add top-level class note
* Add note about working against Moshi's generated signature
* Add missing bit to "requirements for"
* Note kotlin requirement relaxed in custom generators
* Style
* Support gradle incremental processing in code gen
This adds support for incremental compilation in gradle via incap helper and marking the code gen as `ISOLATING`.
Depends on a newer version of KotlinPoet that has https://github.com/square/kotlinpoet/pull/647Resolves#589
* Opportunistically update to auto-service 1.0-rc5
Supports incremental compilation and moves annotations to a separate artifact
* 1.2.0 final!
* Mark compiler embeddales as test only
Before, the KotlinJsonAdapter threw "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0" on a duplicate key when the key matched a property that was not a constructor parameter.