Skip to content

Commit

Permalink
protoprint: fix superfluous trailing space (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhump committed Feb 13, 2022
1 parent e5b6528 commit 3240deb
Show file tree
Hide file tree
Showing 23 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion desc/protoprint/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ func (p *Printer) printOption(name string, optVal interface{}, w *writer, indent
Compact: true,
ExpandAny: true,
}
str := m.Text(optVal)
str := strings.TrimSuffix(m.Text(optVal), " ")
fieldCount := strings.Count(str, ":")
nestedCount := strings.Count(str, "{") + strings.Count(str, "<")
if fieldCount <= 1 && nestedCount == 0 {
Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/desc_test_comments-compact.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ service RpcService {
// service trailer
// that spans multiple lines
// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };
option deprecated = false; // DEPRECATED!
option (testprotos.sfubare) = VALUE;
// Method comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ service RpcService {
option (testprotos.sfubare) = VALUE;

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false; // DEPRECATED!
}
Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/desc_test_comments-default.proto
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ service RpcService {
// that spans multiple lines

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false; // DEPRECATED!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ service RpcService {
*/

/* option that sets field */
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false; /* DEPRECATED! */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ message AnEmptyMessage {
// Service comment
service RpcService {
// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ message AnEmptyMessage {

// Service comment
service RpcService {
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ service RpcService {
option deprecated = false; /* DEPRECATED! */

/* option that sets field */
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option (testprotos.sfubare) = VALUE;

Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/desc_test_comments-sorted.proto
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ service RpcService {
option deprecated = false; // DEPRECATED!

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option (testprotos.sfubare) = VALUE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ service RpcService {
// that spans multiple lines

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false;
// DEPRECATED!
Expand Down
10 changes: 5 additions & 5 deletions desc/protoprint/testfiles/desc_test_complex-compact.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ message Test {
extend Test {
optional string _garblez = 100;
}
option (rept) = { foo:"goo" [foo.bar.Test.Nested._NestedNested._garblez]:"boo" };
option (rept) = { foo:"goo" [foo.bar.Test.Nested._NestedNested._garblez]:"boo" };
message NestedNestedNested {
option (rept) = { foo:"hoo" [foo.bar.Test.Nested._NestedNested._garblez]:"spoo" };
option (rept) = { foo:"hoo" [foo.bar.Test.Nested._NestedNested._garblez]:"spoo" };
optional Test Test = 1;
}
}
Expand Down Expand Up @@ -100,7 +100,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };
option (eee) = V1;
option (a) = {
test: <
Expand Down Expand Up @@ -162,10 +162,10 @@ extend google.protobuf.MethodOptions {
}
service TestTestService {
rpc UserAuth ( Test ) returns ( Test ) {
option (validator) = { authenticated:true permission:<action:LOGIN entity:"client" > };
option (validator) = { authenticated:true permission:<action:LOGIN entity:"client" > };
}
rpc Get ( Test ) returns ( Test ) {
option (validator) = { authenticated:true permission:<action:READ entity:"user" > };
option (validator) = { authenticated:true permission:<action:READ entity:"user" > };
}
}
message Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

option (map_vals) = {
vals: <
Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/desc_test_complex-default.proto
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

option (eee) = V1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

option (eee) = V1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

option (eee) = V1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

option (eee) = V1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

optional Test test = 1;

Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/desc_test_complex-sorted.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

optional Test test = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ message Another {
name: "s"
>
};
option (rept) = { foo:"def" };
option (rept) = { foo:"def" };

option (eee) = V1;

Expand Down
4 changes: 2 additions & 2 deletions desc/protoprint/testfiles/test-non-files-compact.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ message Request {
// Service comment
service RpcService {
option deprecated = false;
option (.testprotos.sfubar) = { id:100 name:"bob" };
option (.testprotos.sfubar) = { id:100 name:"bob" };
option (.testprotos.sfubare) = VALUE;
// Method comment
rpc StreamingRpc ( stream .foo.bar.Request ) returns ( .foo.bar.Request );
Expand Down Expand Up @@ -294,7 +294,7 @@ extend .foo.bar.Request {
// Service comment
service RpcService {
option deprecated = false;
option (.testprotos.sfubar) = { id:100 name:"bob" };
option (.testprotos.sfubar) = { id:100 name:"bob" };
option (.testprotos.sfubare) = VALUE;
// Method comment
rpc StreamingRpc ( stream .foo.bar.Request ) returns ( .foo.bar.Request );
Expand Down
4 changes: 2 additions & 2 deletions desc/protoprint/testfiles/test-non-files-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ service /* service name */ RpcService {
// that spans multiple lines

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false; // DEPRECATED!

Expand Down Expand Up @@ -506,7 +506,7 @@ service /* service name */ RpcService {
// that spans multiple lines

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false; // DEPRECATED!

Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/test-preserve-comments.proto
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ service /* service name */ RpcService {
// that spans multiple lines

// option that sets field
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false; // DEPRECATED!

Expand Down
2 changes: 1 addition & 1 deletion desc/protoprint/testfiles/test-preserve-doc-comments.proto
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ message AnEmptyMessage {

// Service comment
service RpcService {
option (testprotos.sfubar) = { id:100 name:"bob" };
option (testprotos.sfubar) = { id:100 name:"bob" };

option deprecated = false;

Expand Down

0 comments on commit 3240deb

Please sign in to comment.