aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/SortJavaScriptImports.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/SortJavaScriptImports.cpp')
-rw-r--r--clang/lib/Format/SortJavaScriptImports.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp
index 3ba649d07964..8c6722e91534 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -530,7 +530,7 @@ private:
nextToken();
if (Current->is(tok::semi))
return true;
- if (!Current->is(tok::period))
+ if (Current->isNot(tok::period))
return false;
nextToken();
}
@@ -548,10 +548,12 @@ private:
nextToken();
if (Current->is(tok::r_brace))
break;
- bool isTypeOnly =
- Current->is(Keywords.kw_type) && Current->Next &&
- Current->Next->isOneOf(tok::identifier, tok::kw_default);
- if (!isTypeOnly && !Current->isOneOf(tok::identifier, tok::kw_default))
+ auto IsIdentifier = [](const auto *Tok) {
+ return Tok->isOneOf(tok::identifier, tok::kw_default, tok::kw_template);
+ };
+ bool isTypeOnly = Current->is(Keywords.kw_type) && Current->Next &&
+ IsIdentifier(Current->Next);
+ if (!isTypeOnly && !IsIdentifier(Current))
return false;
JsImportedSymbol Symbol;
@@ -565,7 +567,7 @@ private:
if (Current->is(Keywords.kw_as)) {
nextToken();
- if (!Current->isOneOf(tok::identifier, tok::kw_default))
+ if (!IsIdentifier(Current))
return false;
Symbol.Alias = Current->TokenText;
nextToken();