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

628 Коммитов

Автор SHA1 Сообщение Дата
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 0483dbac8a
Prepare next development version 2020-05-08 11:04:31 -07:00
Ben Bader baa42e5c17
Release version 2.0.1 2020-05-04 14:02:47 -07:00
Ben Bader 751b8c6698
Prepare next development version 2020-04-29 00:13:11 -07:00
Ben Bader a5f920e85c
Release version 2.0.0 2020-04-28 23:45:28 -07:00
Jon Parise 712b73f578
Print LoadFailedException cause on load failure (#328)
LoadFailedException wraps a list of error reports. In the load path,
these reports are primarily added by the parser, but we also construct
LoadFailedException objects to wrap FileNotFoundException instances.

The compiler previously only printed the formatted reports. Other
wrapped exception causes were effectively swallowed which lead to
ambiguous compilation failures when an included .thrift file couldn't be
loaded, for example.

This change prints the underlying cause when the LoadFailedException
doesn't have any error reports. This feels like a good compromise that
addresses the root problem of certain exception cases being swallowed.

Alternatively, we could avoid wrapping FileNotFoundException and let is
bubble up on its own, but that would be a change from the currently
documented "contract" where we except all load errors to be represented
by LoadFailedException.
2020-02-19 13:14:53 -08:00
Tim Van Laer 4b8cc86e49 fix for catch-all * namespace #325 (#326)
Fixes #325
2019-11-08 09:22:54 -08:00
Ben Bader 14607e5dd5
Use openjdk instead of oracle jdk (#321)
* Use openjdk instead of oracle jdk

* Don't force Java 8 compatibility in the compiler

* Remove generated annotations from apache thrift classes

* Remove ErrorProne
2019-11-07 15:39:19 -08:00
Ben Bader 32012249b6
Use UTF-8 when writing strings in SimpleJsonProtocol (#317) 2019-06-13 09:46:57 -07:00
Ben Bader 1b2492446d
Prepare next development version 2019-05-13 10:58:23 -07:00
Ben Bader 5b0f2cd4b2 Release version 2.0.0-RC1 2019-05-13 10:57:39 -07:00
Ben Bader 4012613fd7
Add dummy circleci config (#313) 2019-04-30 14:50:20 -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 964340a7d0
Bump to Gradle 5.4 (#309) 2019-04-19 22:46:21 -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
Steven Schoen ec9dcee3a9 Add support for AndroidX nullability annotations (#307)
* Add support for AndroidX nullability annotations

* Fix test formatting

* Restore old flag, designate as deprecated

* Space fixup

* Fix deferred arg
2019-03-29 10:32:33 -07:00
Zac Sweers 0c5bb87fec Specify where a missing file was included in failure message (#305)
This makes debugging easier since looking at that specific file is easier than trying to deduce which one used that namespace/directory.
2019-02-13 10:09:45 -08:00
Ben Bader a6eb88c976
Move union default-value cardinality validation (#302)
Fixes #291
2019-02-06 23:01:04 -08:00
Ben Bader 1370087365
Redirect ANTLR error messages to ErrorReporter (#301)
Instead of using error nodes in `ThriftListener`, we can get better (and prefabricated) error messages directly from ANTLR using their ANTLRErrorListener interface. As a side effect, we can also prevent antlr from spamming stderr!

Fixes #298
2019-02-06 22:39:09 -08: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
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 fbf92faa19
Correct documentation for EnumType member lookup methods (#290)
These have always been documented (incorrectly) to return null if no matching member is found.  They've always actually thrown NoSuchElementExceptions.  This commit changes the documentation to reflect that.
2019-02-05 20:17:44 -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
Zac Sweers e222e48e69 Strip trailing spaces in rendering and ignore in equality checking (#282)
Saves a few bytes
2018-12-20 08:32:22 -08:00
Zac Sweers 5eef80d3e1 Properly render ConstValueElement types (#281)
Fixes #280
Fixes #279
2018-12-20 08:30:15 -08:00
Zac Sweers 5c1b210207 Group typedefs by type first in rendering (#278)
Group typedefs by type first
2018-12-18 13:33:01 -08:00
Ben Bader 9e97705530
Add test for annotations on type params (#274) 2018-12-06 13:03:18 -08:00
Andrew Mu d3cde1c140 Improve Program Circular Include Message (#273)
Adding more info in the exception to make identifying the circular include more easily.
2018-11-27 13:01:40 -08:00
Ben Bader 3883fe8771
Use standard VM Travis infrastructure (#272)
Per https://blog.travis-ci.com/2018-10-04-combining-linux-infrastructures, the Travis container infrastructure is deprecated and will soon be disabled.  `sudo: false` opted us into it, so removing that line will put our builds back on the still-good VM infrastructure.
2018-11-27 09:39:13 -08:00
Ben Bader 79bdb3dcd5
Fix SchemaFunctionalEquality warnings (#271)
Smart-casts FTW!
2018-11-26 20:56:00 -06:00
Ben Bader 517f41bc6e
Remove jcenter repository (#270) 2018-11-26 20:51:00 -06:00
Ben Bader 6bccecefc0
Adopt mockito-kotlin, thereby getting mockito 2 (#269) 2018-11-26 20:43:39 -06:00
Ben Bader 737fa9c44b
Publish shadow jar for thrifty-compiler (#268) 2018-11-26 20:25:44 -06:00
Ben Bader bb062505ea
Integration test for unions (#263) 2018-11-05 11:05:14 -08:00
Ben Bader 6dfe25f299
Bump shadow plugin to remove Gradle warning (#261)
Version 2.x of the shadow plugin had an initialization bug causing warnings about use of deprecated Gradle features; the workaround was to specify `mainClassName` _prior_ to applying the plugin.  Happily, the 4.x release of the plugin fixes the bug.
2018-11-05 09:33:56 -08:00
Ben Bader 2cb0000a04
Fix typo in README.md (#260) 2018-11-05 08:47:07 -08:00
Ben Bader c224e45bda
Prepare next development version 2018-11-02 15:22:40 -07:00
Ben Bader e419a32233
Release Thrifty 1.0.0 2018-11-02 15:22:09 -07: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
Christoph Loy df77d08c83 Add newer implementation of gradle-wrapper (#252) 2018-10-10 11:27:27 -07:00
Christoph Loy d19d043aa0 Update Kotlin to 1.2.71 (#251)
Updating kotlin for better performance and fixes!

See [this](https://blog.jetbrains.com/kotlin/2018/09/kotlin-1-2-70-is-out/)
2018-10-09 11:29:14 -07:00
Jon Parise 18264a8b46 Add @NonNull to struct builder's copy constructor (#250)
The builder's copy constructor receives a `struct` value that can't be
null. Add @NonNull when Android annotations are enabled.
2018-10-05 08:38:41 -07:00
Rosário Pereira Fernandes 9919657327 Update README.md (#243)
Replace `compile` with `implementation`
2018-09-30 19:09:16 -07:00
Jon Parise 7066a6ee06 Add @Nullable annotation to findByValue methods (#241)
The default clause returns null so these methods should be marked as
nullable when Android annotations are enabled.
2018-09-14 14:45:04 -07:00