diff options
author | Martin Probst <martin@probst.io> | 2017-05-15 08:15:53 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2017-05-15 08:15:53 +0000 |
commit | f7d8230b8d24ef0309c92ef3665742085b41a66a (patch) | |
tree | f8ff60b1a991bf54c7bf90e9f9c666b65eef9005 /lib/Format | |
parent | ffd03c81d3b17bd25a9f3c6b22fc1b650f65a505 (diff) |
clang-format: [JS] fix non-null assertion operator recognition.
Summary:
`getIdentifierInfo()` includes all keywords, whereas non-null assertion
operators should only be recognized after non-keywords or pseudo keywords.
Ideally this should list all tokens that clang-format recognizes as a keyword,
but that are pseudo or no keywords in JS. For the time being, just recognize
the specific bits users ran into (`namespace` in this case).
Reviewers: djasper
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D33182
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index d3b2cf4e84..bd5e2ed2f4 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1034,9 +1034,9 @@ private: if (Style.Language == FormatStyle::LK_JavaScript) { if (Current.is(tok::exclaim)) { if (Current.Previous && - (Current.Previous->Tok.getIdentifierInfo() || - Current.Previous->isOneOf(tok::identifier, tok::r_paren, - tok::r_square, tok::r_brace) || + (Current.Previous->isOneOf(tok::identifier, tok::kw_namespace, + tok::r_paren, tok::r_square, + tok::r_brace) || Current.Previous->Tok.isLiteral())) { Current.Type = TT_JsNonNullAssertion; return; |