Skip to content

Commit 7784976

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate scope_util_test
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I3a1a0229b59a7b9f83011d0acd6fd6d56415c5ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394840 Auto-Submit: Phil Quitslund <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent e3987ed commit 7784976

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

pkg/linter/analyzer_use_new_elements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,5 @@ lib/src/rules/use_build_context_synchronously.dart
1414
lib/src/rules/use_late_for_private_fields_and_variables.dart
1515
lib/src/util/dart_type_utilities.dart
1616
lib/src/util/flutter_utils.dart
17-
lib/src/util/leak_detector_visitor.dart
1817
lib/src/util/scope.dart
1918
test/rules/use_build_context_synchronously_test.dart
20-
test/scope_util_test.dart

pkg/linter/test/scope_util_test.dart

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
import 'package:analyzer/dart/analysis/results.dart';
99
import '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';
1211
import 'package:analyzer/src/test_utilities/find_element2.dart';
1312
import 'package:analyzer/src/test_utilities/find_node.dart';
1413
import 'package:linter/src/util/scope.dart';
@@ -25,18 +24,15 @@ main() {
2524

2625
@reflectiveTest
2726
class 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
644640
void 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) {}
779775
void 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

Comments
 (0)