[llvm-bugs] [Bug 40360] New: clang-format indents protobuf incorrectly when an option has a composite value
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 17 09:12:31 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40360
Bug ID: 40360
Summary: clang-format indents protobuf incorrectly when an
option has a composite value
Product: clang
Version: 8.0
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: jhump at bluegosling.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
I'm using clang-format on OS X to format protocol buffer sources.
--------------------------
$ clang-format --version
clang-format version 8.0.0 (tags/google/stable/2018-12-18)
--------------------------
I have a few proto source files that get improperly formatted. The indentation
is wrong: the formatter un-indents one too many after composite option value
ends.
Example protobuf code (test.proto):
--------------------------
syntax = "proto3";
package fullstory.users.v1;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-swagger/options/annotations.proto";
option go_package = "users";
service Foo {
rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http).get = "/foo/bar";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) =
{
summary: "Query for foobar",
description: "Query for a bar using a foo";
};
}
rpc Baz(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http).delete = "/foo/baz";
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) =
{
summary: "Initiates a baz process",
description: "Start processing a given baz";
};
}
}
--------------------------
The above is actually what I would expect the output of the formatter to be. So
if I run it through clang-format, I would expect no change. Instead, the last
several lines of the service get incorrectly un-indented.
--------------------------
$ clang-format '-style={BasedOnStyle: google, ColumnLimit: 150, IndentWidth: 4,
SpacesBeforeTrailingComments: 1, PenaltyBreakComment: 10}' < test.proto
syntax = "proto3";
package fullstory.users.v1;
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "protoc-gen-swagger/options/annotations.proto";
option go_package = "users";
service Foo {
rpc Bar(google.protobuf.Empty) returns(google.protobuf.Empty) {
option(google.api.http).get = "/foo/bar";
option(grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "Query for foobar",
description : "Query for a bar using a foo";
};
}
rpc Baz(google.protobuf.Empty) returns(google.protobuf.Empty) {
option(google.api.http).delete = "/foo/baz";
option(grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
summary : "Initiates a baz process",
description : "Start processing a given baz";
};
}
}
--------------------------
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190117/f8e3d529/attachment.html>
More information about the llvm-bugs
mailing list