| 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'; | |
| 8 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 9 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 8 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 10 import 'package:analyzer/src/fasta/ast_builder.dart'; | 9 import 'package:analyzer/src/fasta/ast_builder.dart'; |
| 11 import 'package:analyzer/src/fasta/element_store.dart'; | |
| 12 import 'package:analyzer/src/generated/parser.dart' as analyzer; | 10 import 'package:analyzer/src/generated/parser.dart' as analyzer; |
| 13 import 'package:analyzer/src/generated/utilities_dart.dart'; | 11 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 14 import 'package:analyzer/src/string_source.dart'; | 12 import 'package:analyzer/src/string_source.dart'; |
| 15 import 'package:front_end/src/fasta/fasta_codes.dart' show Message; | 13 import 'package:front_end/src/fasta/fasta_codes.dart' show Message; |
| 16 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; | 14 import 'package:front_end/src/fasta/kernel/kernel_builder.dart'; |
| 17 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; | 15 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart'; |
| 18 import 'package:front_end/src/fasta/parser/identifier_context.dart' | 16 import 'package:front_end/src/fasta/parser/identifier_context.dart' |
| 19 show IdentifierContext; | 17 show IdentifierContext; |
| 20 import 'package:front_end/src/fasta/parser/parser.dart' as fasta; | 18 import 'package:front_end/src/fasta/parser/parser.dart' as fasta; |
| 21 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; | 19 import 'package:front_end/src/fasta/scanner/string_scanner.dart'; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 121 |
| 124 @override | 122 @override |
| 125 @failingTest | 123 @failingTest |
| 126 void test_logicalOrExpression_precedence_nullableType() { | 124 void test_logicalOrExpression_precedence_nullableType() { |
| 127 // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. | 125 // TODO(paulberry,ahe): Fasta doesn't support NNBD syntax yet. |
| 128 super.test_logicalOrExpression_precedence_nullableType(); | 126 super.test_logicalOrExpression_precedence_nullableType(); |
| 129 } | 127 } |
| 130 } | 128 } |
| 131 | 129 |
| 132 /** | 130 /** |
| 133 * Proxy implementation of [KernelClassElement] used by Fasta parser tests. | |
| 134 * | |
| 135 * All undeclared identifiers are presumed to resolve to an instance of this | |
| 136 * class. | |
| 137 */ | |
| 138 class ElementProxy implements KernelClassElement { | |
| 139 @override | |
| 140 final KernelInterfaceType rawType = new InterfaceTypeProxy(); | |
| 141 | |
| 142 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 143 } | |
| 144 | |
| 145 /** | |
| 146 * Proxy implementation of [KernelClassElement] used by Fasta parser tests. | |
| 147 * | |
| 148 * Any request for an element is satisfied by creating an instance of | |
| 149 * [ElementProxy]. | |
| 150 */ | |
| 151 class ElementStoreProxy implements ElementStore { | |
| 152 final _elements = <Builder, Element>{}; | |
| 153 | |
| 154 @override | |
| 155 Element operator [](Builder builder) => | |
| 156 _elements.putIfAbsent(builder, () => new ElementProxy()); | |
| 157 | |
| 158 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 159 } | |
| 160 | |
| 161 /** | |
| 162 * Tests of the fasta parser based on [ExpressionParserTestMixin]. | 131 * Tests of the fasta parser based on [ExpressionParserTestMixin]. |
| 163 */ | 132 */ |
| 164 @reflectiveTest | 133 @reflectiveTest |
| 165 class ExpressionParserTest_Fasta extends FastaParserTestCase | 134 class ExpressionParserTest_Fasta extends FastaParserTestCase |
| 166 with ExpressionParserTestMixin { | 135 with ExpressionParserTestMixin { |
| 167 @override | 136 @override |
| 168 @failingTest | 137 @failingTest |
| 169 void | 138 void |
| 170 test_parseAssignableExpression_expression_args_dot_typeArgumentComments()
{ | 139 test_parseAssignableExpression_expression_args_dot_typeArgumentComments()
{ |
| 171 super | 140 super |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 } | 734 } |
| 766 | 735 |
| 767 @override | 736 @override |
| 768 @failingTest | 737 @failingTest |
| 769 void test_parseNormalFormalParameter_simple_const_type() { | 738 void test_parseNormalFormalParameter_simple_const_type() { |
| 770 super.test_parseNormalFormalParameter_simple_const_type(); | 739 super.test_parseNormalFormalParameter_simple_const_type(); |
| 771 } | 740 } |
| 772 } | 741 } |
| 773 | 742 |
| 774 /** | 743 /** |
| 775 * Proxy implementation of [KernelClassElement] used by Fasta parser tests. | |
| 776 * | |
| 777 * Any element used as a type name is presumed to refer to an instance of this | |
| 778 * class. | |
| 779 */ | |
| 780 class InterfaceTypeProxy implements KernelInterfaceType { | |
| 781 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 782 } | |
| 783 | |
| 784 /** | |
| 785 * Proxy implementation of [KernelLibraryBuilderProxy] used by Fasta parser | 744 * Proxy implementation of [KernelLibraryBuilderProxy] used by Fasta parser |
| 786 * tests. | 745 * tests. |
| 787 */ | 746 */ |
| 788 class KernelLibraryBuilderProxy implements KernelLibraryBuilder { | 747 class KernelLibraryBuilderProxy implements KernelLibraryBuilder { |
| 789 @override | 748 @override |
| 790 final uri = Uri.parse('file:///test.dart'); | 749 final uri = Uri.parse('file:///test.dart'); |
| 791 | 750 |
| 792 @override | 751 @override |
| 793 Uri get fileUri => uri; | 752 Uri get fileUri => uri; |
| 794 | 753 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 final AstBuilder _astBuilder; | 785 final AstBuilder _astBuilder; |
| 827 | 786 |
| 828 /** | 787 /** |
| 829 * Creates a [ParserProxy] which is prepared to begin parsing at the given | 788 * Creates a [ParserProxy] which is prepared to begin parsing at the given |
| 830 * Fasta token. | 789 * Fasta token. |
| 831 */ | 790 */ |
| 832 factory ParserProxy(analyzer.Token startingToken, | 791 factory ParserProxy(analyzer.Token startingToken, |
| 833 {bool enableGenericMethodComments: false}) { | 792 {bool enableGenericMethodComments: false}) { |
| 834 var library = new KernelLibraryBuilderProxy(); | 793 var library = new KernelLibraryBuilderProxy(); |
| 835 var member = new BuilderProxy(); | 794 var member = new BuilderProxy(); |
| 836 var elementStore = new ElementStoreProxy(); | |
| 837 var scope = new ScopeProxy(); | 795 var scope = new ScopeProxy(); |
| 838 var astBuilder = | 796 var astBuilder = new AstBuilder(null, library, member, scope, true); |
| 839 new AstBuilder(null, library, member, elementStore, scope, true, false); | |
| 840 astBuilder.parseGenericMethodComments = enableGenericMethodComments; | 797 astBuilder.parseGenericMethodComments = enableGenericMethodComments; |
| 841 var fastaParser = new fasta.Parser(new ForwardingTestListener(astBuilder)); | 798 var fastaParser = new fasta.Parser(new ForwardingTestListener(astBuilder)); |
| 842 astBuilder.parser = fastaParser; | 799 astBuilder.parser = fastaParser; |
| 843 return new ParserProxy._(startingToken, fastaParser, astBuilder); | 800 return new ParserProxy._(startingToken, fastaParser, astBuilder); |
| 844 } | 801 } |
| 845 | 802 |
| 846 ParserProxy._(this._currentFastaToken, this._fastaParser, this._astBuilder); | 803 ParserProxy._(this._currentFastaToken, this._fastaParser, this._astBuilder); |
| 847 | 804 |
| 848 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 805 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 849 | 806 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 } | 975 } |
| 1019 | 976 |
| 1020 @override | 977 @override |
| 1021 @failingTest | 978 @failingTest |
| 1022 void test_parsePartOfDirective_uri() { | 979 void test_parsePartOfDirective_uri() { |
| 1023 // TODO(paulberry,ahe): URIs in "part of" declarations are not supported by | 980 // TODO(paulberry,ahe): URIs in "part of" declarations are not supported by |
| 1024 // Fasta. | 981 // Fasta. |
| 1025 super.test_parsePartOfDirective_uri(); | 982 super.test_parsePartOfDirective_uri(); |
| 1026 } | 983 } |
| 1027 } | 984 } |
| OLD | NEW |