forked from OSchip/llvm-project
clang-format: [JS] Support more ES6 classes.
Before: foo = class { constructor() {} } ; After: foo = class { constructor() {} }; llvm-svn: 257154
This commit is contained in:
parent
872df22caa
commit
d5ec65ba33
|
@ -841,6 +841,8 @@ void UnwrappedLineParser::parseStructuralElement() {
|
|||
// This does not apply for Java and JavaScript.
|
||||
if (Style.Language == FormatStyle::LK_Java ||
|
||||
Style.Language == FormatStyle::LK_JavaScript) {
|
||||
if (FormatTok->is(tok::semi))
|
||||
nextToken();
|
||||
addUnwrappedLine();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -755,6 +755,12 @@ TEST_F(FormatTestJS, ClassDeclarations) {
|
|||
" aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaa):\n"
|
||||
" aaaaaaaaaaaaaaaaaaaaaa {}\n"
|
||||
"}");
|
||||
verifyFormat("foo = class Name {\n"
|
||||
" constructor() {}\n"
|
||||
"};");
|
||||
verifyFormat("foo = class {\n"
|
||||
" constructor() {}\n"
|
||||
"};");
|
||||
|
||||
// ':' is not a type declaration here.
|
||||
verifyFormat("class X {\n"
|
||||
|
|
Loading…
Reference in New Issue