Skip to content

Commit efa95a8

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate CreateMixin.
Change-Id: Ife4570d0851e374e3c0e178c0a355f6ead2679c6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389263 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 74804fd commit efa95a8

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ lib/src/services/correction/dart/create_getter.dart
306306
lib/src/services/correction/dart/create_local_variable.dart
307307
lib/src/services/correction/dart/create_method.dart
308308
lib/src/services/correction/dart/create_method_or_function.dart
309+
lib/src/services/correction/dart/create_mixin.dart
309310
lib/src/services/correction/dart/create_no_such_method.dart
310311
lib/src/services/correction/dart/create_parameter.dart
311312
lib/src/services/correction/dart/create_setter.dart

pkg/analysis_server/lib/src/services/correction/dart/create_mixin.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import 'package:analysis_server/src/services/correction/fix.dart';
66
import 'package:analysis_server_plugin/edit/dart/correction_producer.dart';
77
import 'package:analyzer/dart/ast/ast.dart';
8-
import 'package:analyzer/dart/element/element.dart';
8+
import 'package:analyzer/dart/element/element2.dart';
99
import 'package:analyzer/file_system/file_system.dart';
1010
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1111
import '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

Comments
 (0)