Skip to content

Commit 8e8a0e3

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate UseDifferentDivisionOperator.
Change-Id: I916174422f918dce4c01764b5af3036e884031cb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398930 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 322baef commit 8e8a0e3

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

pkg/analysis_server/analyzer_use_new_elements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ lib/src/services/completion/dart/declaration_helper.dart
3232
lib/src/services/completion/dart/identifier_helper.dart
3333
lib/src/services/completion/dart/visibility_tracker.dart
3434
lib/src/services/correction/dart/import_library.dart
35-
lib/src/services/correction/dart/use_different_division_operator.dart
3635
lib/src/services/correction/namespace.dart
3736
lib/src/services/correction/util.dart
3837
lib/src/services/flutter/class_description.dart

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import 'package:analysis_server/src/utilities/extensions/element.dart';
77
import 'package:analysis_server_plugin/edit/dart/correction_producer.dart';
88
import 'package:analyzer/dart/ast/ast.dart';
99
import 'package:analyzer/dart/ast/token.dart';
10-
import 'package:analyzer/dart/element/element.dart';
10+
import 'package:analyzer/dart/element/element2.dart';
1111
import 'package:analyzer/dart/element/type.dart';
1212
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
1313
import 'package:analyzer/src/dart/resolver/applicable_extensions.dart';
14-
import 'package:analyzer/src/utilities/extensions/element.dart';
1514
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1615
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
1716
import 'package:analyzer_plugin/utilities/range_factory.dart';
@@ -104,10 +103,13 @@ class _UseDifferentDivisionOperator extends ResolvedCorrectionProducer {
104103
}
105104
// All extensions available in the current scope for the left operand that
106105
// define the other division operator.
107-
var name = Name(unitResult.libraryElement.source.uri, otherOperator.lexeme);
106+
var name = Name.forLibrary(
107+
unitResult.libraryElement2,
108+
otherOperator.lexeme,
109+
);
108110
var hasNoExtensionWithOtherDivisionOperator =
109-
await librariesWithExtensions(otherOperator.lexeme).where((library) {
110-
return library.asElement2.exportedExtensions
111+
await librariesWithExtensions2(otherOperator.lexeme).where((library) {
112+
return library.exportedExtensions
111113
.havingMemberWithBaseName(name)
112114
.applicableTo(
113115
targetLibrary: libraryElement2,
@@ -130,19 +132,19 @@ class _UseDifferentDivisionOperator extends ResolvedCorrectionProducer {
130132
extension on DartType {
131133
Set<_DivisionOperator> get divisionOperators {
132134
// See operators defined for this type element.
133-
if (element case InterfaceElement interfaceElement) {
135+
if (element3 case InterfaceElement2 interfaceElement) {
134136
return {
135-
for (var method in interfaceElement.methods)
137+
for (var method in interfaceElement.methods2)
136138
// No need to test for eq operators, as they are not explicitly defined.
137-
if (method.name == TokenType.SLASH.lexeme)
139+
if (method.name3 == TokenType.SLASH.lexeme)
138140
_DivisionOperator.division
139-
else if (method.name == TokenType.TILDE_SLASH.lexeme)
141+
else if (method.name3 == TokenType.TILDE_SLASH.lexeme)
140142
_DivisionOperator.effectiveIntegerDivision,
141143
...interfaceElement.allSupertypes.expand(
142144
(type) => type.divisionOperators,
143145
),
144146
};
145-
} else if (element case TypeParameterElement typeParameterElement) {
147+
} else if (element3 case TypeParameterElement2 typeParameterElement) {
146148
return typeParameterElement.bound?.divisionOperators ?? const {};
147149
}
148150

0 commit comments

Comments
 (0)