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

Side by Side Diff: pkg/analyzer/lib/src/fasta/token_utils.dart

Issue 2792053002: Scan generic method comments with Fasta. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library fasta.analyzer.token_utils; 5 library fasta.analyzer.token_utils;
6 6
7 import 'package:front_end/src/fasta/scanner/error_token.dart' show ErrorToken; 7 import 'package:front_end/src/fasta/scanner/error_token.dart' show ErrorToken;
8 8
9 import 'package:front_end/src/fasta/scanner/keyword.dart' show Keyword; 9 import 'package:front_end/src/fasta/scanner/keyword.dart' show Keyword;
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 token.endGroup != null && 160 token.endGroup != null &&
161 token.endGroup.charOffset != token.charOffset) { 161 token.endGroup.charOffset != token.charOffset) {
162 _beginTokenStack.add(translatedToken); 162 _beginTokenStack.add(translatedToken);
163 _endTokenStack.add(token.endGroup); 163 _endTokenStack.add(token.endGroup);
164 } 164 }
165 } 165 }
166 } 166 }
167 167
168 /// Converts a single Fasta comment token to an analyzer comment token. 168 /// Converts a single Fasta comment token to an analyzer comment token.
169 analyzer.CommentToken toAnalyzerCommentToken(Token token) { 169 analyzer.CommentToken toAnalyzerCommentToken(Token token) {
170 // TODO(paulberry,ahe): It would be nice if the scanner gave us an 170 TokenType type;
171 // easier way to distinguish between the two types of comment. 171 if (token.type == GENERIC_METHOD_TYPE_ASSIGN) {
172 var type = token.lexeme.startsWith('/*') 172 type = TokenType.GENERIC_METHOD_TYPE_ASSIGN;
173 ? TokenType.MULTI_LINE_COMMENT 173 } else if (token.type == GENERIC_METHOD_TYPE_LIST) {
174 : TokenType.SINGLE_LINE_COMMENT; 174 type = TokenType.GENERIC_METHOD_TYPE_LIST;
175 } else {
176 // TODO(paulberry,ahe): It would be nice if the scanner gave us an
177 // easier way to distinguish between the two types of comment.
178 type = token.lexeme.startsWith('/*')
179 ? TokenType.MULTI_LINE_COMMENT
180 : TokenType.SINGLE_LINE_COMMENT;
181 }
175 return new analyzer.CommentToken(type, token.lexeme, token.charOffset); 182 return new analyzer.CommentToken(type, token.lexeme, token.charOffset);
176 } 183 }
177 184
178 /// Converts a stream of Analyzer tokens (starting with [token] and continuing 185 /// Converts a stream of Analyzer tokens (starting with [token] and continuing
179 /// to EOF) to a stream of Fasta tokens. 186 /// to EOF) to a stream of Fasta tokens.
180 /// 187 ///
181 /// TODO(paulberry): Analyzer tokens do not record error conditions, so a round 188 /// TODO(paulberry): Analyzer tokens do not record error conditions, so a round
182 /// trip through this function and [toAnalyzerTokenStream] will lose error 189 /// trip through this function and [toAnalyzerTokenStream] will lose error
183 /// information. 190 /// information.
184 Token fromAnalyzerTokenStream(analyzer.Token analyzerToken) { 191 Token fromAnalyzerTokenStream(analyzer.Token analyzerToken) {
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 case TILDE_SLASH_TOKEN: 731 case TILDE_SLASH_TOKEN:
725 return TokenType.TILDE_SLASH; 732 return TokenType.TILDE_SLASH;
726 case TILDE_SLASH_EQ_TOKEN: 733 case TILDE_SLASH_EQ_TOKEN:
727 return TokenType.TILDE_SLASH_EQ; 734 return TokenType.TILDE_SLASH_EQ;
728 case BACKPING_TOKEN: 735 case BACKPING_TOKEN:
729 return TokenType.BACKPING; 736 return TokenType.BACKPING;
730 case BACKSLASH_TOKEN: 737 case BACKSLASH_TOKEN:
731 return TokenType.BACKSLASH; 738 return TokenType.BACKSLASH;
732 case PERIOD_PERIOD_PERIOD_TOKEN: 739 case PERIOD_PERIOD_PERIOD_TOKEN:
733 return TokenType.PERIOD_PERIOD_PERIOD; 740 return TokenType.PERIOD_PERIOD_PERIOD;
734 // case GENERIC_METHOD_TYPE_LIST_TOKEN: 741 case GENERIC_METHOD_TYPE_LIST_TOKEN:
735 // return TokenType.GENERIC_METHOD_TYPE_LIST; 742 return TokenType.GENERIC_METHOD_TYPE_LIST;
736 // case GENERIC_METHOD_TYPE_ASSIGN_TOKEN: 743 case GENERIC_METHOD_TYPE_ASSIGN_TOKEN:
737 // return TokenType.GENERIC_METHOD_TYPE_ASSIGN; 744 return TokenType.GENERIC_METHOD_TYPE_ASSIGN;
738 default: 745 default:
739 return internalError("Unhandled token ${token.info}"); 746 return internalError("Unhandled token ${token.info}");
740 } 747 }
741 } 748 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698