feat(scalasdk): use package imports for views#448
Conversation
* Refactoring of TestData for more flexibility around the parent PackageNaming, javaOuterClassName
| package com.lightbend.akkasls.codegen | ||
|
|
||
| class PackagingSuite extends munit.FunSuite { | ||
| private val testData = TestData() |
There was a problem hiding this comment.
TestData became a class (instead of object) so that it can be initialized with defaults (especially the difference between javaOuterClassName for Java vs Scala)
| | eventName: String, | ||
| | state: ${qualifiedType(view.state.fqn)}, | ||
| | event: Any): View.UpdateEffect[${qualifiedType(view.state.fqn)}] = { | ||
| | state: ${typeName(view.state.fqn)}, |
There was a problem hiding this comment.
using the new typeName which takes the Imports in implicit scope
| | | ||
| | def created( | ||
| | state: ServiceOuterClass.ViewState, entityCreated: EntityOuterClass.EntityCreated): View.UpdateEffect[ServiceOuterClass.ViewState] | ||
| | state: ViewState, entityCreated: EntityCreated): View.UpdateEffect[ViewState] |
There was a problem hiding this comment.
this PR solves the imports for the things from domain, such as the EntityCreated here.
| | | ||
| | override final def serviceDescriptor: Descriptors.ServiceDescriptor = | ||
| | ServiceOuterClass.getDescriptor().findServiceByName("MyService") | ||
| | MyServiceProto.javaDescriptor.findServiceByName("MyService") |
There was a problem hiding this comment.
This is still wrong, but let's tackle that in a separate PR.
With ScalaPB the descriptors can be found in *Proto classes. In the sample it should use CustomerViewProto where I think CustomerView is derived from the file name customer_view.proto.
| | | ||
| | override final def serviceDescriptor: Descriptors.ServiceDescriptor = | ||
| | ${view.fqn.parent.javaOuterClassname}.getDescriptor().findServiceByName("${view.fqn.protoName}") | ||
| | ${view.fqn.parent.name}Proto.javaDescriptor.findServiceByName("${view.fqn.protoName}") |
There was a problem hiding this comment.
This is still wrong, but let's tackle that in a separate PR.
With ScalaPB the descriptors can be found in *Proto classes. In the sample it should use CustomerViewProto where I think CustomerView is derived from the file name customer_view.proto.
The above code results in CustomerByNameProto instead of CustomerViewProto, i.e. view.fqn.parent.name is the rpc service name.
|
|
||
| package customer.api; | ||
|
|
||
| option java_outer_classname = "CustomerApi"; |
There was a problem hiding this comment.
Why not keep them? They're ignored for Scala anyway, right?
There was a problem hiding this comment.
ok, I was uncertain if they were fully ignored or not. However, since these are to be shown in doc snippets it would be confusing to include them when they are not used.
| lazy val javaPackage: String = javaPackageOption.getOrElse(pkg) | ||
| lazy val scalaPackage: String = javaPackage | ||
| def scalaPackage: String = javaPackage | ||
| def javaOuterClassname: String = javaOuterClassnameOption.getOrElse(name) |
|
Merging this, and @raboof will look into the Descriptor issue separately. |
Similar to #443
javaOuterClassName