summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-03-31 14:34:15 +0000
committerDaniel Jasper <djasper@google.com>2015-03-31 14:34:15 +0000
commitf46dec86b647ea5bebeb08eaf4d51471c930f1ba (patch)
treec7a84166a184e33144e9c86223d5e64b629a9c7a /clang/lib/Format
parent462501ee7e05d9ccad2515277159f818c181b6ae (diff)
downloadbcm5719-llvm-f46dec86b647ea5bebeb08eaf4d51471c930f1ba.tar.gz
bcm5719-llvm-f46dec86b647ea5bebeb08eaf4d51471c930f1ba.zip
clang-format: [JS] Support getters, setters and methods in object literals.
llvm-svn: 233698
Diffstat (limited to 'clang/lib/Format')
-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 a036fb29da3..7e8efad26b6 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1036,6 +1036,17 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons) {
FormatTok->BlockKind = BK_BracedInit;
parseBracedList();
break;
+ case tok::r_paren:
+ // JavaScript can just have free standing methods and getters/setters in
+ // object literals. Detect them by a "{" following ")".
+ if (Style.Language == FormatStyle::LK_JavaScript) {
+ nextToken();
+ if (FormatTok->is(tok::l_brace))
+ parseChildBlock();
+ break;
+ }
+ nextToken();
+ break;
case tok::r_brace:
nextToken();
return !HasError;
OpenPOWER on IntegriCloud