77
88import 'package:analyzer/dart/analysis/results.dart' ;
99import 'package:analyzer/dart/ast/ast.dart' ;
10- import 'package:analyzer/dart/element/element.dart' ;
11- import 'package:analyzer/src/test_utilities/find_element.dart' ;
10+ import 'package:analyzer/dart/element/element2.dart' ;
1211import 'package:analyzer/src/test_utilities/find_element2.dart' ;
1312import 'package:analyzer/src/test_utilities/find_node.dart' ;
1413import 'package:linter/src/util/scope.dart' ;
@@ -25,18 +24,15 @@ main() {
2524
2625@reflectiveTest
2726class ResolveNameInScopeTest extends PubPackageResolutionTest {
28- late FindElement findElement;
29-
30- late FindElement2 findElement2;
27+ late FindElement2 findElement;
3128
3229 late FindNode findNode;
3330
3431 @override
3532 Future <ResolvedUnitResult > resolveFile (String path) async {
3633 var result = await super .resolveFile (path);
3734
38- findElement = FindElement (result.unit);
39- findElement2 = FindElement2 (result.unit);
35+ findElement = FindElement2 (result.unit);
4036 findNode = FindNode (result.content, result.unit);
4137 return result;
4238 }
@@ -55,7 +51,7 @@ class B extends A {
5551 }
5652}
5753''' );
58- _checkGetterDifferent (findElement.setter ('foo' ));
54+ _checkGetterDifferent (findElement.setter ('foo= ' ));
5955 }
6056
6157 test_class_getter_different_importScope () async {
@@ -628,7 +624,7 @@ class A {
628624 }
629625}
630626''' );
631- _checkSetterRequested (findElement.setter ('foo' ));
627+ _checkSetterRequested (findElement.setter ('foo= ' ));
632628 }
633629
634630 test_class_setter_requested_thisClass_topLevelFunction () async {
@@ -643,7 +639,7 @@ class A {
643639
644640void foo() {}
645641''' );
646- _checkSetterRequested (findElement.setter ('foo' ));
642+ _checkSetterRequested (findElement.setter ('foo= ' ));
647643 }
648644
649645 test_class_typeParameter_inConstructor () async {
@@ -779,8 +775,8 @@ void foo<T>(int T) {}
779775void foo(void Function<T>(String T) b) {}
780776''' );
781777 var node = findNode.simpleFormalParameter ('T)' );
782- var T = findNode.typeParameter ('T>' ).declaredElement ! ;
783- _resultRequested (node, 'T' , false , T );
778+ var T = findNode.typeParameter ('T>' ).declaredFragment ? .element ;
779+ _resultRequested (node, 'T' , false , T ! );
784780 }
785781
786782 test_genericTypeAlias_typeParameter () async {
@@ -837,7 +833,7 @@ mixin A<T> {
837833 _resultRequested (node, 'T' , false , findElement.typeParameter ('T' ));
838834 }
839835
840- void _checkGetterDifferent (Element expected) {
836+ void _checkGetterDifferent (Element2 expected) {
841837 var node = findNode.this_ ('this.foo;' );
842838 _resultDifferent (node, 'foo' , false , expected);
843839 }
@@ -847,12 +843,12 @@ mixin A<T> {
847843 _resultNone (node, 'foo' , false );
848844 }
849845
850- void _checkGetterRequested (Element expected) {
846+ void _checkGetterRequested (Element2 expected) {
851847 var node = findNode.this_ ('this.foo;' );
852848 _resultRequested (node, 'foo' , false , expected);
853849 }
854850
855- void _checkMethodDifferent (Element expected) {
851+ void _checkMethodDifferent (Element2 expected) {
856852 var node = findNode.this_ ('this.foo()' );
857853 _resultDifferent (node, 'foo' , false , expected);
858854 }
@@ -862,7 +858,7 @@ mixin A<T> {
862858 _resultNone (node, 'foo' , false );
863859 }
864860
865- void _checkMethodRequested (Element expected) {
861+ void _checkMethodRequested (Element2 expected) {
866862 var node = findNode.this_ ('this.foo()' );
867863 _resultRequested (node, 'foo' , false , expected);
868864 }
@@ -871,7 +867,7 @@ mixin A<T> {
871867 _checkMethodRequested (findElement.localVar ('foo' ));
872868 }
873869
874- void _checkSetterDifferent (Element expected) {
870+ void _checkSetterDifferent (Element2 expected) {
875871 var node = findNode.this_ ('this.foo = 0;' );
876872 _resultDifferent (node, 'foo' , true , expected);
877873 }
@@ -881,14 +877,15 @@ mixin A<T> {
881877 _resultNone (node, 'foo' , true );
882878 }
883879
884- void _checkSetterRequested (Element expected) {
880+ void _checkSetterRequested (Element2 expected) {
885881 var node = findNode.this_ ('this.foo = 0;' );
886882 _resultRequested (node, 'foo' , true , expected);
887883 }
888884
889- void _resultDifferent (AstNode node, String id, bool setter, Element element) {
885+ void _resultDifferent (
886+ AstNode node, String id, bool setter, Element2 element) {
890887 var result = resolveNameInScope (id, node, shouldResolveSetter: setter);
891- if (! result.isDifferentName || result.element != element) {
888+ if (! result.isDifferentName || result.element2 != element) {
892889 fail ('Expected different $element , actual: $result ' );
893890 }
894891 }
@@ -900,9 +897,10 @@ mixin A<T> {
900897 }
901898 }
902899
903- void _resultRequested (AstNode node, String id, bool setter, Element element) {
900+ void _resultRequested (
901+ AstNode node, String id, bool setter, Element2 element) {
904902 var result = resolveNameInScope (id, node, shouldResolveSetter: setter);
905- if (! result.isRequestedName || result.element != element) {
903+ if (! result.isRequestedName || result.element2 != element) {
906904 fail ('Expected requested $element , actual: $result ' );
907905 }
908906 }
0 commit comments