Граф коммитов

72 Коммитов

Автор SHA1 Сообщение Дата
Ben Bader fc3d9881d4
Don't enable Dokka or signing unless publishing (#515) 2022-12-12 20:36:28 -07:00
Ben Bader 49e34f280e
Make TestServer instances reusable for whole suites (#513)
* Make TestServer instances reusable for whole suites

* Fix subtle test bug at 0 nanos past the second
2022-12-09 15:35:06 -07:00
Ben Bader d595d639bb
Support omit and emit of field default values in struct constants (#507) 2022-12-08 13:07:45 -07:00
Ben Bader f9c1099d55
Implement Java codegen for struct-valued constants (#503) 2022-12-07 17:07:00 -07:00
Sha Sha Chu c2d854b7e5
Add generated comments to Kotlin files (default true) (#486)
Will respect the existing `--omit-file-comments` flag

Fixes #485
2022-05-23 15:59:11 -06:00
Ben Bader 96a7179355
Guava 31 Multimaps never return null so we don't need safe calls on them (#483) 2022-04-15 22:18:40 -06:00
Ben Bader 6325d9c949
Add kotlin-codegen support for struct-valued constants (#482) 2022-04-15 22:08:42 -06:00
Ben Bader 9747f7d343
Fix more Kotlin deprecations and warnings (#480) 2022-04-14 18:16:27 -06:00
Ben Bader 5f908e53be
Update kotlinpet to 1.11.0, fix tests (#477) 2022-04-14 15:38:38 -06:00
Ben Bader 86e89af427
Move version catalog into TOML file, put plugins there (#472) 2022-04-11 23:29:58 -06:00
Ben Bader e38faa544d
Fix various Gradle deprecations around version catalogs (#470) 2022-04-11 17:11:18 -06:00
Lucas Romero b28da74d6b
Add Server support (#447)
* Expose synthetic structs for method args and result

* Make ThriftException a Struct

and make kind required (there is an "unknown" type anyways)

* Move type holders to class level in order to allow for methods to write to them

* Add runtime classes for server support

* Add server support

* Update README

* Clear type outputs at the beginning of generate()

in case the generator gets re-used

* clean up imports

* remove @JvmOverloads

* import all the things

* Remove wildcard import

* Use hand-built ClassNames instead of direct type references

in order to try to be as compatible with Kotlin Multiplatform as
possible.

* Generate server-specific interface

in a server-specific namespace instead of reusing the client interface.
This is necessary because we always want to generate a coroutine based interface for the server and never a callback based one.

* Support compilation of multiple FileSpecs as a unit

because now we generate a separate FileSpec for the server that also need the types from the "normal" FileSpec.

* Move server integration test to "normal" task

as it no longer requires the coroutine client flag to be set.

* Add license headers

* Add license to thrift test code

* Fix README
2021-09-21 09:11:09 -06:00
Ben Bader 7bdb221058
Replace subprojects/allprojects with buildSrc and version catalogs (#456) 2021-08-01 21:22:45 -06:00
Ben Bader 1afd1bcf92
Add missing license headers and a script to check that new files have them (#450)
Add missing license headers and a script to check that new files have them
2021-06-20 22:04:47 -06:00
Lucas Romero 27438c5f3e
Fix builder class generating name clash if union contains field named "error" (#444)
* Check if specs compile in tests

* Show name clash between field name and kotlin error()

* Use fully-qualified reference to allow KotlinPoet to disambiguate
2021-04-05 01:36:13 -06:00
Lucas Romero e218285262
Update kotlinpoet to 1.8.0 (#446)
* Update kotlinpoet to 1.8.0

* Fix tests

* Emit names using %N to take advantage of automatic escaping

* Update test to reflect changes
2021-04-03 18:55:37 -06:00
Ben Bader 69bb54eed5
Kotlinpoet 1.6.0 -> 1.7.2 (#431) 2021-02-11 00:16:53 -07:00
Sha Sha Chu 20cb33d02b
Adding support for alternative Kotlin enum generation (#421)
* Add big enum support

* add test

* fixing typos
2021-02-04 09:47:00 -07:00
Ben Bader 314fb846b2
Make JvmStatic opt-in and fix an erroneous usage (#417)
* Make JvmStatic opt-in and fix an erroneous usage

* Fix broken test
2020-12-19 16:02:53 -07:00
Ben Bader 84bd3f570a
Empty structs use literal class name for hashCode (#415) 2020-12-18 09:48:32 -07:00
Ben Bader d333322d78
Switch Kotlin structs to builderless by default (#414) 2020-12-17 23:33:35 -07:00
Ben Bader 372ebd78ad
Remove references to java exceptions in generated Kotlin (#412)
* Remove references to java exceptions in generated Kotlin

* Fix integration tests - wow that setup is terrible
2020-12-17 22:27:26 -07:00
Ben Bader 21acff49fc
Use kotlin.collections typealiases of java.util types by default (#411) 2020-12-17 17:23:06 -07:00
Ben Bader 3b897501a3
Fix Kotlin builderless structs with fields named 'result' (#405) 2020-11-23 11:06:27 -07:00
Ben Bader 8bf93eae1f
Remove all support for '@Generated' annotations (#402) 2020-10-02 23:05:36 -06:00
Kirill 5a724f679f
Introducing flag to add a required builder constructor (#398)
* Introducing flags to add a required builder constructor and omit empty builder constructor

* Making sure not to create constructor if it is empty

* Removingy omitBuilderEmptyConstructor

* Adding deprecated annotation when required constructor is present

* Adding extra documentation, simplifying test
2020-08-27 16:06:27 -07:00
Ben Bader 80946e248b
Remove the now-redundant thrifty-runtime-ktx (#397)
* Remove the now-redundant thrifty-runtime-ktx

* Add kotlinx-coroutines-core to thrifty-runtime
2020-08-24 16:04:29 -07:00
Ben Bader c9be396db8
JUnit 4 -> 5 (#396) 2020-08-24 09:16:49 -07:00
Ben Bader 5a7f320171
Convert thrifty-runtime to kotlin, require Java 8 (#391)
* Convert thrifty-runtime to kotlin, require Java 8

* Remove erroneous nits in KotlinCodeGenerator

* New kt files should end with a newline

* Fix artifacts from Java->Kotlin conversion, use better idioms
2020-08-23 18:43:51 -07:00
Ben Bader 15cb49f352
Kotlinpoet 1.5.0 -> 1.6.0 (#380) 2020-08-21 22:51:18 -07:00
guptadeepanshu 01f5b46e45
Yet another non-breaking space fix (#361) 2020-06-04 14:00:34 -07:00
guptadeepanshu 9e4361b238
Fix null check in reading enum values (#360)
Bug was introduced in PR #357. `.let` does nothing. It should be `?.let`
2020-06-04 14:00:01 -07:00
guptadeepanshu a7aa99d6f9
Use non-breaking space to ensure valid code (#359) 2020-06-04 12:40:20 -07:00
guptadeepanshu 4c4cee6d47
Add option to not throw on unknown enum values (#357)
Add option to not throw on unknown enum values

Fixes #320
2020-06-03 09:09:37 -07:00
Ben Bader 672a6b6710
Bump truth to 1.0.1, compile-testing to 0.18 (#347)
* Bump truth to 1.0.1, compile-testing to 0.18

* Remove spurious compile-testing dependency from thrifty-kotlin-codegen
2020-05-15 12:20:09 -07:00
Ben Bader adff16b5e1
kotlintest 3.1.8 -> kotest 4.0.5 (#346) 2020-05-15 11:52:22 -07:00
Ben Bader e1a390e2bf
Move to gradle-maven-publish-plugin (#343) 2020-05-15 00:41:11 -07:00
Ben Bader d022622a99
Upgrade kotlinpoet from 1.0.0-RC1 to 1.5.0 (#334) 2020-05-13 21:59:00 -07:00
Jon Parise 5f08b0dc97
Introduce a --kt-emit-jvmname option (#332)
When specified, `@file:JvmName(name)` annotations will be added to all
of the generated files. This improves the usability of importing these
Kotlin-based classes into Java code modules (e.g. as `foo.Constants`
instead of `foo.ConstantsKt`).

This would ideally be the default behavior, but it's introduced as an
opt-in compiler option to avoid breaking backwards compatibility.
2020-05-12 17:02:00 -07:00
Jon Parise 5c5e70f16c
Remove unneeded/temporary code lines (#331)
It doesn't look like these lines of code were intended to be committed.
2020-05-12 09:58:24 -07:00
Jon Parise ce8960d40b
Introduce an --omit-service-clients option (#330)
When specified, no service clients will be generated. We only support
service clients in the Kotlin generator, so this is implicitly a
Kotlin-only option, but it's not prefixed with `kt` because it could
apply to Java in the future.

This is useful for projects that only need Thrift-generated structures,
etc. and won't use Thrift service calls.
2020-05-08 11:07:47 -07:00
Ben Bader d0d906d916
Support redaction/obfuscation for kotlin unions (#312) 2019-04-22 23:32:34 -07:00
Ben Bader cab9fecb60
Pascal-case sealed type names (#310)
* Pascal-case sealed type names

* Fix typo and add test case
2019-04-22 09:53:43 -07:00
Ben Bader 33d97fa8c9
Implement default values for unions (#308)
This adds support in generated Kotlin code for unions that have default values.

Unions are currently represented as sealed types; the default value, if present, will be a static val on the base sealed type. For example, given the following thrift:

```
union Sample {
  1: string Foo = "bar";
}
```

this will emit (partial code):

```
sealed class Sample : Struct {
  companion object {
    @JvmStatic
    val DEFAULT: Sample = Foo("bar")
  }

  ...
  class Builder {
    private var value: Sample? = DEFAULT
   ...
  }

  ...
  class Adapter {
    override fun read(protocol: Protocol): Sample {
      var result: Sample = DEFAULT
      ...
    }
  }
}
```

The only point about which I'm uncertain is the Adapter.read method; it's not clear to me whether we should assume a default value if no value (or no expected value) is received; the remote end may have a different idea about what the default value is. I expect we'll never revisit this point due to the obscurity of the feature, but have called out the question as a TODO.

Fixes #303.
2019-04-19 22:36:32 -07:00
Ben Bader 6da980e895
Clean up union adapters and test builderless adapters (#299) 2019-02-06 22:06:03 -08:00
Ben Bader bad79488b5
Clean up union builders (#296) 2019-02-06 17:33:40 -08:00
Ben Bader 5334415bdf
Implement custom toString for kotlin unions (#294) 2019-02-06 15:24:57 -08:00
Ben Bader 87c7279bff
Validate Kotlin unions in builder ctors (#288)
Also, change the representation of an empty union from an empty sealed class (which can never be instantiated) to a plain-old empty class.

TODO: toString for empty union, toString for sealed class leaf-nodes.

Fixes #285
2019-02-04 20:49:09 -08:00
Thibault Duperron d1fc321541 Kotlin generate union as sealed class (#253) 2019-02-04 10:13:09 -08:00
Ben Bader 00bbd2e0a9
Support configurable @Generated annotation types (#259) 2018-11-02 14:13:02 -07:00