summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-08-01 15:46:10 +0000
committerMartin Probst <martin@probst.io>2017-08-01 15:46:10 +0000
commitcb870c57b334236dc7b0822c7366a735ac3c1880 (patch)
tree115eb9d34489b7f703a28821722c86ae8545a1d8 /clang/lib/Format/UnwrappedLineParser.cpp
parent7ebbe655edd411bd79a726251ec23d9477ccb64c (diff)
downloadbcm5719-llvm-cb870c57b334236dc7b0822c7366a735ac3c1880.tar.gz
bcm5719-llvm-cb870c57b334236dc7b0822c7366a735ac3c1880.zip
clang-format: [JS] handle object types in extends positions.
Summary: clang-format would previously drop the whitespace after `extends` in code such as: class Foo extends {} {} Where the first set of curly braces is an inline object literal type. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36131 llvm-svn: 309695
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index bbed83263ce..753eada8f1b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1970,6 +1970,17 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
((Style.Language == FormatStyle::LK_Java ||
Style.Language == FormatStyle::LK_JavaScript) &&
FormatTok->isOneOf(tok::period, tok::comma))) {
+ if (Style.Language == FormatStyle::LK_JavaScript &&
+ FormatTok->isOneOf(Keywords.kw_extends, Keywords.kw_implements)) {
+ // JavaScript/TypeScript supports inline object types in
+ // extends/implements positions:
+ // class Foo implements {bar: number} { }
+ nextToken();
+ if (FormatTok->is(tok::l_brace)) {
+ tryToParseBracedList();
+ continue;
+ }
+ }
bool IsNonMacroIdentifier =
FormatTok->is(tok::identifier) &&
FormatTok->TokenText != FormatTok->TokenText.upper();
OpenPOWER on IntegriCloud