| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| (...skipping 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2812 UnlinkedConstOperation.pushReference | 2812 UnlinkedConstOperation.pushReference |
| 2813 ], referenceValidators: [ | 2813 ], referenceValidators: [ |
| 2814 (EntityRef r) => checkTypeRef(r, null, null, 'b', | 2814 (EntityRef r) => checkTypeRef(r, null, null, 'b', |
| 2815 expectedKind: ReferenceKind.propertyAccessor, | 2815 expectedKind: ReferenceKind.propertyAccessor, |
| 2816 prefixExpectations: [ | 2816 prefixExpectations: [ |
| 2817 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') | 2817 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2818 ]) | 2818 ]) |
| 2819 ]); | 2819 ]); |
| 2820 } | 2820 } |
| 2821 | 2821 |
| 2822 test_constExpr_pushReference_staticGetter() { |
| 2823 UnlinkedVariable variable = serializeVariableText(''' |
| 2824 class C { |
| 2825 static int get x => null; |
| 2826 } |
| 2827 const v = C.x; |
| 2828 '''); |
| 2829 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2830 UnlinkedConstOperation.pushReference |
| 2831 ], referenceValidators: [ |
| 2832 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
| 2833 expectedKind: ReferenceKind.propertyAccessor, |
| 2834 prefixExpectations: [ |
| 2835 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2836 ]) |
| 2837 ]); |
| 2838 } |
| 2839 |
| 2840 test_constExpr_pushReference_staticGetter_imported() { |
| 2841 addNamedSource( |
| 2842 '/a.dart', |
| 2843 ''' |
| 2844 class C { |
| 2845 static int get x => null; |
| 2846 } |
| 2847 '''); |
| 2848 UnlinkedVariable variable = serializeVariableText(''' |
| 2849 import 'a.dart'; |
| 2850 const v = C.x; |
| 2851 '''); |
| 2852 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2853 UnlinkedConstOperation.pushReference |
| 2854 ], referenceValidators: [ |
| 2855 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
| 2856 expectedKind: ReferenceKind.propertyAccessor, |
| 2857 prefixExpectations: [ |
| 2858 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2859 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
| 2860 ]) |
| 2861 ]); |
| 2862 } |
| 2863 |
| 2864 test_constExpr_pushReference_staticGetter_imported_withPrefix() { |
| 2865 addNamedSource( |
| 2866 '/a.dart', |
| 2867 ''' |
| 2868 class C { |
| 2869 static int get x => null; |
| 2870 } |
| 2871 '''); |
| 2872 UnlinkedVariable variable = serializeVariableText(''' |
| 2873 import 'a.dart' as p; |
| 2874 const v = p.C.x; |
| 2875 '''); |
| 2876 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2877 UnlinkedConstOperation.pushReference |
| 2878 ], referenceValidators: [ |
| 2879 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
| 2880 expectedKind: ReferenceKind.propertyAccessor, |
| 2881 prefixExpectations: [ |
| 2882 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2883 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart'), |
| 2884 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2885 ]) |
| 2886 ]); |
| 2887 } |
| 2888 |
| 2822 test_constExpr_pushReference_staticMethod() { | 2889 test_constExpr_pushReference_staticMethod() { |
| 2823 UnlinkedVariable variable = serializeVariableText(''' | 2890 UnlinkedVariable variable = serializeVariableText(''' |
| 2824 class C { | 2891 class C { |
| 2825 static m() {} | 2892 static m() {} |
| 2826 } | 2893 } |
| 2827 const v = C.m; | 2894 const v = C.m; |
| 2828 '''); | 2895 '''); |
| 2829 _assertUnlinkedConst(variable.constExpr, operators: [ | 2896 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2830 UnlinkedConstOperation.pushReference | 2897 UnlinkedConstOperation.pushReference |
| 2831 ], referenceValidators: [ | 2898 ], referenceValidators: [ |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2949 UnlinkedConstOperation.pushReference | 3016 UnlinkedConstOperation.pushReference |
| 2950 ], referenceValidators: [ | 3017 ], referenceValidators: [ |
| 2951 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', | 3018 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'f', |
| 2952 expectedKind: ReferenceKind.topLevelFunction, | 3019 expectedKind: ReferenceKind.topLevelFunction, |
| 2953 prefixExpectations: [ | 3020 prefixExpectations: [ |
| 2954 new _PrefixExpectation(ReferenceKind.prefix, 'p') | 3021 new _PrefixExpectation(ReferenceKind.prefix, 'p') |
| 2955 ]) | 3022 ]) |
| 2956 ]); | 3023 ]); |
| 2957 } | 3024 } |
| 2958 | 3025 |
| 3026 test_constExpr_pushReference_topLevelGetter() { |
| 3027 UnlinkedVariable variable = serializeVariableText(''' |
| 3028 int get x => null; |
| 3029 const v = x; |
| 3030 '''); |
| 3031 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 3032 UnlinkedConstOperation.pushReference |
| 3033 ], referenceValidators: [ |
| 3034 (EntityRef r) => checkTypeRef(r, null, null, 'x', |
| 3035 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 3036 ]); |
| 3037 } |
| 3038 |
| 3039 test_constExpr_pushReference_topLevelGetter_imported() { |
| 3040 addNamedSource('/a.dart', 'int get x => null;'); |
| 3041 UnlinkedVariable variable = serializeVariableText(''' |
| 3042 import 'a.dart'; |
| 3043 const v = x; |
| 3044 '''); |
| 3045 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 3046 UnlinkedConstOperation.pushReference |
| 3047 ], referenceValidators: [ |
| 3048 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', |
| 3049 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| 3050 ]); |
| 3051 } |
| 3052 |
| 3053 test_constExpr_pushReference_topLevelGetter_imported_withPrefix() { |
| 3054 addNamedSource('/a.dart', 'int get x => null;'); |
| 3055 UnlinkedVariable variable = serializeVariableText(''' |
| 3056 import 'a.dart' as p; |
| 3057 const v = p.x; |
| 3058 '''); |
| 3059 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 3060 UnlinkedConstOperation.pushReference |
| 3061 ], referenceValidators: [ |
| 3062 (EntityRef r) => checkTypeRef(r, absUri('/a.dart'), 'a.dart', 'x', |
| 3063 expectedKind: ReferenceKind.topLevelPropertyAccessor, |
| 3064 expectedPrefix: 'p') |
| 3065 ]); |
| 3066 } |
| 3067 |
| 2959 test_constExpr_pushReference_topLevelVariable() { | 3068 test_constExpr_pushReference_topLevelVariable() { |
| 2960 UnlinkedVariable variable = serializeVariableText(''' | 3069 UnlinkedVariable variable = serializeVariableText(''' |
| 2961 const int a = 1; | 3070 const int a = 1; |
| 2962 const v = a; | 3071 const v = a; |
| 2963 '''); | 3072 '''); |
| 2964 _assertUnlinkedConst(variable.constExpr, operators: [ | 3073 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2965 UnlinkedConstOperation.pushReference | 3074 UnlinkedConstOperation.pushReference |
| 2966 ], referenceValidators: [ | 3075 ], referenceValidators: [ |
| 2967 (EntityRef r) => checkTypeRef(r, null, null, 'a', | 3076 (EntityRef r) => checkTypeRef(r, null, null, 'a', |
| 2968 expectedKind: ReferenceKind.topLevelPropertyAccessor) | 3077 expectedKind: ReferenceKind.topLevelPropertyAccessor) |
| (...skipping 2306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5275 | 5384 |
| 5276 test_executable_member_getter() { | 5385 test_executable_member_getter() { |
| 5277 UnlinkedClass cls = serializeClassText('class C { int get f => 1; }'); | 5386 UnlinkedClass cls = serializeClassText('class C { int get f => 1; }'); |
| 5278 UnlinkedExecutable executable = | 5387 UnlinkedExecutable executable = |
| 5279 findExecutable('f', executables: cls.executables, failIfAbsent: true); | 5388 findExecutable('f', executables: cls.executables, failIfAbsent: true); |
| 5280 expect(executable.kind, UnlinkedExecutableKind.getter); | 5389 expect(executable.kind, UnlinkedExecutableKind.getter); |
| 5281 expect(executable.returnType, isNotNull); | 5390 expect(executable.returnType, isNotNull); |
| 5282 expect(executable.isAsynchronous, isFalse); | 5391 expect(executable.isAsynchronous, isFalse); |
| 5283 expect(executable.isExternal, isFalse); | 5392 expect(executable.isExternal, isFalse); |
| 5284 expect(executable.isGenerator, isFalse); | 5393 expect(executable.isGenerator, isFalse); |
| 5394 expect(executable.isStatic, isFalse); |
| 5285 _assertCodeRange(executable.codeRange, 10, 15); | 5395 _assertCodeRange(executable.codeRange, 10, 15); |
| 5286 expect(findVariable('f', variables: cls.fields), isNull); | 5396 expect(findVariable('f', variables: cls.fields), isNull); |
| 5287 expect(findExecutable('f=', executables: cls.executables), isNull); | 5397 expect(findExecutable('f=', executables: cls.executables), isNull); |
| 5398 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 5399 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); |
| 5400 expect(unlinkedUnits[0].publicNamespace.names[0].members, isEmpty); |
| 5288 } | 5401 } |
| 5289 | 5402 |
| 5290 test_executable_member_getter_external() { | 5403 test_executable_member_getter_external() { |
| 5291 UnlinkedClass cls = serializeClassText('class C { external int get f; }'); | 5404 UnlinkedClass cls = serializeClassText('class C { external int get f; }'); |
| 5292 UnlinkedExecutable executable = | 5405 UnlinkedExecutable executable = |
| 5293 findExecutable('f', executables: cls.executables, failIfAbsent: true); | 5406 findExecutable('f', executables: cls.executables, failIfAbsent: true); |
| 5294 expect(executable.isExternal, isTrue); | 5407 expect(executable.isExternal, isTrue); |
| 5295 } | 5408 } |
| 5296 | 5409 |
| 5410 test_executable_member_getter_static() { |
| 5411 UnlinkedClass cls = |
| 5412 serializeClassText('class C { static int get f => 1; }'); |
| 5413 UnlinkedExecutable executable = |
| 5414 findExecutable('f', executables: cls.executables, failIfAbsent: true); |
| 5415 expect(executable.isStatic, isTrue); |
| 5416 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 5417 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'C'); |
| 5418 expect(unlinkedUnits[0].publicNamespace.names[0].members, hasLength(1)); |
| 5419 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].name, 'f'); |
| 5420 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].kind, |
| 5421 ReferenceKind.propertyAccessor); |
| 5422 expect( |
| 5423 unlinkedUnits[0].publicNamespace.names[0].members[0].numTypeParameters, |
| 5424 0); |
| 5425 expect( |
| 5426 unlinkedUnits[0].publicNamespace.names[0].members[0].members, isEmpty); |
| 5427 } |
| 5428 |
| 5297 test_executable_member_setter() { | 5429 test_executable_member_setter() { |
| 5298 UnlinkedClass cls = serializeClassText('class C { void set f(value) {} }'); | 5430 UnlinkedClass cls = serializeClassText('class C { void set f(value) {} }'); |
| 5299 UnlinkedExecutable executable = | 5431 UnlinkedExecutable executable = |
| 5300 findExecutable('f=', executables: cls.executables, failIfAbsent: true); | 5432 findExecutable('f=', executables: cls.executables, failIfAbsent: true); |
| 5301 expect(executable.kind, UnlinkedExecutableKind.setter); | 5433 expect(executable.kind, UnlinkedExecutableKind.setter); |
| 5302 expect(executable.returnType, isNotNull); | 5434 expect(executable.returnType, isNotNull); |
| 5303 expect(executable.isAsynchronous, isFalse); | 5435 expect(executable.isAsynchronous, isFalse); |
| 5304 expect(executable.isExternal, isFalse); | 5436 expect(executable.isExternal, isFalse); |
| 5305 expect(executable.isGenerator, isFalse); | 5437 expect(executable.isGenerator, isFalse); |
| 5306 _assertCodeRange(executable.codeRange, 10, 20); | 5438 _assertCodeRange(executable.codeRange, 10, 20); |
| (...skipping 4296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9603 class _PrefixExpectation { | 9735 class _PrefixExpectation { |
| 9604 final ReferenceKind kind; | 9736 final ReferenceKind kind; |
| 9605 final String name; | 9737 final String name; |
| 9606 final String absoluteUri; | 9738 final String absoluteUri; |
| 9607 final String relativeUri; | 9739 final String relativeUri; |
| 9608 final int numTypeParameters; | 9740 final int numTypeParameters; |
| 9609 | 9741 |
| 9610 _PrefixExpectation(this.kind, this.name, | 9742 _PrefixExpectation(this.kind, this.name, |
| 9611 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 9743 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 9612 } | 9744 } |
| OLD | NEW |