Commit Graph

182 Commits

Author SHA1 Message Date
Zac Sweers
a1852a7315 Finish spotless license header configuration (#1231)
* Update spotless and enable copyright header bits again

* Reformat square copyright headers

* Create separate format configuration for external files

* Update CI to use java 15 final

* include stacktrace in ci failures

* Update ktlint to 0.39

* Disable java formatting on JDK 15

* Fix google header
2020-09-25 22:18:51 -04:00
Zac Sweers
517ea36fe5 Fix shadow packaging in code gen artifact (#1214)
* Update to shadow 6.0

* Exclude kotlinpoet core artifact from shading

* Replace runtime scopes with compile

* Opportunistically fix old artifact() dep

Gradle 6.6 supports providers now

* Use api instead

* Add link

* Remove accidental gradle plugin config

This only applies to gradle plugins
2020-09-18 21:43:11 -04:00
Zac Sweers
5c07341977 Switch to Github Actions for CI 2020-09-01 15:48:33 -04:00
Zac Sweers
ecca5122a0 Switch to new appendLine APIs
appendLn is deprecated in kotlin 1.4
2020-09-01 01:13:55 -04:00
Zac Sweers
42f1d18f64 Update Okio and kotlin-compile-testing dependencies (#1198)
* Update Okio to latest

* Update kotlin-compile-testing to 1.2.10

* Update to KtLint 0.38.1

No changes affecting moshi, just support for mixing multiple kotlin versions in a project

* Opportunistic disable kotlin-dsl warning

This is noisy on every build

* Update maven publish to 0.12.0
2020-08-28 07:28:58 -04:00
Zac Sweers
538890e8c0 Switch to spotless and format code (#1196)
* Add spotless configuration

* Reformat!

* Add copyright config for build.gradle.kts files

* Add toeholds for headers
2020-08-27 23:40:15 -04:00
Zac Sweers
4dd4a9d222 Migrate to Gradle (#1159)
* Start gradle root

* Clean up test API ambiguities

These don't compile in gradle anymore and the team[] warns

* Exclude .gradle dirs in git

* Set up moshi module

* Set up moshi-adapters

* Add repositories to subprojects

* Set target/source compatibility

* Set up examples

* Fix location of reflect/test dir

* Set up moshi-kotlin

* Set up code gen

* Opportunistic update code gen deps

* Fix up with code gen

* Set up kotlin tests

* Update snapshots

* Update travis build

* Configure checkstyle

* Cache gradle

* Finish fixing up checkstyle

* Now disable checkstyle until we can fix them all :|

* Update contributing

* Fix tests in codegen

* Remove unnecessary annotation

* Remove maven stuff!

* Suppress warning

* Remove jcenter

* Consolidate dependencies

* Revert "Clean up test API ambiguities"

This reverts commit 3ead69b844b5d7f66134b721e95581f5df1cccd6.

* Fix incap dep

* Opportunistically fix some small kotlinpoet deprecations

* Automatically apply the stdlib to all kotlin projects

* Opportunistic move to opt-in and remove unnecessary annotations

The kotlin maven plugin didn't handle these well in the IDE, gradle does

* Fix Type doc warning

* Fix okio version

* Fix dokka support

* Fix copypasta

* Use new snapshot

* Kotlin 1.4.0
2020-08-27 16:50:28 -04:00
Jesse Wilson
28831b04cf [maven-release-plugin] prepare for next development iteration 2020-08-26 21:38:44 -04:00
Jesse Wilson
cff20193c2 [maven-release-plugin] prepare release moshi-parent-1.10.0 2020-08-26 21:38:36 -04:00
Zac Sweers
a5dbc1d642 Update to Kotlin 1.4.0 (#1191)
* Update to Kotlin 1.4.0

* Remove moshi-kotlin rules in favor of Kotlin's

* Ignore tests for now

* Update to OptIn

* Update test for kotlin 1.4 behavior
2020-08-25 22:51:44 -04:00
Oleg Vladimirov
6eb65908e0 bugfix 2020-06-26 13:28:00 +03:00
Ryan Harter
dd8611a1d9 Merge pull request #1080 from square/z/resolveRealTypes
Fix resolution of types in superclass settable properties
2020-05-26 17:53:45 -05:00
Zac Sweers
d64033ed94 Fix reflection names in generated proguard files (#1088)
* Fix reflection names in generated proguard files

Proguard wants to speak reflection names

* Opportunistic clean up proguard tests

This ensures we fail the test if there are any unexpected ones
2020-01-30 22:58:10 -05:00
Zac Sweers
1edcb77f76 Specify exactly which typevars are allowed to top level 2020-01-18 23:11:17 -05:00
Zac Sweers
76b4ec9f92 Add another twist 2020-01-18 23:10:40 -05:00
Zac Sweers
3f0d763ce1 Opportunistic - suppress RedundantExplicitType 2020-01-18 23:08:44 -05:00
Zac Sweers
4e84451d6e Resolve type arguments correctly for supertype settable properties
Resolves #1046
2020-01-18 22:52:18 -05:00
Zac Sweers
a73b932429 Always emit full types
Effectively reverts https://github.com/square/moshi/pull/1041
2020-01-18 22:47:56 -05:00
Zac Sweers
04f414f600 Add ComplexGenericsInheritanceTest 2020-01-18 22:46:54 -05:00
Zac Sweers
4fbf89cd49 Fix mask count in proguard rule gen (#1075)
* Fix mask count in proguard rule generation

Signed,
Person that always forgets how to do modulo counting

* Update tests
2020-01-15 02:42:52 -05:00
Zac Sweers
9a10976aab Minor processor cleanups (#1070)
* Share cachedClassInspector across all rounds

* Don't proceed if previous round failed
2020-01-14 16:28:35 -05:00
Zac Sweers
89b166f9cd Use actual canonical name rather than implicit toString() (#1069) 2020-01-14 15:50:14 -05:00
Zac Sweers
e45d9e04bd Add missing semicolons (#1068) 2020-01-14 15:26:40 -05:00
Zac Sweers
debb7d3160 Generate proguard rules for code gen on demand (#1067)
* Extract target constructor signature into TargetConstructor.kt

We'll need this to know what the runtime types are for proguard rules

* Add ProguardConfig

* Wire in proguard config

* Write proguard configs out with adapters

* Add full tests

* Now remove the rules!

* Ignore on inline classes for now

* Pass adapter constructor params correctly
2020-01-14 14:59:10 -05:00
Zac Sweers
f891c8187b Check types parameter size in init (#1063)
* Add types size check in code gen

Resolves #932

* Add more useful message for mismatched generics lookup

* Add tests

* Style
2020-01-14 01:50:53 -05:00
Nicklas Ansman Giertz
cc4b5b3ad2 Improve the way Json.name is fetched for codegen (#1059)
* Improve the way Json.name is fetched for codegen

* Remove the comment for jsonName

* Add a test for json names with quotation marks

* Fix the broken tests
2020-01-10 21:32:23 -05:00
Zac Sweers
365e955381 Update to KotlinPoet 1.5.0 (#1062) 2020-01-10 21:05:21 -05:00
Zac Sweers
40a829ef18 Don't linebreak keys with spaces (#1053)
* Don't linebreak keys with spaces

Resolves #1052

* Update kotlin/codegen/src/main/java/com/squareup/moshi/kotlin/codegen/api/AdapterGenerator.kt
2019-12-12 02:53:25 -05:00
Zac Sweers
c3a1ba711c Omit unnecessary generic type from standard constructor call (#1041)
These were redundant. Was `return Foo<T>(...)` and is now `return Foo(...)`
2019-12-05 22:37:38 +01:00
Zac Sweers
14cb9e4bbb Add LocalVariableName to common suppressions (#1040)
* Add LocalVariableName to common suppressions

NameAllocator will add underscores to names, which kotlin doesn't like for stylistic reasons

* Simplify structure a bit

Keeping track of template counts is error prone and would have failed only at runtime
2019-12-05 22:37:26 +01:00
Zac Sweers
791ff3211e Update to Kotlin compile testing 1.2.4 (#1014)
* Update to Kotlin compile testing 1.2.4

This allows us to un-toe-hold a test from before

* Fix trailing newline

* Add class-based alternative

* Use updated test API

* Update to 1.2.5

* Update to Kotlin 1.3.60
2019-12-05 22:37:02 +01:00
Zac Sweers
32c5d48ab1 Strip type annotations from TypeRenderer and asTypeBlock() (#1039)
Resolves #1033
2019-12-05 22:35:57 +01:00
Jesse Wilson
b287596c60 [maven-release-plugin] prepare for next development iteration 2019-11-17 09:53:53 -05:00
Jesse Wilson
89a254d644 [maven-release-plugin] prepare release moshi-parent-1.9.2 2019-11-17 09:53:46 -05:00
Zac Sweers
f49f677bfc Suppress common warnings in generated classes (#1028)
* 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
2019-11-17 09:40:49 -05:00
Zac Sweers
4241918d6b Handle enclosing visibility + cache metadata parsing (#1026)
* 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
2019-11-16 22:27:25 -05:00
Zac Sweers
d25abb1ee5 Fix incorrect type variance being applied on generated adapters (#1010)
* 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
2019-11-08 14:35:13 -08:00
Zac Sweers
7cf365cdbf Fix nullable properties (#992)
* 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
2019-11-02 21:55:20 -04:00
Zac Sweers
fe34a577e7 Check against non-nullable known primitives when rendering class… (#993)
* 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
2019-11-02 15:15:29 -04:00
Zac Sweers
c8c7121e76 Unwrap nested typealiases in code gen (#996)
* Add further nested typealias

* Recursively unwrap classnames

The unwrapped alias could be to something other than a classname!
2019-11-02 09:43:08 -04:00
Jesse Wilson
878e9a86d6 [maven-release-plugin] prepare for next development iteration 2019-10-30 23:26:50 -04:00
Jesse Wilson
0af27a39a6 [maven-release-plugin] prepare release moshi-parent-1.9.1 2019-10-30 23:26:43 -04:00
Zac Sweers
092175ae90 Fix handling of typealiases in non-classname envs + wildcard fix… (#987)
* Correctly render non-classname wildcard types

Resolves #984
Resolves #985

* Add thorough typealias test

* Expand unwrapTypeAlias to parameterized and wildcard types

Resolves #983

* Disable Werror for now
2019-10-30 21:15:28 -04:00
Jesse Wilson
ac789070e8 Merge pull request #988 from square/z/regressionForAbstract
Add an abstract non-unit function regression for #974
2019-10-30 21:11:05 -04:00
Zac Sweers
9a0294c3a0 Handle non-property parameters in kotlin code gen (#982)
* 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
2019-10-30 21:06:04 -04:00
Zac Sweers
510d189e4e Add an abstract non-unit function regression for #974
Resolves #974 for good
2019-10-30 20:24:22 -04:00
Zac Sweers
0aacfc7430 Support 32+ parameter constructors in code gen (#978)
* 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
2019-10-30 16:48:00 -04:00
Zac Sweers
4f1c8a5eda Fix support for classes w/ multiple constructors in code gen (#976)
* 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
2019-10-30 00:39:08 -04:00
Jesse Wilson
4637950bab [maven-release-plugin] prepare for next development iteration 2019-10-29 07:57:56 -04:00
Jesse Wilson
0c8005bcee [maven-release-plugin] prepare release moshi-parent-1.9.0 2019-10-29 07:57:49 -04:00