OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/src/dart/ast/token.dart'; | 10 import 'package:analyzer/src/dart/ast/token.dart'; |
(...skipping 6284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6295 expect(reference.identifier, isNotNull); | 6295 expect(reference.identifier, isNotNull); |
6296 expect(reference.offset, 20); | 6296 expect(reference.offset, 20); |
6297 // the reference is recorded in the comment token | 6297 // the reference is recorded in the comment token |
6298 Token referenceToken = tokenReferences[1]; | 6298 Token referenceToken = tokenReferences[1]; |
6299 expect(referenceToken.offset, 20); | 6299 expect(referenceToken.offset, 20); |
6300 expect(referenceToken.lexeme, 'bb'); | 6300 expect(referenceToken.lexeme, 'bb'); |
6301 } | 6301 } |
6302 } | 6302 } |
6303 | 6303 |
6304 void test_parseCommentReferences_notClosed_noIdentifier() { | 6304 void test_parseCommentReferences_notClosed_noIdentifier() { |
6305 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6305 DocumentationCommentToken docToken = new DocumentationCommentToken( |
6306 new DocumentationCommentToken( | 6306 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5); |
6307 TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5) | 6307 List<CommentReference> references = parse( |
6308 ]; | 6308 "parseCommentReferences", |
6309 List<CommentReference> references = | 6309 <Object>[ |
6310 parse("parseCommentReferences", <Object>[tokens], "") | 6310 <DocumentationCommentToken>[docToken] |
6311 as List<CommentReference>; | 6311 ], |
| 6312 "") as List<CommentReference>; |
| 6313 expect(docToken.references, hasLength(1)); |
6312 expect(references, hasLength(1)); | 6314 expect(references, hasLength(1)); |
| 6315 Token referenceToken = docToken.references[0]; |
6313 CommentReference reference = references[0]; | 6316 CommentReference reference = references[0]; |
6314 expect(reference, isNotNull); | 6317 expect(reference, isNotNull); |
| 6318 expect(docToken.references[0], same(reference.beginToken)); |
6315 expect(reference.identifier, isNotNull); | 6319 expect(reference.identifier, isNotNull); |
6316 expect(reference.identifier.isSynthetic, isTrue); | 6320 expect(reference.identifier.isSynthetic, isTrue); |
6317 expect(reference.identifier.name, ""); | 6321 expect(reference.identifier.name, ""); |
| 6322 // Should end with EOF token. |
| 6323 Token nextToken = referenceToken.next; |
| 6324 expect(nextToken, isNotNull); |
| 6325 expect(nextToken.type, TokenType.EOF); |
6318 } | 6326 } |
6319 | 6327 |
6320 void test_parseCommentReferences_notClosed_withIdentifier() { | 6328 void test_parseCommentReferences_notClosed_withIdentifier() { |
6321 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6329 DocumentationCommentToken docToken = new DocumentationCommentToken( |
6322 new DocumentationCommentToken( | 6330 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5); |
6323 TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text", 5) | |
6324 ]; | |
6325 List<CommentReference> references = | 6331 List<CommentReference> references = |
6326 parse("parseCommentReferences", <Object>[tokens], "") | 6332 parse("parseCommentReferences", <Object>[<DocumentationCommentToken>[ |
| 6333 docToken |
| 6334 ]], "") |
6327 as List<CommentReference>; | 6335 as List<CommentReference>; |
| 6336 expect(docToken.references, hasLength(1)); |
6328 expect(references, hasLength(1)); | 6337 expect(references, hasLength(1)); |
| 6338 Token referenceToken = docToken.references[0]; |
6329 CommentReference reference = references[0]; | 6339 CommentReference reference = references[0]; |
6330 expect(reference, isNotNull); | 6340 expect(reference, isNotNull); |
| 6341 expect(referenceToken, same(reference.beginToken)); |
6331 expect(reference.identifier, isNotNull); | 6342 expect(reference.identifier, isNotNull); |
6332 expect(reference.identifier.isSynthetic, isFalse); | 6343 expect(reference.identifier.isSynthetic, isFalse); |
6333 expect(reference.identifier.name, "namePrefix"); | 6344 expect(reference.identifier.name, "namePrefix"); |
| 6345 // Should end with EOF token. |
| 6346 Token nextToken = referenceToken.next; |
| 6347 expect(nextToken, isNotNull); |
| 6348 expect(nextToken.type, TokenType.EOF); |
6334 } | 6349 } |
6335 | 6350 |
6336 void test_parseCommentReferences_singleLine() { | 6351 void test_parseCommentReferences_singleLine() { |
6337 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ | 6352 List<DocumentationCommentToken> tokens = <DocumentationCommentToken>[ |
6338 new DocumentationCommentToken( | 6353 new DocumentationCommentToken( |
6339 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3), | 6354 TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz", 3), |
6340 new DocumentationCommentToken( | 6355 new DocumentationCommentToken( |
6341 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28) | 6356 TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28) |
6342 ]; | 6357 ]; |
6343 List<CommentReference> references = | 6358 List<CommentReference> references = |
(...skipping 4833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11177 new Scanner(null, new CharSequenceReader(source), listener); | 11192 new Scanner(null, new CharSequenceReader(source), listener); |
11178 Token tokenStream = scanner.tokenize(); | 11193 Token tokenStream = scanner.tokenize(); |
11179 // | 11194 // |
11180 // Parse the source. | 11195 // Parse the source. |
11181 // | 11196 // |
11182 Parser parser = new Parser(null, listener); | 11197 Parser parser = new Parser(null, listener); |
11183 return invokeParserMethodImpl( | 11198 return invokeParserMethodImpl( |
11184 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11199 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
11185 } | 11200 } |
11186 } | 11201 } |
OLD | NEW |