diff options
Diffstat (limited to 'clang/lib/Format/FormatTokenLexer.cpp')
| -rw-r--r-- | clang/lib/Format/FormatTokenLexer.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index 64fbd2d5d45b..7736a7042f86 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -78,7 +78,7 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() { assert(FirstInLineIndex == 0); do { Tokens.push_back(getNextToken()); - if (Style.Language == FormatStyle::LK_JavaScript) { + if (Style.isJavaScript()) { tryParseJSRegexLiteral(); handleTemplateStrings(); } @@ -107,7 +107,7 @@ void FormatTokenLexer::tryMergePreviousTokens() { if (Style.isCpp() && tryTransformTryUsageForC()) return; - if (Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) { + if (Style.isJavaScript() || Style.isCSharp()) { static const tok::TokenKind NullishCoalescingOperator[] = {tok::question, tok::question}; static const tok::TokenKind NullPropagatingOperator[] = {tok::question, @@ -152,7 +152,7 @@ void FormatTokenLexer::tryMergePreviousTokens() { if (tryMergeNSStringLiteral()) return; - if (Style.Language == FormatStyle::LK_JavaScript) { + if (Style.isJavaScript()) { static const tok::TokenKind JSIdentity[] = {tok::equalequal, tok::equal}; static const tok::TokenKind JSNotIdentity[] = {tok::exclaimequal, tok::equal}; @@ -920,8 +920,7 @@ FormatToken *FormatTokenLexer::getNextToken() { // finds comments that contain a backslash followed by a line break, truncates // the comment token at the backslash, and resets the lexer to restart behind // the backslash. - if ((Style.Language == FormatStyle::LK_JavaScript || - Style.Language == FormatStyle::LK_Java) && + if ((Style.isJavaScript() || Style.Language == FormatStyle::LK_Java) && FormatTok->is(tok::comment) && FormatTok->TokenText.startswith("//")) { size_t BackslashPos = FormatTok->TokenText.find('\\'); while (BackslashPos != StringRef::npos) { @@ -982,7 +981,7 @@ FormatToken *FormatTokenLexer::getNextToken() { tok::kw_operator)) { FormatTok->Tok.setKind(tok::identifier); FormatTok->Tok.setIdentifierInfo(nullptr); - } else if (Style.Language == FormatStyle::LK_JavaScript && + } else if (Style.isJavaScript() && FormatTok->isOneOf(tok::kw_struct, tok::kw_union, tok::kw_operator)) { FormatTok->Tok.setKind(tok::identifier); @@ -1060,14 +1059,12 @@ void FormatTokenLexer::readRawToken(FormatToken &Tok) { if (!Tok.TokenText.empty() && Tok.TokenText[0] == '"') { Tok.Tok.setKind(tok::string_literal); Tok.IsUnterminatedLiteral = true; - } else if (Style.Language == FormatStyle::LK_JavaScript && - Tok.TokenText == "''") { + } else if (Style.isJavaScript() && Tok.TokenText == "''") { Tok.Tok.setKind(tok::string_literal); } } - if ((Style.Language == FormatStyle::LK_JavaScript || - Style.Language == FormatStyle::LK_Proto || + if ((Style.isJavaScript() || Style.Language == FormatStyle::LK_Proto || Style.Language == FormatStyle::LK_TextProto) && Tok.is(tok::char_constant)) { Tok.Tok.setKind(tok::string_literal); |
