Skip to content

Commit 96fe407

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove V1 Element.thisOrAncestorMatchingX() methods.
Change-Id: I0a788b2fa3d849d55a4690b59aab1fa6ef4ff04e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423446 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 26f9407 commit 96fe407

File tree

4 files changed

+23
-116
lines changed

4 files changed

+23
-116
lines changed

pkg/analyzer/api.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,10 +3031,6 @@ package:analyzer/dart/element/element.dart:
30313031
source (getter: Source?)
30323032
getDisplayString (method: String Function({bool multiline, bool withNullability}))
30333033
getExtendedDisplayName (method: String Function(String?))
3034-
thisOrAncestorMatching (method: E? Function<E extends Element>(bool Function(Element)), deprecated)
3035-
thisOrAncestorMatching3 (method: E? Function<E extends Element>(bool Function(Element)), deprecated)
3036-
thisOrAncestorOfType (method: E? Function<E extends Element>(), deprecated)
3037-
thisOrAncestorOfType3 (method: E? Function<E extends Element>(), deprecated)
30383034
ElementAnnotation (class extends Object implements ConstantEvaluationTarget):
30393035
new (constructor: ElementAnnotation Function())
30403036
constantEvaluationErrors (getter: List<AnalysisError>?)

pkg/analyzer/lib/dart/element/element.dart

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -353,32 +353,6 @@ abstract class Element implements AnalysisTarget {
353353
/// the provided name will be used.
354354
// TODO(brianwilkerson): Make the parameter optional.
355355
String getExtendedDisplayName(String? shortName);
356-
357-
/// Returns either this element or the most immediate ancestor of this element
358-
/// for which the [predicate] returns `true`, or `null` if there is no such
359-
/// element.
360-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
361-
E? thisOrAncestorMatching<E extends Element>(
362-
bool Function(Element) predicate,
363-
);
364-
365-
/// Returns either this element or the most immediate ancestor of this element
366-
/// for which the [predicate] returns `true`, or `null` if there is no such
367-
/// element.
368-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
369-
E? thisOrAncestorMatching3<E extends Element>(
370-
bool Function(Element) predicate,
371-
);
372-
373-
/// Returns either this element or the most immediate ancestor of this element
374-
/// that has the given type, or `null` if there is no such element.
375-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
376-
E? thisOrAncestorOfType<E extends Element>();
377-
378-
/// Returns either this element or the most immediate ancestor of this element
379-
/// that has the given type, or `null` if there is no such element.
380-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
381-
E? thisOrAncestorOfType3<E extends Element>();
382356
}
383357

384358
/// A single annotation associated with an element.

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,9 @@ class DynamicElementImpl extends ElementImpl implements TypeDefiningFragment {
19091909
@override
19101910
ElementKind get kind => ElementKind.DYNAMIC;
19111911

1912+
@override
1913+
Null get library => null;
1914+
19121915
@override
19131916
Null get libraryFragment => null;
19141917

@@ -2834,10 +2837,7 @@ abstract class ElementImpl
28342837
setModifier(Modifier.SYNTHETIC, isSynthetic);
28352838
}
28362839

2837-
LibraryElementImpl? get library {
2838-
// ignore:deprecated_member_use_from_same_package
2839-
return thisOrAncestorOfType();
2840-
}
2840+
LibraryElementImpl? get library;
28412841

28422842
@override
28432843
Source? get librarySource => library?.source;
@@ -2965,61 +2965,6 @@ abstract class ElementImpl
29652965
_modifiers = _modifiers.updated(modifier, value);
29662966
}
29672967

