| OLD | NEW |
| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 /// fasta may contain synthetic tokens from error recovery that are not mapped | 147 /// fasta may contain synthetic tokens from error recovery that are not mapped |
| 148 /// to the analyzer token stream. We use [_beginTokenStack] and | 148 /// to the analyzer token stream. We use [_beginTokenStack] and |
| 149 /// [_endTokenStack] to create the appropriate links for non-synthetic tokens | 149 /// [_endTokenStack] to create the appropriate links for non-synthetic tokens |
| 150 /// in the way analyzer expects. | 150 /// in the way analyzer expects. |
| 151 void _matchGroups(Token token, analyzer.Token translatedToken) { | 151 void _matchGroups(Token token, analyzer.Token translatedToken) { |
| 152 if (identical(_endTokenStack.last, token)) { | 152 if (identical(_endTokenStack.last, token)) { |
| 153 _beginTokenStack.last.endToken = translatedToken; | 153 _beginTokenStack.last.endToken = translatedToken; |
| 154 _beginTokenStack.removeLast(); | 154 _beginTokenStack.removeLast(); |
| 155 _endTokenStack.removeLast(); | 155 _endTokenStack.removeLast(); |
| 156 } | 156 } |
| 157 // Synthetic end tokens use the same offset as the begin token. | 157 // Synthetic end tokens have a length of zero. |
| 158 if (translatedToken is analyzer.BeginToken && | 158 if (translatedToken is analyzer.BeginToken && |
| 159 token is BeginGroupToken && | 159 token is BeginGroupToken && |
| 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 |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 case PERIOD_PERIOD_PERIOD_TOKEN: | 739 case PERIOD_PERIOD_PERIOD_TOKEN: |
| 740 return TokenType.PERIOD_PERIOD_PERIOD; | 740 return TokenType.PERIOD_PERIOD_PERIOD; |
| 741 case GENERIC_METHOD_TYPE_LIST_TOKEN: | 741 case GENERIC_METHOD_TYPE_LIST_TOKEN: |
| 742 return TokenType.GENERIC_METHOD_TYPE_LIST; | 742 return TokenType.GENERIC_METHOD_TYPE_LIST; |
| 743 case GENERIC_METHOD_TYPE_ASSIGN_TOKEN: | 743 case GENERIC_METHOD_TYPE_ASSIGN_TOKEN: |
| 744 return TokenType.GENERIC_METHOD_TYPE_ASSIGN; | 744 return TokenType.GENERIC_METHOD_TYPE_ASSIGN; |
| 745 default: | 745 default: |
| 746 return internalError("Unhandled token ${token.info}"); | 746 return internalError("Unhandled token ${token.info}"); |
| 747 } | 747 } |
| 748 } | 748 } |
| OLD | NEW |