55import 'package:analysis_server/src/services/correction/fix.dart' ;
66import 'package:analysis_server_plugin/edit/dart/correction_producer.dart' ;
77import 'package:analyzer/dart/ast/ast.dart' ;
8- import 'package:analyzer/dart/element/element .dart' ;
8+ import 'package:analyzer/dart/element/element2 .dart' ;
99import 'package:analyzer/file_system/file_system.dart' ;
1010import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart' ;
1111import 'package:analyzer_plugin/utilities/fixes/fixes.dart' ;
@@ -29,12 +29,12 @@ class CreateMixin extends ResolvedCorrectionProducer {
2929
3030 @override
3131 Future <void > compute (ChangeBuilder builder) async {
32- Element ? prefixElement;
32+ Element2 ? prefixElement;
3333 var node = this .node;
3434 if (node is NamedType ) {
3535 var importPrefix = node.importPrefix;
3636 if (importPrefix != null ) {
37- prefixElement = importPrefix.element ;
37+ prefixElement = importPrefix.element2 ;
3838 if (prefixElement == null ) {
3939 return ;
4040 }
@@ -57,7 +57,7 @@ class CreateMixin extends ResolvedCorrectionProducer {
5757 if (node.parent is InstanceCreationExpression ) {
5858 return ;
5959 }
60- prefixElement = node.prefix.staticElement ;
60+ prefixElement = node.prefix.element ;
6161 if (prefixElement == null ) {
6262 return ;
6363 }
@@ -66,13 +66,13 @@ class CreateMixin extends ResolvedCorrectionProducer {
6666 return ;
6767 }
6868 // prepare environment
69- Element targetUnit;
69+ LibraryFragment targetUnit;
7070 var prefix = '' ;
7171 var suffix = '' ;
7272 var offset = - 1 ;
7373 String ? filePath;
7474 if (prefixElement == null ) {
75- targetUnit = unit.declaredElement ! ;
75+ targetUnit = unit.declaredFragment ! ;
7676 var enclosingMember = node.thisOrAncestorMatching ((node) =>
7777 node is CompilationUnitMember && node.parent is CompilationUnit );
7878 if (enclosingMember == null ) {
@@ -82,19 +82,16 @@ class CreateMixin extends ResolvedCorrectionProducer {
8282 filePath = file;
8383 prefix = '$eol $eol ' ;
8484 } else {
85- for (var import
86- in libraryElement.definingCompilationUnit.libraryImports) {
87- if (prefixElement is PrefixElement &&
88- import.prefix? .element == prefixElement) {
89- var library = import.importedLibrary;
85+ for (var import in libraryElement2.firstFragment.libraryImports2) {
86+ if (prefixElement is PrefixElement2 &&
87+ import.prefix2? .element == prefixElement) {
88+ var library = import.importedLibrary2;
9089 if (library != null ) {
91- targetUnit = library.definingCompilationUnit ;
90+ targetUnit = library.firstFragment ;
9291 var targetSource = targetUnit.source;
9392 try {
94- if (targetSource != null ) {
95- offset = targetSource.contents.data.length;
96- filePath = targetSource.fullName;
97- }
93+ offset = targetSource.contents.data.length;
94+ filePath = targetSource.fullName;
9895 prefix = eol;
9996 suffix = eol;
10097 } on FileSystemException {
0 commit comments