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

Side by Side Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 764243003: Updated detached tokens of references in documentation comments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | Annotate | Revision Log
OLDNEW
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 engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/incremental_scanner.dart'; 10 import 'package:analyzer/src/generated/incremental_scanner.dart';
(...skipping 6724 matching lines...) Expand 10 before | Expand all | Expand 10 after
6735 SimpleIdentifier, 6735 SimpleIdentifier,
6736 reference.identifier); 6736 reference.identifier);
6737 expect(identifier, isNotNull); 6737 expect(identifier, isNotNull);
6738 expect(identifier.isSynthetic, isTrue); 6738 expect(identifier.isSynthetic, isTrue);
6739 expect(identifier.token, isNotNull); 6739 expect(identifier.token, isNotNull);
6740 expect(identifier.name, ""); 6740 expect(identifier.name, "");
6741 expect(identifier.offset, 5); 6741 expect(identifier.offset, 5);
6742 } 6742 }
6743 6743
6744 void test_parseCommentReferences_multiLine() { 6744 void test_parseCommentReferences_multiLine() {
6745 List<Token> tokens = <Token>[ 6745 CommentToken token = new CommentToken(
6746 new StringToken(TokenType.MULTI_LINE_COMMENT, "/** xxx [a] yyy [b] zzz * /", 3)]; 6746 TokenType.MULTI_LINE_COMMENT,
6747 "/** xxx [a] yyy [bb] zzz */",
6748 3);
6749 List<CommentToken> tokens = <CommentToken>[token];
6747 List<CommentReference> references = 6750 List<CommentReference> references =
6748 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6751 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6752 List<Token> tokenReferences = token.references;
6749 expect(references, hasLength(2)); 6753 expect(references, hasLength(2));
6750 CommentReference reference = references[0]; 6754 expect(tokenReferences, hasLength(2));
6751 expect(reference, isNotNull); 6755 {
6752 expect(reference.identifier, isNotNull); 6756 CommentReference reference = references[0];
6753 expect(reference.offset, 12); 6757 expect(reference, isNotNull);
6754 reference = references[1]; 6758 expect(reference.identifier, isNotNull);
6755 expect(reference, isNotNull); 6759 expect(reference.offset, 12);
6756 expect(reference.identifier, isNotNull); 6760 // the reference is recorded in the comment token
6757 expect(reference.offset, 20); 6761 Token referenceToken = tokenReferences[0];
6762 expect(referenceToken.offset, 12);
6763 expect(referenceToken.lexeme, 'a');
6764 }
6765 {
6766 CommentReference reference = references[1];
6767 expect(reference, isNotNull);
6768 expect(reference.identifier, isNotNull);
6769 expect(reference.offset, 20);
6770 // the reference is recorded in the comment token
6771 Token referenceToken = tokenReferences[1];
6772 expect(referenceToken.offset, 20);
6773 expect(referenceToken.lexeme, 'bb');
6774 }
6758 } 6775 }
6759 6776
6760 void test_parseCommentReferences_notClosed_noIdentifier() { 6777 void test_parseCommentReferences_notClosed_noIdentifier() {
6761 List<Token> tokens = <Token>[ 6778 List<CommentToken> tokens = <CommentToken>[
6762 new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5)]; 6779 new CommentToken(TokenType.MULTI_LINE_COMMENT, "/** [ some text", 5)];
6763 List<CommentReference> references = 6780 List<CommentReference> references =
6764 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6781 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6765 expect(references, hasLength(1)); 6782 expect(references, hasLength(1));
6766 CommentReference reference = references[0]; 6783 CommentReference reference = references[0];
6767 expect(reference, isNotNull); 6784 expect(reference, isNotNull);
6768 expect(reference.identifier, isNotNull); 6785 expect(reference.identifier, isNotNull);
6769 expect(reference.identifier.isSynthetic, isTrue); 6786 expect(reference.identifier.isSynthetic, isTrue);
6770 expect(reference.identifier.name, ""); 6787 expect(reference.identifier.name, "");
6771 } 6788 }
6772 6789
6773 void test_parseCommentReferences_notClosed_withIdentifier() { 6790 void test_parseCommentReferences_notClosed_withIdentifier() {
6774 List<Token> tokens = <Token>[ 6791 List<CommentToken> tokens = <CommentToken>[
6775 new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some text ", 5)]; 6792 new CommentToken(TokenType.MULTI_LINE_COMMENT, "/** [namePrefix some tex t", 5)];
6776 List<CommentReference> references = 6793 List<CommentReference> references =
6777 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6794 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6778 expect(references, hasLength(1)); 6795 expect(references, hasLength(1));
6779 CommentReference reference = references[0]; 6796 CommentReference reference = references[0];
6780 expect(reference, isNotNull); 6797 expect(reference, isNotNull);
6781 expect(reference.identifier, isNotNull); 6798 expect(reference.identifier, isNotNull);
6782 expect(reference.identifier.isSynthetic, isFalse); 6799 expect(reference.identifier.isSynthetic, isFalse);
6783 expect(reference.identifier.name, "namePrefix"); 6800 expect(reference.identifier.name, "namePrefix");
6784 } 6801 }
6785 6802
6786 void test_parseCommentReferences_singleLine() { 6803 void test_parseCommentReferences_singleLine() {
6787 List<Token> tokens = <Token>[ 6804 List<CommentToken> tokens = <CommentToken>[
6788 new StringToken(TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz" , 3), 6805 new CommentToken(TokenType.SINGLE_LINE_COMMENT, "/// xxx [a] yyy [b] zzz ", 3),
6789 new StringToken(TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28)]; 6806 new CommentToken(TokenType.SINGLE_LINE_COMMENT, "/// x [c]", 28)];
6790 List<CommentReference> references = 6807 List<CommentReference> references =
6791 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6808 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6792 expect(references, hasLength(3)); 6809 expect(references, hasLength(3));
6793 CommentReference reference = references[0]; 6810 CommentReference reference = references[0];
6794 expect(reference, isNotNull); 6811 expect(reference, isNotNull);
6795 expect(reference.identifier, isNotNull); 6812 expect(reference.identifier, isNotNull);
6796 expect(reference.offset, 12); 6813 expect(reference.offset, 12);
6797 reference = references[1]; 6814 reference = references[1];
6798 expect(reference, isNotNull); 6815 expect(reference, isNotNull);
6799 expect(reference.identifier, isNotNull); 6816 expect(reference.identifier, isNotNull);
6800 expect(reference.offset, 20); 6817 expect(reference.offset, 20);
6801 reference = references[2]; 6818 reference = references[2];
6802 expect(reference, isNotNull); 6819 expect(reference, isNotNull);
6803 expect(reference.identifier, isNotNull); 6820 expect(reference.identifier, isNotNull);
6804 expect(reference.offset, 35); 6821 expect(reference.offset, 35);
6805 } 6822 }
6806 6823
6807 void test_parseCommentReferences_skipCodeBlock_bracketed() { 6824 void test_parseCommentReferences_skipCodeBlock_bracketed() {
6808 List<Token> tokens = <Token>[ 6825 List<CommentToken> tokens = <CommentToken>[
6809 new StringToken( 6826 new CommentToken(
6810 TokenType.MULTI_LINE_COMMENT, 6827 TokenType.MULTI_LINE_COMMENT,
6811 "/** [:xxx [a] yyy:] [b] zzz */", 6828 "/** [:xxx [a] yyy:] [b] zzz */",
6812 3)]; 6829 3)];
6813 List<CommentReference> references = 6830 List<CommentReference> references =
6814 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6831 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6815 expect(references, hasLength(1)); 6832 expect(references, hasLength(1));
6816 CommentReference reference = references[0]; 6833 CommentReference reference = references[0];
6817 expect(reference, isNotNull); 6834 expect(reference, isNotNull);
6818 expect(reference.identifier, isNotNull); 6835 expect(reference.identifier, isNotNull);
6819 expect(reference.offset, 24); 6836 expect(reference.offset, 24);
6820 } 6837 }
6821 6838
6822 void test_parseCommentReferences_skipCodeBlock_spaces() { 6839 void test_parseCommentReferences_skipCodeBlock_spaces() {
6823 List<Token> tokens = <Token>[ 6840 List<CommentToken> tokens = <CommentToken>[
6824 new StringToken( 6841 new CommentToken(
6825 TokenType.MULTI_LINE_COMMENT, 6842 TokenType.MULTI_LINE_COMMENT,
6826 "/**\n * a[i]\n * xxx [i] zzz\n */", 6843 "/**\n * a[i]\n * xxx [i] zzz\n */",
6827 3)]; 6844 3)];
6828 List<CommentReference> references = 6845 List<CommentReference> references =
6829 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6846 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6830 expect(references, hasLength(1)); 6847 expect(references, hasLength(1));
6831 CommentReference reference = references[0]; 6848 CommentReference reference = references[0];
6832 expect(reference, isNotNull); 6849 expect(reference, isNotNull);
6833 expect(reference.identifier, isNotNull); 6850 expect(reference.identifier, isNotNull);
6834 expect(reference.offset, 27); 6851 expect(reference.offset, 27);
6835 } 6852 }
6836 6853
6837 void test_parseCommentReferences_skipLinkDefinition() { 6854 void test_parseCommentReferences_skipLinkDefinition() {
6838 List<Token> tokens = <Token>[ 6855 List<CommentToken> tokens = <CommentToken>[
6839 new StringToken( 6856 new CommentToken(
6840 TokenType.MULTI_LINE_COMMENT, 6857 TokenType.MULTI_LINE_COMMENT,
6841 "/** [a]: http://www.google.com (Google) [b] zzz */", 6858 "/** [a]: http://www.google.com (Google) [b] zzz */",
6842 3)]; 6859 3)];
6843 List<CommentReference> references = 6860 List<CommentReference> references =
6844 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6861 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6845 expect(references, hasLength(1)); 6862 expect(references, hasLength(1));
6846 CommentReference reference = references[0]; 6863 CommentReference reference = references[0];
6847 expect(reference, isNotNull); 6864 expect(reference, isNotNull);
6848 expect(reference.identifier, isNotNull); 6865 expect(reference.identifier, isNotNull);
6849 expect(reference.offset, 44); 6866 expect(reference.offset, 44);
6850 } 6867 }
6851 6868
6852 void test_parseCommentReferences_skipLinked() { 6869 void test_parseCommentReferences_skipLinked() {
6853 List<Token> tokens = <Token>[ 6870 List<CommentToken> tokens = <CommentToken>[
6854 new StringToken( 6871 new CommentToken(
6855 TokenType.MULTI_LINE_COMMENT, 6872 TokenType.MULTI_LINE_COMMENT,
6856 "/** [a](http://www.google.com) [b] zzz */", 6873 "/** [a](http://www.google.com) [b] zzz */",
6857 3)]; 6874 3)];
6858 List<CommentReference> references = 6875 List<CommentReference> references =
6859 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6876 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6860 expect(references, hasLength(1)); 6877 expect(references, hasLength(1));
6861 CommentReference reference = references[0]; 6878 CommentReference reference = references[0];
6862 expect(reference, isNotNull); 6879 expect(reference, isNotNull);
6863 expect(reference.identifier, isNotNull); 6880 expect(reference.identifier, isNotNull);
6864 expect(reference.offset, 35); 6881 expect(reference.offset, 35);
6865 } 6882 }
6866 6883
6867 void test_parseCommentReferences_skipReferenceLink() { 6884 void test_parseCommentReferences_skipReferenceLink() {
6868 List<Token> tokens = <Token>[ 6885 List<CommentToken> tokens = <CommentToken>[
6869 new StringToken(TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3 )]; 6886 new CommentToken(TokenType.MULTI_LINE_COMMENT, "/** [a][c] [b] zzz */", 3)];
6870 List<CommentReference> references = 6887 List<CommentReference> references =
6871 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], ""); 6888 ParserTestCase.parse("parseCommentReferences", <Object>[tokens], "");
6872 expect(references, hasLength(1)); 6889 expect(references, hasLength(1));
6873 CommentReference reference = references[0]; 6890 CommentReference reference = references[0];
6874 expect(reference, isNotNull); 6891 expect(reference, isNotNull);
6875 expect(reference.identifier, isNotNull); 6892 expect(reference.identifier, isNotNull);
6876 expect(reference.offset, 15); 6893 expect(reference.offset, 15);
6877 } 6894 }
6878 6895
6879 void test_parseCompilationUnit_abstractAsPrefix_parameterized() { 6896 void test_parseCompilationUnit_abstractAsPrefix_parameterized() {
(...skipping 4007 matching lines...) Expand 10 before | Expand all | Expand 10 after
10887 // Parse the source. 10904 // Parse the source.
10888 // 10905 //
10889 Parser parser = new Parser(null, listener); 10906 Parser parser = new Parser(null, listener);
10890 return invokeParserMethodImpl( 10907 return invokeParserMethodImpl(
10891 parser, 10908 parser,
10892 methodName, 10909 methodName,
10893 <Object>[tokenStream], 10910 <Object>[tokenStream],
10894 tokenStream) as Token; 10911 tokenStream) as Token;
10895 } 10912 }
10896 } 10913 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698