summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-04-26 12:34:15 +0000
committerMartin Probst <martin@probst.io>2017-04-26 12:34:15 +0000
commit19c7de0a2262da2da139c7ddd7978cecdef1ffae (patch)
tree89f1a808da50ef412a4c1dbb634a3ea26555e5cf /clang/lib/Format/TokenAnnotator.cpp
parente6a770844889432a655eb31897f1e087eee64d9d (diff)
downloadbcm5719-llvm-19c7de0a2262da2da139c7ddd7978cecdef1ffae.tar.gz
bcm5719-llvm-19c7de0a2262da2da139c7ddd7978cecdef1ffae.zip
clang-format: [JS] prevent wraps before class members.
Summary: In JavaScript/TypeScript, class member definitions that use modifiers can be subject to Automatic Semicolon Insertion (ASI). For example, "class X { get \n foo }" defines a property called "get" and a property called "foo", both with no type annotation. This change prevents wrapping after the modifier keywords (visibility modifiers, static, get and set) to prevent accidental ASI. Reviewers: djasper, bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D32531 llvm-svn: 301397
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index bbc2d1e52b6..86380c6e6f1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2543,7 +2543,11 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
if (NonComment &&
NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
tok::kw_throw, Keywords.kw_interface,
- Keywords.kw_type))
+ Keywords.kw_type, tok::kw_static, tok::kw_public,
+ tok::kw_private, tok::kw_protected,
+ Keywords.kw_abstract,
+ Keywords.kw_get,
+ Keywords.kw_set))
return false; // Otherwise a semicolon is inserted.
if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
return false;
OpenPOWER on IntegriCloud