From 6a5d38d2ee30d74cb67f44d410d504d268e87046 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 13 Apr 2015 14:56:54 +0000 Subject: clang-format: [JS] Allow periods and commata in class declarations. Patch by Martin Probst. Thank you. llvm-svn: 234752 --- clang/lib/Format/UnwrappedLineParser.cpp | 3 ++- clang/unittests/Format/FormatTestJS.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'clang') diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 826356f474a..905f9c1ba5f 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 76c2730960e..bfe62ecb956 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/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) { -- cgit v1.2.3