summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-03-13 07:10:18 +0000
committerMartin Probst <martin@probst.io>2017-03-13 07:10:18 +0000
commitb98ab89ebb7dd5ee008a1fd3e0ea8502e9e4d963 (patch)
tree03629e480bc7e97b08f81303fa1977f4eb03834a /clang/lib/Format/TokenAnnotator.cpp
parent1867a87c3d5b20c7ff488a230dee4e6213e43032 (diff)
downloadbcm5719-llvm-b98ab89ebb7dd5ee008a1fd3e0ea8502e9e4d963.tar.gz
bcm5719-llvm-b98ab89ebb7dd5ee008a1fd3e0ea8502e9e4d963.zip
clang-format: [JS] do not wrap after interface and type.
Summary: `interface` and `type` are pseudo keywords and cause automatic semicolon insertion when followed by a line break: interface // gets parsed as a long variable access to "interface" VeryLongInterfaceName { } With this change, clang-format not longer wraps after `interface` or `type`. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D30874 llvm-svn: 297605
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index c529f1e4a62..0111aea52e4 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2526,11 +2526,10 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return true;
} else if (Style.Language == FormatStyle::LK_JavaScript) {
const FormatToken *NonComment = Right.getPreviousNonComment();
- if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw) ||
- (NonComment &&
- NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw)))
+ if (NonComment &&
+ NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw, Keywords.kw_interface,
+ Keywords.kw_type))
return false; // Otherwise a semicolon is inserted.
if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
return false;
OpenPOWER on IntegriCloud