Skip to content

Commit 6724d4d

Browse files
hchokshifacebook-github-bot
authored andcommitted
Add new annotation scope for function parameters, warn on field annotations for function parameters
Summary: - Add a new annotation scope for RPC function parameters - Emit a warning when using field-scoped annotations (without a function parameter scope) - Add function parameter scope to common annotations where applicable Reviewed By: vitaut, iahs Differential Revision: D75463963 fbshipit-source-id: 3f0d05ce3046dad8cf2646ee064b0f002586e7e7
1 parent f11d5f4 commit 6724d4d

6 files changed

Lines changed: 16 additions & 2 deletions

File tree

thrift/annotation/cpp.thrift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct Name {
5757
*/
5858
@scope.Typedef
5959
@scope.Field
60+
@scope.FunctionParameter
6061
struct Type {
6162
1: string name;
6263

thrift/annotation/go.thrift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ namespace py thrift.annotation.go
2828
// Annotation for overriding Go names (e.g. to avoid codegen name conflicts).
2929
@scope.Field
3030
@scope.Function
31+
@scope.FunctionParameter
3132
@scope.Typedef
3233
struct Name {
3334
1: string name;
3435
}
3536

3637
// Annotation for overriding Go struct field tags (e.g. json, yaml, serf tags).
3738
@scope.Field
39+
@scope.FunctionParameter
3840
struct Tag {
3941
1: string tag;
4042
}

thrift/annotation/java.thrift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct Mutable {}
3333

3434
// When this annotation is applied, thrift compiler will annotate corresponding java entity the given java annotation.
3535
@scope.Field
36+
@scope.FunctionParameter
3637
@scope.Struct
3738
@scope.Union
3839
@scope.Exception

thrift/annotation/python.thrift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ namespace py thrift.annotation.python
2727
// start
2828

2929
/// Hides in thrift-py3 only, not in thrift-python
30-
@scope.Definition
30+
/// Allowed for all @scope.Definition, except for @scope.FunctionParameter as that would hide part of
31+
/// the RPC function parameters.
32+
@scope.RootDefinition
33+
@scope.Field
34+
@scope.Function
35+
@scope.Transitive
3136
struct Py3Hidden {}
3237

3338
/// Hides in thrift-py-deprecated only

thrift/annotation/rust.thrift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ struct NewType {}
262262
* | `&'a T<K, V>` | `IntoIterator<Item = (&'a K, &'a V)>`
263263
*/
264264
@scope.Field
265+
@scope.FunctionParameter
265266
@scope.Typedef
266267
struct Type {
267268
1: string name;

thrift/annotation/scope.thrift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct Union {}
8686
/** The `exception` definition scope. */
8787
struct Exception {}
8888

89-
/** Field declartaions, for example in `struct` or `function` declartions. */
89+
/** Field declarations, for example in `struct` declaration. */
9090
struct Field {}
9191

9292
/** The `typedef` definition scope. */
@@ -102,6 +102,9 @@ struct Interaction {}
102102
struct Function {}
103103
/* added by compiler: (hack.name = "TFunction", js.name = "TFunction") */
104104

105+
/** The `function parameter` definition scope. */
106+
struct FunctionParameter {}
107+
105108
/** The Enum value definition scope. */
106109
struct EnumValue {}
107110

@@ -141,6 +144,7 @@ struct RootDefinition {}
141144
@RootDefinition
142145
@Field
143146
@Function
147+
@FunctionParameter
144148
@EnumValue
145149
@Transitive
146150
struct Definition {}

0 commit comments

Comments
 (0)