Skip to content

Commit 61c3582

Browse files
srawlinsCommit Queue
authored andcommitted
DAS: Migrate from InheritanceManager3 in corrections
Change-Id: I2adf06ba0a1b19c233bd54f5116e6f63c62b1fd3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429720 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]>
1 parent e68d688 commit 61c3582

File tree

4 files changed

+20
-38
lines changed

4 files changed

+20
-38
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AddCallSuper extends ResolvedCorrectionProducer {
4040

4141
var name = methodDeclaration.name.lexeme;
4242
var nameObj = Name.forLibrary(classElement.library2, name);
43-
var overridden = InheritanceManager3().getInherited4(classElement, nameObj);
43+
var overridden = classElement.getInheritedMember(nameObj);
4444
if (overridden == null) return;
4545
var overriddenNamedParameters = overridden.formalParameters
4646
.where((p) => p.isNamed)

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:analyzer/dart/ast/token.dart';
99
import 'package:analyzer/dart/element/element.dart';
1010
import 'package:analyzer/dart/element/type.dart';
1111
import 'package:analyzer/src/dart/ast/ast.dart';
12-
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
1312
import 'package:analyzer/src/dart/element/type.dart';
1413
import 'package:analyzer/src/dart/resolver/applicable_extensions.dart';
1514
import 'package:analyzer/src/utilities/extensions/ast.dart';
@@ -534,21 +533,14 @@ extension on Element? {
534533
if (element is! InterfaceElement) {
535534
return false;
536535
}
537-
var inheritanceManager3 = InheritanceManager3();
538-
var interface = inheritanceManager3.getInterface2(element);
539-
var bracesGetter =
540-
interface.map2[Name.forLibrary(
541-
element.library2,
542-
TokenType.INDEX.lexeme,
543-
)];
544-
if (bracesGetter != null) {
545-
return true;
546-
}
547-
var bracesSetter =
548-
interface.map2[Name.forLibrary(
549-
element.library2,
550-
TokenType.INDEX_EQ.lexeme,
551-
)];
552-
return bracesSetter != null;
536+
var indexName = Name.forLibrary(element.library2, TokenType.INDEX.lexeme);
537+
var indexEqName = Name.forLibrary(
538+
element.library2,
539+
TokenType.INDEX_EQ.lexeme,
540+
);
541+
var member =
542+
element.getInterfaceMember(indexName) ??
543+
element.getInterfaceMember(indexEqName);
544+
return member != null;
553545
}
554546
}

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,16 @@ class ReplaceReturnType extends ResolvedCorrectionProducer {
105105
}
106106

107107
var classElement = clazz.declaredFragment!.element;
108-
var overriddenList = InheritanceManager3().getOverridden4(
109-
classElement,
108+
var overriddenList = classElement.getOverridden(
110109
Name.forLibrary(classElement.library2, methodName),
111110
);
112111

113-
if (overriddenList != null) {
114-
var notSubtype = overriddenList.any(
115-
(element) =>
116-
!libraryElement2.typeSystem.isSubtypeOf(
117-
newType,
118-
element.returnType,
119-
),
120-
);
121-
if (notSubtype) {
122-
return false;
123-
}
112+
if (overriddenList == null) {
113+
return true;
124114
}
125-
return true;
115+
116+
return overriddenList.every(
117+
(e) => libraryElement2.typeSystem.isSubtypeOf(newType, e.returnType),
118+
);
126119
}
127120
}

pkg/analysis_server/lib/src/services/correction/fix/data_driven/rename_parameter.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:analysis_server/src/services/correction/dart/data_driven.dart';
66
import 'package:analysis_server/src/services/correction/fix/data_driven/change.dart';
77
import 'package:analyzer/dart/ast/ast.dart';
88
import 'package:analyzer/dart/element/element.dart';
9-
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
109
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
1110
import 'package:analyzer_plugin/utilities/range_factory.dart';
1211

@@ -33,9 +32,7 @@ class RenameParameter extends Change<_Data> {
3332
var declaration = data.methodDeclaration;
3433
var parameter = declaration.parameterNamed(oldName);
3534
if (parameter != null) {
36-
var overriddenMethod = declaration.overriddenElement(
37-
fix.inheritanceManager,
38-
);
35+
var overriddenMethod = declaration.overriddenElement;
3936
var overriddenParameter = overriddenMethod?.parameterNamed(oldName);
4037
if (overriddenParameter == null) {
4138
// If the overridden parameter has already been removed, then just
@@ -134,13 +131,13 @@ extension on MethodDeclaration {
134131
/// Returns the element that this method overrides.
135132
///
136133
/// Returns `null` if this method doesn't override any inherited member.
137-
ExecutableElement? overriddenElement(InheritanceManager3 inheritanceManager) {
134+
ExecutableElement? get overriddenElement {
138135
var element = declaredFragment?.element;
139136
if (element != null) {
140137
var enclosingElement = element.enclosingElement;
141138
if (enclosingElement is InterfaceElement) {
142139
var name = Name(enclosingElement.library2.uri, element.name3!);
143-
return inheritanceManager.getInherited4(enclosingElement, name);
140+
return enclosingElement.getInheritedMember(name);
144141
}
145142
}
146143
return null;

0 commit comments

Comments
 (0)