| 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/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
| 6 import 'package:analyzer/dart/ast/token.dart' as analyzer; | 6 import 'package:analyzer/dart/ast/token.dart' as analyzer; |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/error/error.dart'; | 8 import 'package:analyzer/error/error.dart'; |
| 9 import 'package:analyzer/src/generated/parser.dart' as analyzer; | 9 import 'package:analyzer/src/generated/parser.dart' as analyzer; |
| 10 import 'package:analyzer/src/generated/utilities_dart.dart'; | 10 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 463 } |
| 464 | 464 |
| 465 @override | 465 @override |
| 466 @failingTest | 466 @failingTest |
| 467 void test_parseListLiteral_empty_oneToken_withComment() { | 467 void test_parseListLiteral_empty_oneToken_withComment() { |
| 468 super.test_parseListLiteral_empty_oneToken_withComment(); | 468 super.test_parseListLiteral_empty_oneToken_withComment(); |
| 469 } | 469 } |
| 470 | 470 |
| 471 @override | 471 @override |
| 472 @failingTest | 472 @failingTest |
| 473 void test_parseListOrMapLiteral_map_noType() { | |
| 474 super.test_parseListOrMapLiteral_map_noType(); | |
| 475 } | |
| 476 | |
| 477 @override | |
| 478 @failingTest | |
| 479 void | 473 void |
| 480 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { | 474 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { |
| 481 super | 475 super |
| 482 .test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgu
mentComments(); | 476 .test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgu
mentComments(); |
| 483 } | 477 } |
| 484 | 478 |
| 485 @override | 479 @override |
| 486 @failingTest | 480 @failingTest |
| 487 void | 481 void |
| 488 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { | 482 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { |
| 489 super | 483 super |
| 490 .test_parsePostfixExpression_none_methodInvocation_typeArgumentComments(
); | 484 .test_parsePostfixExpression_none_methodInvocation_typeArgumentComments(
); |
| 491 } | 485 } |
| 492 | 486 |
| 493 @override | 487 @override |
| 494 @failingTest | 488 @failingTest |
| 495 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { | 489 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { |
| 496 super.test_parsePrimaryExpression_listLiteral_typed_genericComment(); | 490 super.test_parsePrimaryExpression_listLiteral_typed_genericComment(); |
| 497 } | 491 } |
| 498 | 492 |
| 499 @override | 493 @override |
| 500 @failingTest | 494 @failingTest |
| 501 void test_parsePrimaryExpression_mapLiteral() { | |
| 502 super.test_parsePrimaryExpression_mapLiteral(); | |
| 503 } | |
| 504 | |
| 505 @override | |
| 506 @failingTest | |
| 507 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { | 495 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { |
| 508 super.test_parsePrimaryExpression_mapLiteral_typed_genericComment(); | 496 super.test_parsePrimaryExpression_mapLiteral_typed_genericComment(); |
| 509 } | 497 } |
| 510 | 498 |
| 511 @override | 499 @override |
| 500 @failingTest |
| 501 void test_parsePrimaryExpression_super() { |
| 502 super.test_parsePrimaryExpression_super(); |
| 503 } |
| 504 |
| 505 @override |
| 512 @failingTest | 506 @failingTest |
| 513 void test_parseRelationalExpression_as_nullable() { | 507 void test_parseRelationalExpression_as_nullable() { |
| 514 super.test_parseRelationalExpression_as_nullable(); | 508 super.test_parseRelationalExpression_as_nullable(); |
| 515 } | 509 } |
| 516 | 510 |
| 517 @override | 511 @override |
| 518 @failingTest | 512 @failingTest |
| 519 void test_parseRelationalExpression_is_nullable() { | 513 void test_parseRelationalExpression_is_nullable() { |
| 520 super.test_parseRelationalExpression_is_nullable(); | 514 super.test_parseRelationalExpression_is_nullable(); |
| 521 } | 515 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 if (typeArgumentsCode != null) { | 777 if (typeArgumentsCode != null) { |
| 784 sc += typeArgumentsCode; | 778 sc += typeArgumentsCode; |
| 785 } | 779 } |
| 786 sc += code; | 780 sc += code; |
| 787 return _parseExpression(sc); | 781 return _parseExpression(sc); |
| 788 } | 782 } |
| 789 | 783 |
| 790 @override | 784 @override |
| 791 TypedLiteral parseListOrMapLiteral(analyzer.Token modifier, String code) { | 785 TypedLiteral parseListOrMapLiteral(analyzer.Token modifier, String code) { |
| 792 String literalCode = modifier != null ? '$modifier $code' : code; | 786 String literalCode = modifier != null ? '$modifier $code' : code; |
| 793 return _parseExpression(literalCode); | 787 return parsePrimaryExpression(literalCode) as TypedLiteral; |
| 794 } | 788 } |
| 795 | 789 |
| 796 @override | 790 @override |
| 797 Expression parseLogicalAndExpression(String code) { | 791 Expression parseLogicalAndExpression(String code) { |
| 798 return _parseExpression(code); | 792 return _parseExpression(code); |
| 799 } | 793 } |
| 800 | 794 |
| 801 @override | 795 @override |
| 802 Expression parseLogicalOrExpression(String code) { | 796 Expression parseLogicalOrExpression(String code) { |
| 803 return _parseExpression(code); | 797 return _parseExpression(code); |
| 804 } | 798 } |
| 805 | 799 |
| 806 @override | 800 @override |
| 807 MapLiteral parseMapLiteral( | 801 MapLiteral parseMapLiteral( |
| 808 analyzer.Token token, String typeArgumentsCode, String code) { | 802 analyzer.Token token, String typeArgumentsCode, String code) { |
| 809 String sc = ''; | 803 String sc = ''; |
| 810 if (token != null) { | 804 if (token != null) { |
| 811 sc += token.lexeme + ' '; | 805 sc += token.lexeme + ' '; |
| 812 } | 806 } |
| 813 if (typeArgumentsCode != null) { | 807 if (typeArgumentsCode != null) { |
| 814 sc += typeArgumentsCode; | 808 sc += typeArgumentsCode; |
| 815 } | 809 } |
| 816 sc += code; | 810 sc += code; |
| 817 return _parseMapLiteralCode(sc); | 811 return parsePrimaryExpression(sc) as MapLiteral; |
| 818 } | 812 } |
| 819 | 813 |
| 820 @override | 814 @override |
| 821 MapLiteralEntry parseMapLiteralEntry(String code) { | 815 MapLiteralEntry parseMapLiteralEntry(String code) { |
| 822 return _parseMapLiteralCode('{$code}').entries.single; | 816 var mapLiteral = parseMapLiteral(null, null, '{ $code }'); |
| 817 return mapLiteral.entries.single; |
| 823 } | 818 } |
| 824 | 819 |
| 825 @override | 820 @override |
| 826 Expression parseMultiplicativeExpression(String code) { | 821 Expression parseMultiplicativeExpression(String code) { |
| 827 return _parseExpression(code); | 822 return _parseExpression(code); |
| 828 } | 823 } |
| 829 | 824 |
| 830 @override | 825 @override |
| 831 InstanceCreationExpression parseNewExpression(String code) { | 826 InstanceCreationExpression parseNewExpression(String code) { |
| 832 return _parseExpression(code); | 827 return _parseExpression(code); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 846 return _parseExpression(code); | 841 return _parseExpression(code); |
| 847 } | 842 } |
| 848 | 843 |
| 849 @override | 844 @override |
| 850 Identifier parsePrefixedIdentifier(String code) { | 845 Identifier parsePrefixedIdentifier(String code) { |
| 851 return _parseExpression(code); | 846 return _parseExpression(code); |
| 852 } | 847 } |
| 853 | 848 |
| 854 @override | 849 @override |
| 855 Expression parsePrimaryExpression(String code) { | 850 Expression parsePrimaryExpression(String code) { |
| 856 return _parseExpression(code); | 851 return _runParser( |
| 852 code, (parser) => parser.parsePrimary, const <ErrorCode>[]) |
| 853 as Expression; |
| 857 } | 854 } |
| 858 | 855 |
| 859 @override | 856 @override |
| 860 Expression parseRelationalExpression(String code) { | 857 Expression parseRelationalExpression(String code) { |
| 861 return _parseExpression(code); | 858 return _parseExpression(code); |
| 862 } | 859 } |
| 863 | 860 |
| 864 @override | 861 @override |
| 865 RethrowExpression parseRethrowExpression(String code) { | 862 RethrowExpression parseRethrowExpression(String code) { |
| 866 return _parseExpression(code); | 863 return _parseExpression(code); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 @override | 910 @override |
| 914 PrefixExpression parseUnaryExpression(String code) { | 911 PrefixExpression parseUnaryExpression(String code) { |
| 915 return _parseExpression(code); | 912 return _parseExpression(code); |
| 916 } | 913 } |
| 917 | 914 |
| 918 Expression _parseExpression(String code) { | 915 Expression _parseExpression(String code) { |
| 919 var statement = parseStatement('$code;') as ExpressionStatement; | 916 var statement = parseStatement('$code;') as ExpressionStatement; |
| 920 return statement.expression; | 917 return statement.expression; |
| 921 } | 918 } |
| 922 | 919 |
| 923 MapLiteral _parseMapLiteralCode(String code) { | |
| 924 var statement = | |
| 925 parseStatement('var v = $code;') as VariableDeclarationStatement; | |
| 926 return statement.variables.variables.single.initializer as MapLiteral; | |
| 927 } | |
| 928 | |
| 929 Object _runParser( | 920 Object _runParser( |
| 930 String source, ParseFunction getParseFunction(fasta.Parser parser), | 921 String source, ParseFunction getParseFunction(fasta.Parser parser), |
| 931 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 922 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 932 if (errorCodes.isNotEmpty) { | 923 if (errorCodes.isNotEmpty) { |
| 933 // TODO(paulberry): Check that the parser generates the proper errors. | 924 // TODO(paulberry): Check that the parser generates the proper errors. |
| 934 throw new UnimplementedError(); | 925 throw new UnimplementedError(); |
| 935 } | 926 } |
| 936 createParser(source); | 927 createParser(source); |
| 937 return _parserProxy._run(getParseFunction); | 928 return _parserProxy._run(getParseFunction); |
| 938 } | 929 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 @override | 1191 @override |
| 1201 @failingTest | 1192 @failingTest |
| 1202 void | 1193 void |
| 1203 test_parseCompilationUnitMember_function_generic_noReturnType_annotated()
{ | 1194 test_parseCompilationUnitMember_function_generic_noReturnType_annotated()
{ |
| 1204 // TODO(paulberry,ahe): Fasta doesn't appear to support annotated type | 1195 // TODO(paulberry,ahe): Fasta doesn't appear to support annotated type |
| 1205 // parameters. | 1196 // parameters. |
| 1206 super | 1197 super |
| 1207 .test_parseCompilationUnitMember_function_generic_noReturnType_annotated
(); | 1198 .test_parseCompilationUnitMember_function_generic_noReturnType_annotated
(); |
| 1208 } | 1199 } |
| 1209 | 1200 |
| 1210 void test_parseCompilationUnitMember_typedef() { | |
| 1211 // TODO(paulberry): Unhandled event: FunctionTypeAlias | |
| 1212 super.test_parseCompilationUnitMember_typedef(); | |
| 1213 } | |
| 1214 | |
| 1215 @override | 1201 @override |
| 1216 @failingTest | 1202 @failingTest |
| 1217 void test_parseDirectives_mixed() { | 1203 void test_parseDirectives_mixed() { |
| 1218 // TODO(paulberry,ahe): This test verifies the analyzer parser's ability to | 1204 // TODO(paulberry,ahe): This test verifies the analyzer parser's ability to |
| 1219 // stop parsing as soon as the first non-directive is encountered; this is | 1205 // stop parsing as soon as the first non-directive is encountered; this is |
| 1220 // useful for quickly traversing an import graph. Consider adding a similar | 1206 // useful for quickly traversing an import graph. Consider adding a similar |
| 1221 // ability to Fasta's parser. | 1207 // ability to Fasta's parser. |
| 1222 super.test_parseDirectives_mixed(); | 1208 super.test_parseDirectives_mixed(); |
| 1223 } | 1209 } |
| 1224 | 1210 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 } | 1255 } |
| 1270 | 1256 |
| 1271 @override | 1257 @override |
| 1272 @failingTest | 1258 @failingTest |
| 1273 void test_parsePartOfDirective_uri() { | 1259 void test_parsePartOfDirective_uri() { |
| 1274 // TODO(paulberry,ahe): URIs in "part of" declarations are not supported by | 1260 // TODO(paulberry,ahe): URIs in "part of" declarations are not supported by |
| 1275 // Fasta. | 1261 // Fasta. |
| 1276 super.test_parsePartOfDirective_uri(); | 1262 super.test_parsePartOfDirective_uri(); |
| 1277 } | 1263 } |
| 1278 } | 1264 } |
| OLD | NEW |