Index: pkg/analysis_server/lib/src/services/refactoring/extract_method.dart |
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart |
index 107abf3d74f6ee955c2be1ef2056439a7fdeeb20..366f282a8aab0b8c235cc797722e7b8dba79fe3c 100644 |
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart |
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_method.dart |
@@ -21,6 +21,7 @@ import 'package:analysis_server/src/services/refactoring/rename_unit_member.dart |
import 'package:analysis_server/src/services/search/element_visitors.dart'; |
import 'package:analysis_server/src/services/search/search_engine.dart'; |
import 'package:analyzer/dart/ast/ast.dart'; |
+import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
import 'package:analyzer/dart/ast/token.dart'; |
import 'package:analyzer/dart/ast/visitor.dart'; |
import 'package:analyzer/dart/element/element.dart'; |
@@ -411,7 +412,8 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl |
AstNode parent = _parentMember.parent; |
// top-level function |
if (parent is CompilationUnit) { |
- LibraryElement libraryElement = parent.element.library; |
+ LibraryElement libraryElement = |
+ resolutionMap.elementForCompilationUnit(parent).library; |
return validateCreateFunction(searchEngine, libraryElement, name); |
} |
// method of class |