forked from OSchip/llvm-project
clang-format: [Proto] Don't do bad things if imports are missing ;.
llvm-svn: 273179
This commit is contained in:
parent
4deb4ed21e
commit
3d5a7d6b65
|
@ -882,10 +882,21 @@ void UnwrappedLineParser::parseStructuralElement() {
|
|||
/*MunchSemi=*/false);
|
||||
return;
|
||||
}
|
||||
if (Style.Language == FormatStyle::LK_JavaScript &&
|
||||
FormatTok->is(Keywords.kw_import)) {
|
||||
parseJavaScriptEs6ImportExport();
|
||||
return;
|
||||
if (FormatTok->is(Keywords.kw_import)) {
|
||||
if (Style.Language == FormatStyle::LK_JavaScript) {
|
||||
parseJavaScriptEs6ImportExport();
|
||||
return;
|
||||
}
|
||||
if (Style.Language == FormatStyle::LK_Proto) {
|
||||
nextToken();
|
||||
if (!FormatTok->is(tok::string_literal))
|
||||
return;
|
||||
nextToken();
|
||||
if (FormatTok->is(tok::semi))
|
||||
nextToken();
|
||||
addUnwrappedLine();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals,
|
||||
Keywords.kw_slots, Keywords.kw_qslots)) {
|
||||
|
|
|
@ -189,5 +189,20 @@ TEST_F(FormatTestProto, ExtendingMessage) {
|
|||
"}");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestProto, FormatsImports) {
|
||||
verifyFormat("import \"a.proto\";\n"
|
||||
"import \"b.proto\";\n"
|
||||
"// comment\n"
|
||||
"message A {\n"
|
||||
"}");
|
||||
|
||||
// Missing semicolons should not confuse clang-format.
|
||||
verifyFormat("import \"a.proto\"\n"
|
||||
"import \"b.proto\"\n"
|
||||
"// comment\n"
|
||||
"message A {\n"
|
||||
"}");
|
||||
}
|
||||
|
||||
} // end namespace tooling
|
||||
} // end namespace clang
|
||||
|
|
Loading…
Reference in New Issue