| 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 2597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2608 const v = C; | 2608 const v = C; |
| 2609 '''); | 2609 '''); |
| 2610 _assertUnlinkedConst(variable.constExpr, operators: [ | 2610 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2611 UnlinkedConstOperation.pushReference | 2611 UnlinkedConstOperation.pushReference |
| 2612 ], referenceValidators: [ | 2612 ], referenceValidators: [ |
| 2613 (EntityRef r) => checkTypeRef(r, null, null, 'C', | 2613 (EntityRef r) => checkTypeRef(r, null, null, 'C', |
| 2614 expectedKind: ReferenceKind.classOrEnum) | 2614 expectedKind: ReferenceKind.classOrEnum) |
| 2615 ]); | 2615 ]); |
| 2616 } | 2616 } |
| 2617 | 2617 |
| 2618 test_constExpr_pushReference_enumValue() { |
| 2619 UnlinkedVariable variable = serializeVariableText(''' |
| 2620 enum C {V1, V2, V3} |
| 2621 const v = C.V1; |
| 2622 '''); |
| 2623 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2624 UnlinkedConstOperation.pushReference |
| 2625 ], referenceValidators: [ |
| 2626 (EntityRef r) => checkTypeRef(r, null, null, 'V1', |
| 2627 expectedKind: ReferenceKind.propertyAccessor, |
| 2628 prefixExpectations: [ |
| 2629 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2630 ]) |
| 2631 ]); |
| 2632 } |
| 2633 |
| 2634 test_constExpr_pushReference_enumValue_viaImport() { |
| 2635 addNamedSource( |
| 2636 '/a.dart', |
| 2637 ''' |
| 2638 enum C {V1, V2, V3} |
| 2639 '''); |
| 2640 UnlinkedVariable variable = serializeVariableText(''' |
| 2641 import 'a.dart'; |
| 2642 const v = C.V1; |
| 2643 '''); |
| 2644 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2645 UnlinkedConstOperation.pushReference |
| 2646 ], referenceValidators: [ |
| 2647 (EntityRef r) => checkTypeRef(r, null, null, 'V1', |
| 2648 expectedKind: ReferenceKind.propertyAccessor, |
| 2649 prefixExpectations: [ |
| 2650 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2651 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
| 2652 ]) |
| 2653 ]); |
| 2654 } |
| 2655 |
| 2656 test_constExpr_pushReference_enumValues() { |
| 2657 UnlinkedVariable variable = serializeVariableText(''' |
| 2658 enum C {V1, V2, V3} |
| 2659 const v = C.values; |
| 2660 '''); |
| 2661 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2662 UnlinkedConstOperation.pushReference |
| 2663 ], referenceValidators: [ |
| 2664 (EntityRef r) => checkTypeRef(r, null, null, 'values', |
| 2665 expectedKind: ReferenceKind.propertyAccessor, |
| 2666 prefixExpectations: [ |
| 2667 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C') |
| 2668 ]) |
| 2669 ]); |
| 2670 } |
| 2671 |
| 2672 test_constExpr_pushReference_enumValues_viaImport() { |
| 2673 addNamedSource( |
| 2674 '/a.dart', |
| 2675 ''' |
| 2676 enum C {V1, V2, V3} |
| 2677 '''); |
| 2678 UnlinkedVariable variable = serializeVariableText(''' |
| 2679 import 'a.dart'; |
| 2680 const v = C.values; |
| 2681 '''); |
| 2682 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2683 UnlinkedConstOperation.pushReference |
| 2684 ], referenceValidators: [ |
| 2685 (EntityRef r) => checkTypeRef(r, null, null, 'values', |
| 2686 expectedKind: ReferenceKind.propertyAccessor, |
| 2687 prefixExpectations: [ |
| 2688 new _PrefixExpectation(ReferenceKind.classOrEnum, 'C', |
| 2689 absoluteUri: absUri('/a.dart'), relativeUri: 'a.dart') |
| 2690 ]) |
| 2691 ]); |
| 2692 } |
| 2693 |
| 2618 test_constExpr_pushReference_field() { | 2694 test_constExpr_pushReference_field() { |
| 2619 UnlinkedVariable variable = serializeVariableText(''' | 2695 UnlinkedVariable variable = serializeVariableText(''' |
| 2620 class C { | 2696 class C { |
| 2621 static const int F = 1; | 2697 static const int F = 1; |
| 2622 } | 2698 } |
| 2623 const v = C.F; | 2699 const v = C.F; |
| 2624 '''); | 2700 '''); |
| 2625 _assertUnlinkedConst(variable.constExpr, operators: [ | 2701 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 2626 UnlinkedConstOperation.pushReference | 2702 UnlinkedConstOperation.pushReference |
| 2627 ], referenceValidators: [ | 2703 ], referenceValidators: [ |
| (...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4028 expect(e.nameOffset, text.indexOf('E')); | 4104 expect(e.nameOffset, text.indexOf('E')); |
| 4029 expect(e.values, hasLength(1)); | 4105 expect(e.values, hasLength(1)); |
| 4030 expect(e.values[0].name, 'v1'); | 4106 expect(e.values[0].name, 'v1'); |
| 4031 expect(e.values[0].nameOffset, text.indexOf('v1')); | 4107 expect(e.values[0].nameOffset, text.indexOf('v1')); |
| 4032 _assertCodeRange(e.codeRange, 0, 13); | 4108 _assertCodeRange(e.codeRange, 0, 13); |
| 4033 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); | 4109 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 4034 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 4110 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 4035 ReferenceKind.classOrEnum); | 4111 ReferenceKind.classOrEnum); |
| 4036 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E'); | 4112 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'E'); |
| 4037 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); | 4113 expect(unlinkedUnits[0].publicNamespace.names[0].numTypeParameters, 0); |
| 4114 expect(unlinkedUnits[0].publicNamespace.names[0].members, hasLength(2)); |
| 4115 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].kind, |
| 4116 ReferenceKind.propertyAccessor); |
| 4117 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].name, 'values'); |
| 4118 expect( |
| 4119 unlinkedUnits[0].publicNamespace.names[0].members[0].numTypeParameters, |
| 4120 0); |
| 4121 expect(unlinkedUnits[0].publicNamespace.names[0].members[1].kind, |
| 4122 ReferenceKind.propertyAccessor); |
| 4123 expect(unlinkedUnits[0].publicNamespace.names[0].members[1].name, 'v1'); |
| 4124 expect( |
| 4125 unlinkedUnits[0].publicNamespace.names[0].members[1].numTypeParameters, |
| 4126 0); |
| 4038 } | 4127 } |
| 4039 | 4128 |
| 4040 test_enum_documented() { | 4129 test_enum_documented() { |
| 4041 String text = ''' | 4130 String text = ''' |
| 4042 // Extra comment so doc comment offset != 0 | 4131 // Extra comment so doc comment offset != 0 |
| 4043 /** | 4132 /** |
| 4044 * Docs | 4133 * Docs |
| 4045 */ | 4134 */ |
| 4046 enum E { v }'''; | 4135 enum E { v }'''; |
| 4047 UnlinkedEnum enm = serializeEnumText(text); | 4136 UnlinkedEnum enm = serializeEnumText(text); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4067 /** | 4156 /** |
| 4068 * Docs | 4157 * Docs |
| 4069 */ | 4158 */ |
| 4070 v | 4159 v |
| 4071 }'''; | 4160 }'''; |
| 4072 UnlinkedEnumValue value = serializeEnumText(text).values[0]; | 4161 UnlinkedEnumValue value = serializeEnumText(text).values[0]; |
| 4073 expect(value.documentationComment, isNotNull); | 4162 expect(value.documentationComment, isNotNull); |
| 4074 checkDocumentationComment(value.documentationComment, text); | 4163 checkDocumentationComment(value.documentationComment, text); |
| 4075 } | 4164 } |
| 4076 | 4165 |
| 4166 test_enum_value_private() { |
| 4167 serializeEnumText('enum E { _v }', 'E'); |
| 4168 expect(unlinkedUnits[0].publicNamespace.names, hasLength(1)); |
| 4169 expect(unlinkedUnits[0].publicNamespace.names[0].members, hasLength(1)); |
| 4170 expect(unlinkedUnits[0].publicNamespace.names[0].members[0].name, 'values'); |
| 4171 } |
| 4172 |
| 4077 test_executable_abstract() { | 4173 test_executable_abstract() { |
| 4078 UnlinkedExecutable executable = | 4174 UnlinkedExecutable executable = |
| 4079 serializeClassText('abstract class C { f(); }').executables[0]; | 4175 serializeClassText('abstract class C { f(); }').executables[0]; |
| 4080 expect(executable.isAbstract, isTrue); | 4176 expect(executable.isAbstract, isTrue); |
| 4081 } | 4177 } |
| 4082 | 4178 |
| 4083 test_executable_concrete() { | 4179 test_executable_concrete() { |
| 4084 UnlinkedExecutable executable = | 4180 UnlinkedExecutable executable = |
| 4085 serializeClassText('abstract class C { f() {} }').executables[0]; | 4181 serializeClassText('abstract class C { f() {} }').executables[0]; |
| 4086 expect(executable.isAbstract, isFalse); | 4182 expect(executable.isAbstract, isFalse); |
| (...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7552 class _PrefixExpectation { | 7648 class _PrefixExpectation { |
| 7553 final ReferenceKind kind; | 7649 final ReferenceKind kind; |
| 7554 final String name; | 7650 final String name; |
| 7555 final String absoluteUri; | 7651 final String absoluteUri; |
| 7556 final String relativeUri; | 7652 final String relativeUri; |
| 7557 final int numTypeParameters; | 7653 final int numTypeParameters; |
| 7558 | 7654 |
| 7559 _PrefixExpectation(this.kind, this.name, | 7655 _PrefixExpectation(this.kind, this.name, |
| 7560 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); | 7656 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); |
| 7561 } | 7657 } |
| OLD | NEW |