From 7cc1322fee1d699496078f3d50ead07b38791778 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Fri, 20 Dec 2024 18:47:31 -0800 Subject: [PATCH] Elements. Changes to support google3 migration. Change-Id: I3244d230632dd237304148f7f62f9719d3ac7c11 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401982 Reviewed-by: Phil Quitslund Reviewed-by: Brian Wilkerson --- pkg/analyzer/lib/dart/element/type.dart | 5 +++++ pkg/analyzer/lib/src/dart/element/type.dart | 5 +++++ pkg/analyzer/lib/src/utilities/extensions/element.dart | 6 ------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart index 52d5107dd78f..e1259c8b2e58 100644 --- a/pkg/analyzer/lib/dart/element/type.dart +++ b/pkg/analyzer/lib/dart/element/type.dart @@ -385,6 +385,11 @@ abstract class InterfaceType implements ParameterizedType { /// with the given name. MethodElement? getMethod(String name); + /// Return the element representing the method with the given [name] that is + /// declared in this class, or `null` if this class does not declare a method + /// with the given name. + MethodElement2? getMethod2(String name); + /// Return the element representing the setter with the given [name] that is /// declared in this class, or `null` if this class does not declare a setter /// with the given name. diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart index 90fbcfdd83ff..2e2448f51c16 100644 --- a/pkg/analyzer/lib/src/dart/element/type.dart +++ b/pkg/analyzer/lib/src/dart/element/type.dart @@ -905,6 +905,11 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { MethodElement? getMethod(String methodName) => MethodMember.from(element.getMethod(methodName), this); + @override + MethodElement2? getMethod2(String methodName) { + return getMethod(methodName)?.asElement2; + } + @override PropertyAccessorElement? getSetter(String setterName) => PropertyAccessorMember.from(element.getSetter(setterName), this); diff --git a/pkg/analyzer/lib/src/utilities/extensions/element.dart b/pkg/analyzer/lib/src/utilities/extensions/element.dart index 2d5dc4c86fba..ac1c3ecd5140 100644 --- a/pkg/analyzer/lib/src/utilities/extensions/element.dart +++ b/pkg/analyzer/lib/src/utilities/extensions/element.dart @@ -375,12 +375,6 @@ extension InterfaceElementExtension on InterfaceElement { } } -extension InterfaceTypeExtension on InterfaceType { - MethodElement2? getMethod2(String name) { - return getMethod(name)?.asElement2; - } -} - extension LabelElement2Extension on LabelElement2 { LabelElement get asElement { return firstFragment as LabelElement;