Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: pkg/analyzer/lib/src/fasta/token_utils.dart

Issue 2842213003: new TokenType and Keyword API (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/fasta/token_utils.dart
diff --git a/pkg/analyzer/lib/src/fasta/token_utils.dart b/pkg/analyzer/lib/src/fasta/token_utils.dart
index 028cb661f126ddfff04435f21e5c3cd84e51593d..ed035bc5905e339b3f0f321de1a844dbeaa8e591 100644
--- a/pkg/analyzer/lib/src/fasta/token_utils.dart
+++ b/pkg/analyzer/lib/src/fasta/token_utils.dart
@@ -279,6 +279,14 @@ Token fromAnalyzerToken(analyzer.Token token) {
Token string(TokenType info) =>
new StringToken.fromString(info, token.lexeme, token.offset);
Token symbol(TokenType info) => new SymbolToken(info, token.offset);
+ if (token.type.isKeyword) {
+ var keyword = Keyword.keywords[token.lexeme];
+ if (keyword != null) {
+ return new KeywordToken(keyword, token.offset);
+ } else {
+ return internalError("Unrecognized keyword: '${token.lexeme}'.");
+ }
+ }
switch (token.type) {
case TokenType.DOUBLE:
return string(TokenType.DOUBLE);
@@ -299,14 +307,6 @@ Token fromAnalyzerToken(analyzer.Token token) {
break;
case TokenType.INT:
return string(TokenType.INT);
- case TokenType.KEYWORD:
- var keyword = Keyword.keywords[token.lexeme];
- if (keyword != null) {
- return new KeywordToken(keyword, token.offset);
- } else {
- return internalError("Unrecognized keyword: '${token.lexeme}'.");
- }
- break;
case TokenType.MULTI_LINE_COMMENT:
if (token.lexeme.startsWith('/**')) {
return new DartDocToken.fromSubstring(TokenType.MULTI_LINE_COMMENT,
@@ -491,7 +491,7 @@ analyzer.Token toAnalyzerToken(Token token,
case KEYWORD_TOKEN:
KeywordToken keywordToken = token;
- var syntax = keywordToken.keyword.syntax;
+ var syntax = keywordToken.keyword.lexeme;
// TODO(paulberry): if the map lookup proves to be too slow, consider
// using a switch statement, or perhaps a string of
// "if (identical(syntax, "foo"))" checks. (Note that identical checks
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/type.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698