Skip to content

Commit

Permalink
finagle-ts: Generates inherited service, service and method annotations
Browse files Browse the repository at this point in the history
Problem/Solution

TypeScript generator should also support generating inherited services.
Method annotations are located in the generated ThriftRequest(Call) schema.
Service annotations are readonly fields.

What also happened in this phab:

By re-enabling goldfile test, found that bazel/pants cannot trace beyond its
target, in this case, target1. So the target2 files cannot be tested. Removed
the target2 files in gold files tests.

generator.ts overwrite the generated path in node_module/gen when copying, we
have to reset chmod every time when there are multiple thrift dependency
targets.

JIRA Issues: CSL-11991

Differential Revision: https://phabricator.twitter.biz/D904597
  • Loading branch information
yufangong authored and jenkins committed Jun 11, 2022
1 parent a6cc0f9 commit 8c121f0
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions scrooge-generator-tests/src/test/thrift/scala/BUILD
Expand Up @@ -5,6 +5,7 @@ create_thrift_libraries(
generate_languages = [
"java",
"scala",
"typescript",
],
)

Expand Down
@@ -1,5 +1,6 @@
#@namespace scala collisions.big.thriftscala
namespace java collisions.big.thriftjava
#@namespace typescript collisions.big.thriftts


# Scala 2.10 can't handle case classes with 22+ arguments.
Expand Down
@@ -1,5 +1,6 @@
#@namespace scala collisions
namespace java collisions_java
#@namespace typescript collisions.thriftts


// Test struct names colliding with capitalized method names.
Expand Down
@@ -1,5 +1,6 @@
#@namespace scala collisions
namespace java collisions_java
#@namespace typescript collisions.thriftts

# Check for collisions between Result and MyService.MyMethod.Result
struct Result {
Expand Down
@@ -1,5 +1,6 @@
#@namespace scala collisions.enums
namespace java collisions.enums_java
#@namespace typescript collisions.enums.thriftts

union Result {
string successValue
Expand Down
3 changes: 2 additions & 1 deletion scrooge-generator-tests/src/test/thrift/scala/const.thrift
@@ -1,5 +1,6 @@
namespace java includes.a.thriftjava
#@namespace scala includes.a.thriftscala
#@namespace typescript includes.a.thriftts

struct CityState {
1: string city
Expand All @@ -25,4 +26,4 @@ struct TestName {
2: string last
3: string middle = ""
4: Address address
}
}
3 changes: 2 additions & 1 deletion scrooge-generator-tests/src/test/thrift/scala/const1.thrift
@@ -1,5 +1,6 @@
namespace java includes.b.thriftjava
#@namespace scala includes.b.thriftscala
#@namespace typescript includes.b.thriftts

include "const.thrift"

Expand All @@ -15,4 +16,4 @@ const const.TestName name1 = {
}
}
}
}
}
@@ -1,5 +1,6 @@
#@namespace scala collisions.dupes.thriftscala
namespace java collisions.dupes.thriftjava
#@namespace typescript collisions.dups.thriftts


service Aaa {
Expand Down
1 change: 1 addition & 0 deletions scrooge-generator-tests/src/test/thrift/scala/echo.thrift
@@ -1,5 +1,6 @@
#@namespace scala collisions
namespace java java_collisions
#@namespace typescript collisions.thriftts

/* Method colliding with service name */
service Echo {
Expand Down
@@ -1,5 +1,6 @@
#@namespace scala inheritance.aaa
namespace java inheritance.thriftjava.aaa
#@namespace typescript inheritance.thriftts.aaa

struct Box {
1: i32 x
Expand Down
@@ -1,5 +1,6 @@
#@namespace scala inheritance.bbb
namespace java inheritance.thriftjava.bbb
#@namespace typescript inheritance.thriftts.bbb

include "aaa.thrift"

Expand Down
@@ -1,5 +1,6 @@
#@namespace scala inheritance.ccc
namespace java inheritance.thriftjava.ccc
#@namespace typescript inheritance.thriftts.ccc

include "bbb.thrift"

Expand Down
@@ -1,5 +1,6 @@
#@namespace scala inheritance.ddd
namespace java inheritance.thriftjava.ddd
#@namespace typescript inheritance.thriftts.ddd

include "ccc.thrift"

Expand Down
@@ -1,5 +1,6 @@
#@namespace scala inheritance
namespace java inheritance.thriftjava
#@namespace typescript inheritance.thriftts

include "lowercase.thrift"

Expand Down
@@ -1,5 +1,6 @@
#@namespace scala inheritance
namespace java inheritance.thriftjava
#@namespace typescript inheritance.thriftts

service iamlowercase {
i32 getInt()
Expand Down
@@ -1,5 +1,6 @@
#@namespace scala collisions.big.thriftscala
namespace java collisions.big.thriftjava
#@namespace typescript collisions.big.thriftts

# We skip generation of ServiceIfaces for thrift services with 255+ methods.
# see https://issues.scala-lang.org/browse/SI-7324
Expand Down

0 comments on commit 8c121f0

Please sign in to comment.