Skip to content

Commit b66cb16

Browse files
hchokshifacebook-github-bot
authored andcommitted
Convert swift.recursive_reference unstructured annotation to @java.Recursive
Summary: Codemod update to replace `swift.recursive_reference` unstructured annotation with `java.Recursive` structured annotation. Reviewed By: vitaut Differential Revision: D76058596 fbshipit-source-id: d1b44245f59128a6a723dda19919bffabd6c2800
1 parent c820854 commit b66cb16

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

third-party/thrift/src/thrift/compiler/codemod/structure_annotations.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ class structure_annotations {
404404
to_add.insert(fmt::format(
405405
"@java.Annotation{{java_annotation = \"{}\"}}", data.value));
406406
fm_.add_include("thrift/annotation/java.thrift");
407+
} else if (name == "swift.recursive_reference") {
408+
to_remove.emplace_back(name, data);
409+
if (data.value == "true" && dynamic_cast<const t_field*>(&node)) {
410+
to_add.insert("@java.Recursive");
411+
fm_.add_include("thrift/annotation/java.thrift");
412+
}
407413
}
408414

409415
// go

third-party/thrift/src/thrift/compiler/codemod/structure_annotations_test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,11 @@ def test_java(self):
338338
"foo.thrift",
339339
textwrap.dedent(
340340
"""\
341-
struct S {}
341+
struct S {
342+
1: i32 field1 (swift.recursive_reference = "true");
343+
344+
2: i32 field2 (swift.recursive_reference = "false");
345+
}
342346
(
343347
java.swift.annotations = "@com.facebook.Foo
344348
@com.facebook.Bar",
@@ -360,7 +364,12 @@ def test_java(self):
360364
@java.Annotation{java_annotation = "@com.facebook.Foo
361365
@com.facebook.Bar"}
362366
@java.Mutable
363-
struct S {}
367+
struct S {
368+
@java.Recursive
369+
1: i32 field1 ;
370+
371+
2: i32 field2 ;
372+
}
364373
"""
365374
),
366375
)

0 commit comments

Comments
 (0)