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

77 Коммитов

Автор SHA1 Сообщение Дата
Ben Bader 55e74b550d
Cache more things in build-src and integration tests (#517) 2022-12-13 11:13:13 -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 f9c1099d55
Implement Java codegen for struct-valued constants (#503) 2022-12-07 17:07:00 -07:00
Ben Bader d7d09987f0
Remove deprecated JvmDefault annotations (#481) 2022-04-14 19:01:14 -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 4c569057e6
Fix simple Kotlin deprecations in thrifty-runtime (#471) 2022-04-11 21:08:59 -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 f516c01fea
Update CLI and documentation for 3.0.0 release (#451) 2021-06-21 08:34:45 -06:00
Ben Bader 334dca1ba8
Use non-deprecated 'beInstanceOf' matcher (#435) 2021-02-11 17:18:01 -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 d333322d78
Switch Kotlin structs to builderless by default (#414) 2020-12-17 23:33:35 -07:00
Ben Bader cefa407e74
Add Okio-based convenience APIs to thrifty-runtime (#408) 2020-12-15 12:05:17 -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
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 5a7b8606c3
Bump okio from 1.14.1 to 2.6.0 (#348) 2020-05-19 21:19:35 -07:00
Ben Bader 492ae9565d
Remove redundant, obsolete, etc configuration from build.gradle files (#354) 2020-05-16 22:39:40 -07:00
Ben Bader adff16b5e1
kotlintest 3.1.8 -> kotest 4.0.5 (#346) 2020-05-15 11:52:22 -07:00
Ben Bader cd2fb0cd88
Bump shadow-jar to 5.2.0 (#342)
Also, remove some deprecated uses of the shadowJar task's `archivePath`
property, taking the opportunity to more lazily configure test tasks.
2020-05-14 11:05:53 -07:00
Ben Bader d0d906d916
Support redaction/obfuscation for kotlin unions (#312) 2019-04-22 23:32:34 -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 b5792afa72
Specify that a successful parse consumes all input (#300)
Prior to this commit, our generated antlr parser would happily stop midway through a file if it discovered a token it couldn't handle, such as a semicolon at the top level.  This was treated as a successful parse, leading to surprising cases of missing generated structs.

Fixed here by adding `EOF` to the end of our top-level `document` definition, which is the antlr way of saying "consume all input or else it is an error".

Fixes #297
2019-02-06 22:10:51 -08:00
Ben Bader 6da980e895
Clean up union adapters and test builderless adapters (#299) 2019-02-06 22:06:03 -08:00
Thibault Duperron d1fc321541 Kotlin generate union as sealed class (#253) 2019-02-04 10:13:09 -08:00
Ben Bader bb062505ea
Integration test for unions (#263) 2018-11-05 11:05:14 -08:00
Ben Bader 00bbd2e0a9
Support configurable @Generated annotation types (#259) 2018-11-02 14:13:02 -07:00
Ben Bader 78f0a79430
Bump errorprone, only use it on Java modules (#255) 2018-10-30 11:04:21 -07:00
Ben Bader 4490117b05
Update to Kotlin 1.3 (#254) 2018-10-30 10:41:04 -07:00
Ben Bader d510978323
Add missing license headers (#229) 2018-08-15 17:02:37 -07:00
Ben Bader 2486c21a39
Kotlin: generate coroutine-based service clients (#225)
This is the simplest possible coroutine implementation. It's a thin veneer over the AsyncClientBase code, using suspendCoroutine to get at the raw Continuation object which is passed to the generated MethodCall callbacks.

We can explore more interesting implementations as coroutine I/O is finalized by JetBrains.

Fixes #211
2018-08-15 13:15:24 -07:00
Ben Bader a8cd8f826f
Add missing call to protocol.readMessageEnd() (#224)
We've missed this since the beginning because BinaryProtocol and CompactProtocol both send and receive nothing for message end.  JsonProtocol, however, is sensitive to this.  Adding calls to `readMessageEnd()` for both normal and exceptional results fixes things.
2018-08-14 14:28:24 -07:00
Ben Bader 2785ae1f09
Fix read methods for maps of collections (#220) 2018-08-08 17:06:57 -07:00
Ben Bader 6382545567
Fix scope collisions between enums in maps (#218)
In #217, we fixed broken generated Java for maps of enum types.  As it happens, the same thing was broken in Kotlin.  This commit fixes it.
2018-08-08 14:51:39 -07:00
Ben Bader 3364494579
Kotlin/builderless adapters (#215) 2018-08-07 10:04:27 -07:00
Ben Bader d7af683722
Support custom collection types in Kotlin code (#214) 2018-08-06 16:49:51 -07:00
Ben Bader c3686b52f8
Change command-line flags (#212)
Instead of `--emit-kotlin`, we're adding a `--lang` option defaulting to Java. Instead of `--use-java-style-names`, we're adding `--name-style` defaulting to, well, "default", but that can also be "java" (or potentially other styles as well).

This change also attempts to infer language if it is unspecified - in this case, if `--kt-file-per-type` is specified, but `--lang` is not, we assume that `--lang=kotlin` was intended.

Fixes #209

#209 envisioned a bigger revamp of the CLI, but on further thought we don't need to go to such lengths. Just providing options (instead of boolean flags) for a few params and introducing `--lang` are enough to keep the CLI reasonable.
2018-08-06 11:46:27 -07:00
Ben Bader a18d577bf1
Generate typealiases for typedefs (#206) 2018-08-05 18:07:36 -07:00
Ben Bader 6cfcbd4b67
Kotlin services (#197)
This is good enough to get the next release out the door, but is not the end of the story for services.  I still want to investigate a coroutine-based client, but that's a larger project potentially involving a kotlin-specific version of `thrifty-runtime` to support it.
2018-08-04 11:36:43 -07:00
Ben Bader 3d33badd83
Allow int literals for consts of type double (#195) 2018-07-31 15:54:05 -07:00
Ben Bader 0b5c3e9cb4
Use NameAllocators to avoid name conflicts (#194) 2018-07-31 15:29:58 -07:00
Ben Bader 32fa3ac5de
CLI rework, kotlin codegen bugfix, build ordering bugfix (#187) 2018-07-30 21:30:52 -07:00
Dino Kovač 4c5e96b38d Json Protocol support (#156)
Add Json Protocol support
2017-11-18 09:45:12 -08:00
Dino Kovač 39b99da82a Fix reading bool value using compact protocol (#153)
We came across an issue in deserializing a bool value using compact protocol - the value always comes out false.

This PR modifies the test so that it catches this bug and fixes it.
2017-08-09 15:11:41 -07:00
Gabriel Ittner dac643223c Split ClientBase to enabled synchronous calls (#147) 2017-06-24 12:43:38 -07:00
Ben Bader 03c5e7b098 Apply codecov.io configuration (#134) 2017-03-09 14:21:28 -08:00
Ben Bader e6f1cb7298 Add JaCoCo report generation (#127) 2017-03-08 13:29:16 -08:00