Skip to content

Commit 434d6bc

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate ChangeToStaticAccess.
Change-Id: I1c5b9fa8e0cbab50ab418c3a6cbdaafbe2dbbe6f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389563 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 8a868ed commit 434d6bc

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ lib/src/services/correction/dart/add_type_annotation.dart
251251
lib/src/services/correction/dart/assign_to_local_variable.dart
252252
lib/src/services/correction/dart/change_argument_name.dart
253253
lib/src/services/correction/dart/change_to_nearest_precise_value.dart
254+
lib/src/services/correction/dart/change_to_static_access.dart
254255
lib/src/services/correction/dart/change_type_annotation.dart
255256
lib/src/services/correction/dart/convert_add_all_to_spread.dart
256257
lib/src/services/correction/dart/convert_class_to_enum.dart

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

Lines changed: 10 additions & 10 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_plugin/utilities/change_builder/change_builder_core.dart';
1010
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
1111
import 'package:analyzer_plugin/utilities/range_factory.dart';
@@ -29,43 +29,43 @@ class ChangeToStaticAccess extends ResolvedCorrectionProducer {
2929
@override
3030
Future<void> compute(ChangeBuilder builder) async {
3131
Expression? target;
32-
Element? invokedElement;
32+
Element2? invokedElement;
3333
var identifier = node;
3434
if (identifier is SimpleIdentifier) {
3535
var parent = identifier.parent;
3636
if (parent is MethodInvocation) {
3737
if (parent.methodName == identifier) {
3838
target = parent.target;
39-
invokedElement = identifier.staticElement;
39+
invokedElement = identifier.element;
4040
}
4141
} else if (parent is PrefixedIdentifier) {
4242
if (parent.identifier == identifier) {
4343
target = parent.prefix;
44-
invokedElement = identifier.staticElement;
44+
invokedElement = identifier.element;
4545
}
4646
}
4747
}
48-
if (target == null || invokedElement is! ExecutableElement) {
48+
if (target == null || invokedElement is! ExecutableElement2) {
4949
return;
5050
}
5151

5252
var target_final = target;
53-
var declaringElement = invokedElement.enclosingElement3;
53+
var declaringElement = invokedElement.enclosingElement2;
5454

55-
if (declaringElement is InterfaceElement) {
55+
if (declaringElement is InterfaceElement2) {
5656
_className = declaringElement.name;
5757
await builder.addDartFileEdit(file, (builder) {
5858
builder.addReplacement(range.node(target_final), (builder) {
59-
builder.writeReference(declaringElement);
59+
builder.writeReference2(declaringElement);
6060
});
6161
});
62-
} else if (declaringElement is ExtensionElement) {
62+
} else if (declaringElement is ExtensionElement2) {
6363
var extensionName = declaringElement.name;
6464
if (extensionName != null) {
6565
_className = extensionName;
6666
await builder.addDartFileEdit(file, (builder) {
6767
builder.addReplacement(range.node(target_final), (builder) {
68-
builder.writeReference(declaringElement);
68+
builder.writeReference2(declaringElement);
6969
});
7070
});
7171
}

0 commit comments

Comments
 (0)