summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-05-12 13:00:33 +0000
committerMartin Probst <martin@probst.io>2017-05-12 13:00:33 +0000
commit79f9c5fe0c837858c343e1bcb9d36ffd44374f1f (patch)
treeb5abf5704b3234c6061013c0856a749824832771
parentd0d29addf9e9e54aeb8322d7fe47fa2bee4f3b14 (diff)
downloadbcm5719-llvm-79f9c5fe0c837858c343e1bcb9d36ffd44374f1f.tar.gz
bcm5719-llvm-79f9c5fe0c837858c343e1bcb9d36ffd44374f1f.zip
clang-format: [JS] support non-null assertions after all identifiers.
Summary: Previously: x = namespace !; Now: x = namespace!; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D33113 llvm-svn: 302893
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index c274d7bf07f..d3b2cf4e84c 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1034,7 +1034,8 @@ private:
if (Style.Language == FormatStyle::LK_JavaScript) {
if (Current.is(tok::exclaim)) {
if (Current.Previous &&
- (Current.Previous->isOneOf(tok::identifier, tok::r_paren,
+ (Current.Previous->Tok.getIdentifierInfo() ||
+ Current.Previous->isOneOf(tok::identifier, tok::r_paren,
tok::r_square, tok::r_brace) ||
Current.Previous->Tok.isLiteral())) {
Current.Type = TT_JsNonNullAssertion;
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 4a2da1abe0f..8387152bcac 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1799,6 +1799,7 @@ TEST_F(FormatTestJS, NonNullAssertionOperator) {
" .foo()!\n"
" .foo()!;\n",
getGoogleJSStyleWithColumns(20));
+ verifyFormat("let x = namespace!;\n");
}
TEST_F(FormatTestJS, Conditional) {
OpenPOWER on IntegriCloud