2968-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
2969-
@override
2970-
E? thisOrAncestorMatching<E extends Element>(
2971-
bool Function(Element) predicate,
2972-
) {
2973-
Element? element = this;
2974-
while (element != null && !predicate(element)) {
2975-
element = element.enclosingElement3;
2976-
}
2977-
return element as E?;
2978-
}
2979-
2980-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
2981-
@override
2982-
E? thisOrAncestorMatching3<E extends Element>(
2983-
bool Function(Element) predicate,
2984-
) {
2985-
Element? element = this;
2986-
while (element != null && !predicate(element)) {
2987-
element = (element as ElementImpl).enclosingElement3;
2988-
}
2989-
return element as E?;
2990-
}
2991-
2992-
@Deprecated('Use Element2.thisOrAncestorOfType2() instead')
2993-
@override
2994-
E? thisOrAncestorOfType<E extends Element>() {
2995-
if (E == LibraryElementImpl) {
2996-
if (enclosingElement3 case LibraryElementImpl library) {
2997-
return library as E;
2998-
}
2999-
return thisOrAncestorOfType<CompilationUnitElementImpl>()?.library as E?;
3000-
}
3001-
3002-
Element element = this;
3003-
while (element is! E) {
3004-
var ancestor = element.enclosingElement3;
3005-
if (ancestor == null) return null;
3006-
element = ancestor;
3007-
}
3008-
return element;
3009-
}
3010-
3011-
@Deprecated('Use Element2.thisOrAncestorOfType2() instead')
3012-
@override
3013-
E? thisOrAncestorOfType3<E extends Element>() {
3014-
Element element = this;
3015-
while (element is! E) {
3016-
var ancestor = element.enclosingElement3;
3017-
if (ancestor == null) return null;
3018-
element = ancestor;
3019-
}
3020-
return element;
3021-
}
3022-
30232968
@override
30242969
String toString() {
30252970
return getDisplayString();
@@ -6420,7 +6365,7 @@ class LabelElementImpl extends ElementImpl implements LabelFragment {
64206365

64216366
@override
64226367
LibraryElementImpl get library {
6423-
return super.library!;
6368+
return libraryFragment.element;
64246369
}
64256370

64266371
@override
@@ -8331,6 +8276,9 @@ class NeverElementImpl extends ElementImpl implements TypeDefiningFragment {
83318276
@override
83328277
ElementKind get kind => ElementKind.NEVER;
83338278

8279+
@override
8280+
Null get library => null;
8281+
83348282
@override
83358283
Null get libraryFragment => null;
83368284

@@ -8570,6 +8518,12 @@ class ParameterElementImpl extends VariableElementImpl
85708518
@override
85718519
ElementKind get kind => ElementKind.PARAMETER;
85728520

8521+
@override
8522+
LibraryElementImpl? get library {
8523+
var library = libraryFragment?.element;
8524+
return library as LibraryElementImpl?;
8525+
}
8526+
85738527
@override
85748528
LibraryElementImpl? get library2 => library;
85758529

@@ -8937,6 +8891,9 @@ class PrefixElementImpl extends ElementImpl {
89378891

89388892
@override
89398893
ElementKind get kind => ElementKind.PREFIX;
8894+
8895+
@override
8896+
Null get library => null;
89408897
}
89418898

89428899
class PrefixElementImpl2 extends ElementImpl2 implements PrefixElement2 {
@@ -10561,6 +10518,12 @@ class TypeParameterElementImpl extends ElementImpl
1056110518
@override
1056210519
ElementKind get kind => ElementKind.TYPE_PARAMETER;
1056310520

10521+
@override
10522+
LibraryElementImpl? get library {
10523+
var library = libraryFragment?.element;
10524+
return library as LibraryElementImpl?;
10525+
}
10526+
1056410527
@override
1056510528
LibraryFragment? get libraryFragment {
1056610529
return enclosingFragment?.libraryFragment;

pkg/analyzer/lib/src/dart/element/member.dart

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -922,32 +922,6 @@ abstract class Member
922922
);
923923
}
924924

925-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
926-
@override
927-
E? thisOrAncestorMatching<E extends Element>(
928-
bool Function(Element) predicate,
929-
) {
930-
return declaration.thisOrAncestorMatching(predicate);
931-
}
932-
933-
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
934-
@override
935-
E? thisOrAncestorMatching3<E extends Element>(
936-
bool Function(Element) predicate,
937-
) {
938-
return declaration.thisOrAncestorMatching3(predicate);
939-
}
940-
941-
@Deprecated('Use Element2.thisOrAncestorOfType2() instead')
942-
@override
943-
E? thisOrAncestorOfType<E extends Element>() =>
944-
declaration.thisOrAncestorOfType<E>();
945-
946-
@Deprecated('Use Element2.thisOrAncestorOfType2() instead')
947-
@override
948-
E? thisOrAncestorOfType3<E extends Element>() =>
949-
declaration.thisOrAncestorOfType3<E>();
950-
951925
@override
952926
String toString() {
953927
return getDisplayString();

0 commit comments

Comments
 (0)