Commit Graph

202 Commits

Author SHA1 Message Date
Zac Sweers
ce45a68cc3 Small grammar and naming followups for proguard gen (#1365) 2021-07-16 03:06:43 -04:00
Steve SeongUg Jung
72f464bbdc Add an argument to be disable proguard code generating (#1353)
Co-authored-by: SeongUg Jung <seongug.jung@hanwha.com>
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
2021-07-15 21:24:31 -04:00
Zac Sweers
e343751593 Update to Kotlin 1.5 (and associated deps) (#1339) 2021-05-07 12:51:33 -04:00
Zac Sweers
7372baaaa0 Invoke constructor directly if all params with default are set (#1326)
Resolves #1302
2021-03-29 21:47:22 -04:00
wrongwrong
37f34e16f0 Improve KotlinJsonAdapter performance by invoke KFunction by "call". (#1286) 2021-03-29 20:46:42 -04:00
Zac Sweers
bcfce60577 Warn on missing TypeElement rather than error (#1323)
One example I found for this is when a property is annotated with android's `@SuppressLint`, which is only available from the android jar and not visible during apt. This should just be a warning (if even?) and not a hard error.
2021-03-29 20:44:55 -04:00
Zac Sweers
103b60328c Improve readability of constructor invocation params (#1312) 2021-03-13 20:52:25 -05:00
Zac Sweers
3bc47519ab Fix reading property function types (#1311) 2021-03-13 20:47:52 -05:00
Zac Sweers
935f8b872a Support generic arrays with defaults in code gen (#1310) 2021-03-13 20:47:27 -05:00
Masatoshi Kubode
156b1f0365 Fix a crash when processing a parameter annotated with an annotation that placed in annotation package (#1287)
* Update KotlinPoet to 1.7.2

* Fix a Java NPE crash when processing a parameter annotated with an annotation that placed in annotation package

This problem happens with KotlinPoet 1.7.x.
From KotlinPoet 1.7.x, `TypeName.toString()` is escaped with backquotes if the package name contains keywords.
So NPE will be thrown if an annotation is placed in `annotation` package because `elements.getTypeElement(it.typeName.toString())` returns `null`.

* Reformat imports

* Use rawType().canonicalName instead of toString()

* Fix test case

* Require getTypeElement

* Exclude com.google.guava from shadowJar

* Move a test case of processing a qualifier placed in `annotation` package

* Use checkNull instead
2021-02-22 02:43:04 -05:00
Zac Sweers
7f1e7e229e Suppress some poet deprecations (#1306) 2021-02-20 23:27:56 -05:00
Zac Sweers
99ebab66c0 Reserve simple type names referenced by properties to avoid collisions (#1305) 2021-02-15 13:02:28 -05:00
Zac Sweers
6b09dc443d Suppress RedundantVisibilityModifier in generated adapters (#1303) 2021-02-15 12:58:14 -05:00
Zac Sweers
6e5bb3a29b Prepare project for Kotlin migration (#1257) 2021-02-02 13:11:38 -05:00
Zac Sweers
8518f47f52 Update dependencies (#1258) 2021-02-02 13:11:20 -05:00
Zac Sweers
230c3d801f Promote Kotlin type-inferring APIs to the main Moshi package (round 2!) (#1202)
* Make moshi-root a kotlin project

* Move moshi kotlin extensions to moshi core

* Add appropriate experimental annotations

* Add nextAdapter helper

* Add explicit return type on addAdapter

* Expression body for adapter

* Use nextAdapter helper

* Opportunistically fix a couple Util warnings

* Add Types extensions

* Spotless

* Use extensions in more places for added coverage

* Apply java versions on any java plugin type

This way the kotlin projects get this too

* Fix circularAdapters test?

* Use java 8 in java for code gen too

* Fixup with CircularAdaptersTest

* Add coverage for remaining

* Remove nextAdapter

* Remove leftover function

* Use asserts

left checkNotNull for the contract

* boxIfPrimitive

* Fixup docs

* Copyright fixes

* Add parameterized addAdapter

* Switch to using native javaType API

* Spotless

* Back to 2019

* Spotless

* Use rawType extension

* Fix rebase issues
2020-10-04 18:18:52 -04:00
Zac Sweers
f17e7c2584 Fix infinite loop with type var variance stripping + remove from API (#1246)
* Add test case

* Add TypeVariableResolver to handle backward referencing type vars

* Copy nullability in typevars
2020-10-04 18:10:49 -04:00
Zac Sweers
5ce092857a Fix some misc deprecated KotlinPoet APIs (#1249)
* Move off of deprecated AnnotationSpec.className

* Simplify generatedType check and avoid deprecated KP API
2020-10-04 18:03:45 -04:00
Zac Sweers
f192473419 Standardize (almost) all tests on Truth (#1242)
* Replace assertj calls with Truth where possible

* Update test dependencies

* adapters

* reflect

* codegen

* moshi

* Add missing inOrder()

* Spotless
2020-09-26 20:38:39 -04:00
Zac Sweers
bc85227f29 Add JsonString recipe to examples (#1230)
* Start recipes module with JsonString recipe

* Make recipes a kotlin project

* Move JsonString sample to examples

* Add license

* Include all java modules

* Add kotlin options

* Spotless

* Remove jvmtarget

I was today years old when I found out 1.7 isn't a valid target

* Make gradle happy

* Add codegen

* Spotless
2020-09-25 22:51:05 -04:00
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