summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-09-28 14:28:08 +0000
committerDaniel Jasper <djasper@google.com>2015-09-28 14:28:08 +0000
commit9f642f7d7aeefd4ce676c891ea462c0f32a5ed68 (patch)
tree6e755f32044a712f855087f4716b09d3a61f80b6 /clang/lib/Format/TokenAnnotator.cpp
parent28b9a14b07f0c6b491076c0bff8ddee7beb75231 (diff)
downloadbcm5719-llvm-9f642f7d7aeefd4ce676c891ea462c0f32a5ed68.tar.gz
bcm5719-llvm-9f642f7d7aeefd4ce676c891ea462c0f32a5ed68.zip
clang-format: [JS] handle let (ES6)
Patch by Martin Probst. Thank you! llvm-svn: 248713
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 53027c79b36..068f9727b89 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1951,7 +1951,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
Left.isOneOf(Keywords.kw_returns, Keywords.kw_option))
return true;
} else if (Style.Language == FormatStyle::LK_JavaScript) {
- if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow))
+ if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow))
return true;
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
return false;
@@ -2082,8 +2082,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
Left.Previous && Left.Previous->is(tok::equal) &&
Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export,
tok::kw_const) &&
- // kw_var is a pseudo-token that's a tok::identifier, so matches above.
- !Line.startsWith(Keywords.kw_var))
+ // kw_var/kw_let are pseudo-tokens that are tok::identifier, so match
+ // above.
+ !Line.First->isOneOf(Keywords.kw_var, Keywords.kw_let))
// Object literals on the top level of a file are treated as "enum-style".
// Each key/value pair is put on a separate line, instead of bin-packing.
return true;
OpenPOWER on IntegriCloud