Commit Graph

391 Commits

Author SHA1 Message Date
renovate[bot]
516c005952 Update dependency com.pinterest.ktlint:ktlint-cli to v1.2.0 (#1814)
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.2.0

* Appease ktlint

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-02-28 21:59:39 +00:00
renovate[bot]
b767eeb2c2 Update dependency com.squareup.moshi:moshi to v1.15.1 2024-01-30 18:14:02 +00:00
Jake Wharton
2cc9ebb88e Update formatters to latest
Ensure renovate can bump them by specifying full coordinates in toml.
2024-01-29 12:10:47 -05:00
renovate[bot]
8d54b3baf5 Update dependency com.squareup.moshi:moshi to v1.15.0 (#1676)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-05-21 14:07:31 -04:00
Nicholas DeLello
ef99a13bb7 Make class instances with type parameter info equal to equivalent parameterized types. (#1542)
* Make class instances with type parameter info equal to equivalent parameterized types.

* Add test for flipped version.

* Clean up unnecessary collection calls, do some housekeeping.

* Spotless

---------

Co-authored-by: Zac Sweers <pandanomic@gmail.com>
2023-05-05 22:19:21 +00:00
renovate[bot]
c11f0e168c Update kotlin monorepo (#1614)
* Update kotlin monorepo

* Update ksp to v1.8.0-1.0.9

* Lower metadata to 0.5.0

* Update KCT

* Update to compilerOptions

* Suppress deprecation

* Add missing java target too

* Raise it again because it's broken on all

* Kotlin 1.8.20 + updated kotlinpoet

* Update kotlinpoet

* Update kotlin

* Fix KSP equality check for KotlinPoet 1.13.x

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <github@jakewharton.com>
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
2023-05-05 18:04:57 -04:00
Elgun Jabrayilzade
9ca9ce0428 remove obvious comment 2023-04-17 06:24:28 +00:00
renovate[bot]
8a098d6a07 Update dependency gradle to v8 (#1630)
* Update dependency gradle to v8

* Remove VERSION_CATALOGS feature

* Match JDK 19 in toolchain

* Update forces + fix japicmp version

* ???

* Another

* Update japicmp

* Update shadow plugin

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
2023-02-25 18:36:04 +00:00
renovate[bot]
e6110de8c3 Update plugin spotless to v6.14.0 (#1620)
* Update plugin spotless to v6.14.0

* Update Spotless version and apply

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2023-01-30 14:03:50 +00:00
Jesse Wilson
c9f8c56efc Update changelog for 1.14.0 2022-09-06 14:36:42 -04:00
Zac Sweers
53bb46c208 Remove redundant opt-in flags (#1544)
* Remove "-opt-in=com.squareup.kotlinpoet.ksp.KotlinPoetKspPreview"

Unused now

* Remove redundant -opt-in=RequiresOptIn
2022-06-13 17:11:29 -04:00
Zac Sweers
e95af32df8 Update dependencies + Kotlin 1.7 + KotlinPoet 1.12.0 (#1543) 2022-06-13 17:02:27 -04:00
Zac Sweers
fd128875c3 Remove a couple leftover TODOs (#1513) 2022-01-23 18:47:25 -05:00
Zac Sweers
2c9e3d036a Convert LinkedHashTreeMap to Kotlin (#1508)
* Initial pass at converting LinkedHashTreeMap to Kotlin

* Update tests as needed

* Remove Arrays use

* Separate find nullability

* Clean up a few expression bodies

* Various little cleanups and warnings

* Sprinkle in some knownNotNulls where useful

* add() is not implemented

* clean up some visibility and properties that can be fields

* Some minor formatting

* Some minor formatting
2022-01-23 18:03:25 -05:00
Zac Sweers
b2a67760d4 Explicitly denote util public APIs in japicmp (#1511) 2022-01-21 17:22:13 -05:00
Zac Sweers
c5e98e5be8 Small cleanups from a few past PRs (#1509) 2022-01-20 10:23:22 -05:00
Zac Sweers
c5be69a93c Tighten up visibility of APIs in Util.kt (#1510) 2022-01-20 10:22:52 -05:00
Spencer Griffin
9e5fc24f4f Convert ClassJsonAdapter to kotlin (#1470) 2022-01-19 00:25:06 -05:00
Spencer Griffin
57df98b9b1 Convert AdapterMethodsFactory.java to kotlin (#1467)
* Rename AdapterMethodsFactory from java to kt

* Convert AdapterMethodsFactory.java to AdapterMethodsFactory.kt

* Make kotlin more idiomatic

* Use forEach loop

* Spotless

* More idiomatic kotlin

* Inline toString

* Address comments from PR

* Address comments in PR review

* Spotless

* Use templated string for error message

* Add japicmp exclusion for internal AdapterMethodsFacotry#get method

* Convert if to when

* Convert if to when

* Use templated strings

* Replace forEach with for loop

* Simplify expression

* Add local val to avoid cast

* Update moshi/src/main/java/com/squareup/moshi/AdapterMethodsFactory.kt

Co-authored-by: Zac Sweers <pandanomic@gmail.com>

* Better variable names

* Exclude entire AdapterMethodsFactory class in japicmp

* Update moshi/src/main/java/com/squareup/moshi/AdapterMethodsFactory.kt

Co-authored-by: Zac Sweers <pandanomic@gmail.com>

* Update moshi/src/main/java/com/squareup/moshi/AdapterMethodsFactory.kt

Co-authored-by: Zac Sweers <pandanomic@gmail.com>

* Update moshi/src/main/java/com/squareup/moshi/AdapterMethodsFactory.kt

Co-authored-by: Zac Sweers <pandanomic@gmail.com>

* Update moshi/src/main/java/com/squareup/moshi/AdapterMethodsFactory.kt

Co-authored-by: Zac Sweers <pandanomic@gmail.com>

* Import knownNotNull

* Add requireNull in Util to create error message

* Rename argument

* Convert error message to raw string

* Use generateSequence to iterate through the superclasses

* Use it rather than complicated name

* Rename requireNull to checkNull, and remove contract

* Fix tests since error type changed

* Update moshi/src/main/java/com/squareup/moshi/internal/Util.kt

Co-authored-by: Spencer Griffin <sgriffin@ancestry.com>
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
2022-01-18 22:45:42 -05:00
Zac Sweers
178a6858ff Switch fully over to dokka and fix accidental root project publishing (#1507) 2022-01-17 13:04:35 -05:00
Zac Sweers
47697c2601 Convert JsonReader to Kotlin (#1505)
* Rename .java to .kt

* Convert JsonReader to Kotlin

Made it sealed along the way like JsonWriter

Some of the properties had different docs for setting and getting, which dokka doesn't seem to have a nice way to differentiate. Went with a little marked up form but open to suggestions.

* Restore isLenient name to lenient

This plays nice for both java and kotlin consumers, as it's still isLenient to java consumers but not a source breaking change for kotlin

* Fix peek nullability and a kotlin source change

* Fix another nullability

* Use collection builders

* Ok this didn't work quite as I expected

* Update moshi/src/main/java/com/squareup/moshi/JsonReader.kt

Co-authored-by: Parth Padgaonkar <1294660+JvmName@users.noreply.github.com>

Co-authored-by: Parth Padgaonkar <1294660+JvmName@users.noreply.github.com>
2022-01-17 02:52:02 -05:00
Zac Sweers
e6081dc90e Skip nullchecks on known primitives (#1506) 2022-01-17 02:07:55 -05:00
Spencer Griffin
71c32934bf Convert ClassFactory.java to kotlin (#1469)
Co-authored-by: Spencer Griffin <sgriffin@ancestry.com>
2022-01-13 01:26:08 -05:00
Zac Sweers
1fdc61dc31 Update a few misc build deps (#1500) 2022-01-12 13:50:48 -05:00
Zac Sweers
9ac2ddf2db Finish up JsonWriter Kotlin conversion (#1501)
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
Co-authored-by: Goooler <wangzongler@gmail.com>
2022-01-12 13:47:35 -05:00
Spencer Griffin
ff2f6e18d2 Convert ArrayJsonAdapter.java to kotlin (#1468)
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
Co-authored-by: Spencer Griffin <sgriffin@ancestry.com>
2022-01-12 13:42:42 -05:00
Zac Sweers
396342b06b Convert RecordJsonAdapter to Kotlin (#1493) 2022-01-11 15:39:31 -05:00
Zac Sweers
d805ad1b5b Keep @FromJson/@ToJson-annotated methods in proguard (#1499) 2022-01-11 15:00:34 -05:00
Zac Sweers
1b582e4647 Convert JsonValueReader to Kotlin (#1487) 2022-01-11 13:29:16 -05:00
Zac Sweers
0a6565bb46 Convert JsonUtf8Writer to Kotlin (#1486) 2022-01-11 13:08:48 -05:00
Zac Sweers
ec3977160b Convert Types to Kotlin (#1488) 2022-01-11 12:55:33 -05:00
Zac Sweers
156e9007fd Convert JsonValueSource to Kotlin (#1489)
* Rename .java to .kt

* Convert JsonValueSource to Kotlin
2022-01-10 12:23:09 -05:00
Zac Sweers
d7b70637d2 Convert MapJsonAdapter to Kotlin (#1492)
* Rename .java to .kt

* Convert MapJsonAdapter to Kotlin

* Pull up factory into companion object

* Spotless

* apicmp

* Use knownNotNull

* Use a template
2022-01-10 12:22:15 -05:00
Zac Sweers
31b7a11027 Inline Moshi extension functions to Moshi itself (#1496)
* Move inline extensions to Moshi(.Builder) directly

No need for the separation and it allows removing of the import

* Remove now-redundant imports
2022-01-10 12:22:02 -05:00
Zac Sweers
59afd4bb9b Convert JsonValueWriter to Kotlin (#1491)
* Rename .java to .kt

* Convert JsonValueWriter to Kotlin

* Use knownNotNull

* when of whens

Co-authored-by: Parth Padgaonkar <1294660+JvmName@users.noreply.github.com>

* Nix the return

* Clean up

Co-authored-by: Parth Padgaonkar <1294660+JvmName@users.noreply.github.com>
2022-01-10 12:21:14 -05:00
Zac Sweers
6e81499501 Convert StandardJsonAdapters to Kotlin (#1494)
* Rename .java to .kt

* Convert StandardJsonAdapters to Kotlin

* Inline factory to object

* Idiomatic cleanups + japicmp

* Fixes

* Another idiomatatic bit

* Use knownNotNull() where applicable
2022-01-10 12:14:07 -05:00
Zac Sweers
323d97c787 Convert JsonAdapter to Kotlin (#1475)
* Rename .java to .kt

* Convert JsonAdapter to Kotlin

Note that there's more to be done here I think, namely exploring removing the NonNull adapter and making the nullSafe() adapter public so that nullability is directly in the API. Saving that for another day though

* Update a couple usages

* Fix override

* Add exclusion for open

* Add `@Language` annotation for json strings

Allows the IDE to automatically make this pretty

* Spotless

* Nullable

Co-authored-by: Egor Andreevich <egor@squareup.com>

* When

Co-authored-by: Parth Padgaonkar <1294660+JvmName@users.noreply.github.com>

* Another when

* Spotless

Co-authored-by: Egor Andreevich <egor@squareup.com>
Co-authored-by: Parth Padgaonkar <1294660+JvmName@users.noreply.github.com>
2022-01-10 11:29:37 -05:00
Zac Sweers
6f8d690e6e Convert JsonScope to Kotlin (#1484)
* Rename .java to .kt

* Convert JsonScope to Kotlin

* Use buildString
2022-01-10 11:08:36 -05:00
Zac Sweers
2daf78337d Convert Collection adapter to Kotlin (#1485)
* Consolidate contract utils

* Rename .java to .kt

* Convert CollectionJsonAdapter to Kotlin

* Lift factory into companion object

* Update moshi/src/main/java/com/squareup/moshi/internal/Util.kt
2022-01-10 11:07:57 -05:00
Zac Sweers
32932cfb40 Convert exceptions to Kotlin (#1483)
* Rename .java to .kt

* Convert exceptions to kotlin

* Add missing empty constructor
2022-01-10 11:07:48 -05:00
Zac Sweers
56e1ae6404 Use Okio IOException in Kotlin classes (#1490)
More portability!
2022-01-07 21:02:16 -05:00
Zac Sweers
e2c346e1de Convert util package to Kotlin (#1461)
* Rename .java to .kt

* Convert NonNullJsonAdapter

* Rename .java to .kt

* Convert NullSafeJsonAdapter

* Fix missing null-check

* Rename .java to .kt

* Convert Util (initial pass)

* Push to top-level Util

* Use extensions and properties where possible

* Use knownNotNull

* Spotless

* Clean up impl type classes a bit

* Update code gen

* Use extension for resolving

* Spotless

* Fix master conflicts

* Rename to toStringWithAnnotations()

* for (t in args.indices) {

* for (i in interfaces.indices) {

* Template
2022-01-06 14:54:13 -05:00
Zac Sweers
e5e4c48767 Convert Moshi annotations to Kotlin (#1472) 2022-01-03 13:53:56 -05:00
Zac Sweers
82cf56ab76 Fix javadoc task and snapshots (#1474)
The javadoc task assumes every doc starts with h1 and thus using them anywhere in the body after the start is an error ¯\_(ツ)_/¯. This just changes them to h2
2021-12-26 17:55:43 -06:00
Zac Sweers
f0b886f129 Fix exhaustive when in JsonUtf8Reader (#1473)
* Fix exhaustive when in JsonUtf8Reader

This accidentally snuck into master because it predates the Kotlin 1.6 upgrade

* Fix nextInt too

* Clean up a few little warnings opportunistically

* Fix comment

* Use knownNotNull
2021-12-26 17:07:52 -06:00
Parth Padgaonkar
c49daf907b JsonUtf8Reader --> Kt (#1400)
* initial attempt

* passing tests

* cleanup

* Apply suggestions from code review

Co-authored-by: Jake Wharton <github@jakewharton.com>

* split `also` to two lines

* remove !! and labels

* spotless

* Apply suggestions from code review

Co-authored-by: Jake Wharton <github@jakewharton.com>

* clean up a few more things

* pull duplicated code into an inline fun

* missed one

* refactor double field evaluation to inline fun

* spotless

* Apply suggestions from code review

Co-authored-by: Jake Wharton <github@jakewharton.com>

* var -> val

Co-authored-by: Jake Wharton <github@jakewharton.com>
2021-12-26 16:05:55 -06:00
Zac Sweers
f3d2103ffb Convert Moshi.java to Kotlin (#1462)
* Rename .java to .kt

* Migrate Moshi.java to Moshi.kt

* Idiomatic cleanups

* Move comments down

* Apply suggestions from code review

Co-authored-by: Egor Andreevich <egor@squareup.com>

* Small little cleanups

Co-authored-by: Egor Andreevich <egor@squareup.com>
2021-12-26 15:49:52 -06:00
Zac Sweers
82987854df Remove redundant static modifiers on records
They are implicit
2021-12-20 16:46:39 -05:00
Zac Sweers
2e15a3fa72 Update moshi version used for japicmp (#1459) 2021-12-12 04:03:03 -05:00
Jesse Wilson
7401e82b9b Submit to Javadoc's draconion heading ordering rule (#1452)
Whoever thought this was a good idea is wrong.

    > Task :moshi:javadoc
    /home/runner/work/moshi/moshi/moshi/src/main/java/com/squareup/moshi/JsonWriter.java:40: error: heading used out of sequence: <H3>, compared to implicit preceding heading: <H1>
     * <h3>Encoding JSON</h3>
       ^
    /home/runner/work/moshi/moshi/moshi/src/main/java/com/squareup/moshi/JsonReader.java:40: error: heading used out of sequence: <H3>, compared to implicit preceding heading: <H1>
     * <h3>Parsing JSON</h3>
       ^
2021-12-09 06:07:44 -05:00