@@ -24,34 +24,37 @@ class ErrorReporterTest extends PubPackageResolutionTest {
2424
2525 test_atElement_named () async {
2626 await resolveTestCode ('class A {}' );
27- var element = findElement.class_ ('A' );
28- var reporter = ErrorReporter (listener, element.source);
29- reporter.atElement (
27+ var element = findElement2.class_ ('A' );
28+ var firstFragment = element.firstFragment;
29+ var reporter =
30+ ErrorReporter (listener, firstFragment.libraryFragment.source);
31+ reporter.atElement2 (
3032 element,
3133 CompileTimeErrorCode .CAST_TO_NON_TYPE ,
3234 arguments: ['A' ],
3335 );
3436
3537 var error = listener.errors[0 ];
36- expect (error.offset, element.nameOffset );
38+ expect (error.offset, firstFragment.nameOffset2 );
3739 }
3840
3941 test_atElement_unnamed () async {
4042 await resolveTestCode (r'''
41- import 'dart:async';
42- import 'dart:math';
43+ extension on int {}
4344''' );
44- var element = findElement. import ( 'dart:math' );
45+ var element = findElement2. unnamedExtension ( );
4546
46- var reporter = ErrorReporter (listener, element.source);
47- reporter.atElement (
47+ var firstFragment = element.firstFragment;
48+ var reporter =
49+ ErrorReporter (listener, firstFragment.libraryFragment.source);
50+ reporter.atElement2 (
4851 element,
4952 CompileTimeErrorCode .CAST_TO_NON_TYPE ,
5053 arguments: ['A' ],
5154 );
5255
5356 var error = listener.errors[0 ];
54- expect (error.offset, element.nameOffset );
57+ expect (error.offset, - 1 );
5558 }
5659
5760 test_atNode_types_differentNames () async {
@@ -65,8 +68,8 @@ main() {
6568 x;
6669}
6770''' );
68- var aImport = findElement .importFind ('package:test/a.dart' );
69- var bImport = findElement .importFind ('package:test/b.dart' );
71+ var aImport = findElement2 .importFind ('package:test/a.dart' );
72+ var bImport = findElement2 .importFind ('package:test/b.dart' );
7073
7174 var firstType = aImport.class_ ('A' ).instantiate (
7275 typeArguments: [],
@@ -77,7 +80,8 @@ main() {
7780 nullabilitySuffix: NullabilitySuffix .none,
7881 );
7982
80- var reporter = ErrorReporter (listener, firstType.element.source);
83+ var reporter = ErrorReporter (
84+ listener, firstType.element3.firstFragment.libraryFragment.source);
8185
8286 reporter.atNode (
8387 findNode.simple ('x' ),
@@ -100,8 +104,8 @@ main() {
100104 x;
101105}
102106''' );
103- var aImport = findElement .importFind ('package:test/a.dart' );
104- var bImport = findElement .importFind ('package:test/b.dart' );
107+ var aImport = findElement2 .importFind ('package:test/a.dart' );
108+ var bImport = findElement2 .importFind ('package:test/b.dart' );
105109
106110 var firstType = aImport.class_ ('A' ).instantiate (
107111 typeArguments: [],
@@ -112,7 +116,8 @@ main() {
112116 nullabilitySuffix: NullabilitySuffix .none,
113117 );
114118
115- var reporter = ErrorReporter (listener, firstType.element.source);
119+ var reporter = ErrorReporter (
120+ listener, firstType.element3.firstFragment.libraryFragment.source);
116121 reporter.atNode (
117122 findNode.simple ('x' ),
118123 CompileTimeErrorCode .ARGUMENT_TYPE_NOT_ASSIGNABLE ,
@@ -140,7 +145,7 @@ main() {
140145 var fa = findNode.topLevelVariableDeclaration ('fa' );
141146 var fb = findNode.topLevelVariableDeclaration ('fb' );
142147
143- var source = result.unit.declaredElement ! .source;
148+ var source = result.unit.declaredFragment ! .libraryFragment ! .source;
144149 var reporter = ErrorReporter (listener, source);
145150 reporter.atNode (
146151 findNode.simple ('x' ),
@@ -171,7 +176,7 @@ main() {
171176 var ba = findNode.topLevelVariableDeclaration ('ba' );
172177 var bb = findNode.topLevelVariableDeclaration ('bb' );
173178
174- var source = result.unit.declaredElement ! .source;
179+ var source = result.unit.declaredFragment ! .libraryFragment ! .source;
175180 var reporter = ErrorReporter (listener, source);
176181 reporter.atNode (
177182 findNode.simple ('x' ),
0 commit comments