Comments (6)
Perfect. Will close the issue now and cut a release soon. Don't hesitate to start a new issue or comment here if anything left unresolved.
from scalapb.
Hi Oscar, thanks for suggesting this feature and contributing the PR. I had started to work on this in parallel, looked at your code and made adjustments in mine as necessary. One difference is that I refrained from introducing target_regex
in aux_message_options
but expanded target
to accept *
to indicate to apply to all messages in scope. Will this work for you?
I'd really appreciate before I cut a release if you will be able to try out the snapshot release 0.11.13+88-1d78ac52-SNAPSHOT
and see if it works for? Some documentation is at https://github.com/scalapb/ScalaPB/blob/master/CHANGELOG.md#01114 , and
from scalapb.
Hi, thanks!
While I was unable to try the snapshot you published due to scalapb-runtime_3
missing for that version, I published it locally and tried it out.
There's one thing that's preventing me from not importing io.circe.generic.auto.*
and that is the derives
clause for GeneratedSealedOneof
. Currently, only NonEmpty
has the clause (and rightfully so!), but it's also needed for the top-level type.
However, I changed all sealed_value
messages into sealed_value_optional
and while it did increase boilerplate a bit, I got rid of some rather complex type-class derivation logic.
In the end, I'm left with the following diff required to make things work:
diff --git a/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala b/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala
index cbfce320..2f65388d 100644
--- a/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala
+++ b/compiler-plugin/src/main/scala/scalapb/compiler/SealedOneofsGenerator.scala
@@ -31,7 +31,7 @@ class SealedOneofsGenerator(message: Descriptor, implicits: DescriptorImplicits)
val bases =
if (baseClasses.nonEmpty)
s"extends ${baseClasses.mkString(" with ")} $derives"
- else ""
+ else s"$derives"
if (message.sealedOneofStyle != SealedOneofStyle.Optional) {
val sealedOneofNonEmptyName = message.sealedOneofNonEmptyScalaType.nameSymbol
from scalapb.
The result is amazing! 90% decrease in incremental compilation speed in many cases, and 50% reduction in clean compile.
from scalapb.
The previous commit has the diff you posted. Can you try again? I'm not sure why you were not able to use scalapb_runtime-3. Tthe new version is published on sonatype, but also the previous version did. Are your resolvers configured correctly for the project/
from scalapb.
Correct! I had the Sonatype snapshots configured only for the build project, and not for the project that used ScalaPB.
It works now.
from scalapb.
Related Issues (20)
- Cannot name a 'oneof' field 'option' if an optional field exists HOT 1
- --jvm_0_out: protoc-gen-jvm_0: Plugin failed with status code 1. WIth Java version 11, change to 17 is fixed HOT 21
- Type Mismatch Error with `asRecognized` in versions 0.11.14 and 0.11.15 HOT 3
- sealed_oneof_companion_extends doesn't work for optional sealed oneof
- Sealed oneof "extend" for Empty case HOT 1
- java.lang.IllegalAccessError: tried to access method 'com.google.protobuf.LazyStringArrayList' HOT 10
- google/protobuf/empty.proto: File not found. HOT 1
- Define trait for GeneratedEnumCompanion’s fromJavaValue/toJavaValue HOT 1
- Support Scala 3.4 type wildcards HOT 2
- `_typemapper` are defined as package private, causing issues when deriving schemas HOT 4
- Protobuf with a field named using generates invalid Scala 3 code HOT 1
- ArrayIndexOutOfBoundsException on getFieldByNumber HOT 5
- UTF-8 Strings are unparseable? HOT 2
- JsonFormat.toJsonString omits authorisation string in the output JSON HOT 2
- Dependency on `scalapb.options.ScalapbProto` in generated code. HOT 3
- New release HOT 1
- Add an option to generate oneof fields as a sealed abstract class
- pin to protobuf 3.x HOT 1
- Publish scalapb-runtime for Scala Native 0.5.x HOT 3
- Publish new Maven release for v0.11.16 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scalapb.