@@ -16,7 +16,6 @@ import 'package:analyzer/source/source_range.dart';
1616import 'package:analyzer/src/dart/analysis/driver.dart' ;
1717import 'package:analyzer/src/dart/analysis/search.dart' ;
1818import 'package:analyzer/src/dart/ast/ast.dart' ;
19- import 'package:analyzer/src/utilities/extensions/element.dart' ;
2019import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart' ;
2120import 'package:analyzer_plugin/utilities/range_factory.dart' ;
2221import 'package:path/path.dart' as path show posix, Context;
@@ -204,8 +203,8 @@ class MoveFileRefactoringImpl extends RefactoringImpl
204203 return ;
205204 }
206205
207- var element = resolvedUnit.unit.declaredElement ;
208- if (element == null ) {
206+ var libraryFragment = resolvedUnit.unit.declaredFragment ;
207+ if (libraryFragment == null ) {
209208 return ;
210209 }
211210
@@ -224,12 +223,12 @@ class MoveFileRefactoringImpl extends RefactoringImpl
224223 ));
225224 }
226225
227- var libraryElement = element.library ;
226+ var libraryElement = libraryFragment.element ;
228227
229228 // If this element is a library, handle inbound 'part of' directives which
230229 // are not included in `searchEngine.searchReferences` below.
231- if (element == libraryElement.definingCompilationUnit ) {
232- var libraryResult = await _session.getResolvedLibraryByElement (
230+ if (libraryFragment == libraryElement.firstFragment ) {
231+ var libraryResult = await _session.getResolvedLibraryByElement2 (
233232 libraryElement,
234233 );
235234 if (libraryResult is ! ResolvedLibraryResult ) {
@@ -247,7 +246,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
247246 for (var uriString in partOfs) {
248247 recordReference (
249248 range: range.node (uriString),
250- sourceFile: result.unit.declaredElement ! .source.fullName,
249+ sourceFile: result.unit.declaredFragment ! .source.fullName,
251250 targetFile: oldPath,
252251 quotedUriValue: uriString.literal.lexeme,
253252 );
@@ -271,7 +270,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
271270 if (uriValue == null ) continue ;
272271 recordReference (
273272 range: range.node (uriString),
274- sourceFile: element .source.fullName,
273+ sourceFile: libraryFragment .source.fullName,
275274 targetFile: pathContext.normalize (
276275 pathContext.join (oldDir, _uriToPath (uriValue)),
277276 ),
@@ -283,7 +282,7 @@ class MoveFileRefactoringImpl extends RefactoringImpl
283282
284283 // Finally, locate all other incoming references to this file.
285284 var references = await refactoringWorkspace.searchEngine
286- .searchLibraryFragmentReferences (element.asElement2 );
285+ .searchLibraryFragmentReferences (libraryFragment );
287286 for (var reference in references) {
288287 recordReference (
289288 range: reference.range,
0 commit comments