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
This commit is contained in:
Martin Probst 2017-05-12 13:00:33 +00:00
parent d0d29addf9
commit 79f9c5fe0c
2 changed files with 3 additions and 1 deletions

View File

@ -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;

View File

@ -1799,6 +1799,7 @@ TEST_F(FormatTestJS, NonNullAssertionOperator) {
" .foo()!\n"
" .foo()!;\n",
getGoogleJSStyleWithColumns(20));
verifyFormat("let x = namespace!;\n");
}
TEST_F(FormatTestJS, Conditional) {