public:
LineType parseLine() {
- if (CurrentToken->is(tok::hash)) {
+ if (CurrentToken->is(tok::hash))
return parsePreprocessorDirective();
- }
// Directly allow to 'import <string-literal>' to support protocol buffer
// definitions (code.google.com/p/protobuf) or missing "#" (either way we
return LT_ImportStatement;
}
+ // In .proto files, top-level options are very similar to import statements
+ // and should not be line-wrapped.
+ if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
+ CurrentToken->is(Keywords.kw_option)) {
+ next();
+ if (CurrentToken && CurrentToken->is(tok::identifier))
+ return LT_ImportStatement;
+ }
+
bool KeywordVirtualFound = false;
bool ImportStatement = false;
while (CurrentToken) {
"}];");
}
+TEST_F(FormatTestProto, DoesntWrapFileOptions) {
+ EXPECT_EQ(
+ "option java_package = "
+ "\"some.really.long.package.that.exceeds.the.column.limit\";",
+ format("option java_package = "
+ "\"some.really.long.package.that.exceeds.the.column.limit\";"));
+}
+
TEST_F(FormatTestProto, FormatsOptions) {
verifyFormat("option (MyProto.options) = {\n"
" field_a: OK\n"