OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer/src/fasta/token_utils.dart'; | 5 import 'package:analyzer/src/fasta/token_utils.dart'; |
6 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; | 6 import 'package:front_end/src/fasta/scanner/error_token.dart' as fasta; |
7 import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta; | 7 import 'package:front_end/src/fasta/scanner/keyword.dart' as fasta; |
8 import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta; | 8 import 'package:front_end/src/fasta/scanner/string_scanner.dart' as fasta; |
9 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; | 9 import 'package:front_end/src/fasta/scanner/token.dart' as fasta; |
10 import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta; | 10 import 'package:front_end/src/fasta/scanner/token_constants.dart' as fasta; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 expect(tokenCount, 26); | 95 expect(tokenCount, 26); |
96 | 96 |
97 tokenCount = 0; | 97 tokenCount = 0; |
98 int previousEnd = 0; | 98 int previousEnd = 0; |
99 int spotCheckCount = 0; | 99 int spotCheckCount = 0; |
100 int commentTokenCount = 0; | 100 int commentTokenCount = 0; |
101 token = scanSource(includeComments: true); | 101 token = scanSource(includeComments: true); |
102 while (!token.isEof) { | 102 while (!token.isEof) { |
103 ++tokenCount; | 103 ++tokenCount; |
104 // Assert valid comments | 104 // Assert valid comments |
105 fasta.Token comment = token.precedingComments; | 105 fasta.CommentToken comment = token.precedingComments; |
106 while (comment != null) { | 106 while (comment != null) { |
107 ++commentTokenCount; | 107 ++commentTokenCount; |
108 expect(comment.info.kind, fasta.COMMENT_TOKEN); | 108 expect(comment.info.kind, fasta.COMMENT_TOKEN); |
109 expect(comment.charOffset, greaterThanOrEqualTo(previousEnd)); | 109 expect(comment.charOffset, greaterThanOrEqualTo(previousEnd)); |
110 previousEnd = comment.charOffset + comment.charCount; | 110 previousEnd = comment.charOffset + comment.charCount; |
111 comment = comment.next; | 111 comment = comment.next; |
112 } | 112 } |
113 expect(token.info.kind, isNot(fasta.COMMENT_TOKEN)); | 113 expect(token.info.kind, isNot(fasta.COMMENT_TOKEN)); |
114 expect(token.charOffset, greaterThanOrEqualTo(previousEnd)); | 114 expect(token.charOffset, greaterThanOrEqualTo(previousEnd)); |
115 previousEnd = token.charOffset + token.charCount; | 115 previousEnd = token.charOffset + token.charCount; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Figure out which recovery technique we want the front end to use. | 170 // Figure out which recovery technique we want the front end to use. |
171 super.test_mismatched_opener(); | 171 super.test_mismatched_opener(); |
172 } | 172 } |
173 | 173 |
174 void test_next_previous() { | 174 void test_next_previous() { |
175 const source = 'int a; /*1*/ /*2*/ /*3*/ B f(){if (a < 2) {}}'; | 175 const source = 'int a; /*1*/ /*2*/ /*3*/ B f(){if (a < 2) {}}'; |
176 fasta.Token token = | 176 fasta.Token token = |
177 new fasta.StringScanner(source, includeComments: true).tokenize(); | 177 new fasta.StringScanner(source, includeComments: true).tokenize(); |
178 while (!token.isEof) { | 178 while (!token.isEof) { |
179 expect(token.next.previousToken, token); | 179 expect(token.next.previousToken, token); |
180 fasta.Token commentToken = token.precedingComments; | 180 fasta.CommentToken commentToken = token.precedingComments; |
181 while (commentToken != null) { | 181 while (commentToken != null) { |
182 if (commentToken.next != null) { | 182 if (commentToken.next != null) { |
183 expect(commentToken.next.previousToken, commentToken); | 183 expect(commentToken.next.previousToken, commentToken); |
184 } | 184 } |
185 commentToken = commentToken.next; | 185 commentToken = commentToken.next; |
186 } | 186 } |
187 token = token.next; | 187 token = token.next; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 final ErrorListener _listener; | 459 final ErrorListener _listener; |
460 | 460 |
461 ToAnalyzerTokenStreamConverter_WithListener(this._listener); | 461 ToAnalyzerTokenStreamConverter_WithListener(this._listener); |
462 | 462 |
463 @override | 463 @override |
464 void reportError( | 464 void reportError( |
465 ScannerErrorCode errorCode, int offset, List<Object> arguments) { | 465 ScannerErrorCode errorCode, int offset, List<Object> arguments) { |
466 _listener.errors.add(new TestError(offset, errorCode, arguments)); | 466 _listener.errors.add(new TestError(offset, errorCode, arguments)); |
467 } | 467 } |
468 } | 468 } |
OLD | NEW |