From: Daniel Jasper Date: Mon, 13 Apr 2015 14:56:54 +0000 (+0000) Subject: clang-format: [JS] Allow periods and commata in class declarations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fac8170bc38bcd8fe5e310dcac7861c124a8c60;p=clang clang-format: [JS] Allow periods and commata in class declarations. Patch by Martin Probst. Thank you. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234752 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 826356f474..905f9c1ba5 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -1541,7 +1541,8 @@ void UnwrappedLineParser::parseRecord() { // it is often token-pasted. while (FormatTok->is(tok::identifier) || FormatTok->is(tok::coloncolon) || FormatTok->is(tok::hashhash) || - (Style.Language == FormatStyle::LK_Java && + ((Style.Language == FormatStyle::LK_Java || + Style.Language == FormatStyle::LK_JavaScript) && FormatTok->isOneOf(tok::period, tok::comma))) nextToken(); diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 76c2730960..bfe62ecb95 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -544,6 +544,7 @@ TEST_F(FormatTestJS, ClassDeclarations) { verifyFormat("class C {\n private static x: string = 12;\n}"); verifyFormat("class C {\n static x(): string { return 'asd'; }\n}"); verifyFormat("class C extends P implements I {}"); + verifyFormat("class C extends p.P implements i.I {}"); } TEST_F(FormatTestJS, MetadataAnnotations) {