r257451 - clang-format: [JS] Support exporting abstract classes.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 11 22:24:39 PST 2016
Author: djasper
Date: Tue Jan 12 00:24:38 2016
New Revision: 257451
URL: http://llvm.org/viewvc/llvm-project?rev=257451&view=rev
Log:
clang-format: [JS] Support exporting abstract classes.
Before:
export abstract class X {y: number;}
(and all sorts of other havoc in more complicated cases).
After:
export abstract class X { y: number; }
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=257451&r1=257450&r2=257451&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Jan 12 00:24:38 2016
@@ -1809,6 +1809,10 @@ void UnwrappedLineParser::parseJavaScrip
return;
}
+ // Consume the "abstract" in "export abstract class".
+ if (FormatTok->is(Keywords.kw_abstract))
+ nextToken();
+
if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum,
Keywords.kw_interface, Keywords.kw_let,
Keywords.kw_var))
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257451&r1=257450&r2=257451&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Jan 12 00:24:38 2016
@@ -878,6 +878,7 @@ TEST_F(FormatTestJS, Modules) {
" y: string;\n"
"}");
verifyFormat("export class X { y: number; }");
+ verifyFormat("export abstract class X { y: number; }");
verifyFormat("export default class X { y: number }");
verifyFormat("export default function() {\n return 1;\n}");
verifyFormat("export var x = 12;");
More information about the cfe-commits
mailing list