Skip to content

Commit 2bd5128

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Rename AstNodeExtension.withParents to withAncestors
Change-Id: I7554db51356bef19cacad1359399d2c44e6aff7b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434120 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 74cc3f6 commit 2bd5128

File tree

12 files changed

+22
-26
lines changed

12 files changed

+22
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class AddTypeAnnotation extends ResolvedCorrectionProducer {
6262
return;
6363
}
6464

65-
for (var node in this.node.withParents) {
65+
for (var node in this.node.withAncestors) {
6666
if (node is VariableDeclarationList) {
6767
await _forVariableDeclaration(builder, node);
6868
return;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AssignToLocalVariable extends ResolvedCorrectionProducer {
3737
Future<void> compute(ChangeBuilder builder) async {
3838
// prepare enclosing ExpressionStatement
3939
ExpressionStatement? expressionStatement;
40-
for (var node in this.node.withParents) {
40+
for (var node in this.node.withAncestors) {
4141
if (node is ExpressionStatement) {
4242
expressionStatement = node;
4343
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ConvertIntoFinalField extends ResolvedCorrectionProducer {
2727
Future<void> compute(ChangeBuilder builder) async {
2828
// Find the enclosing getter.
2929
MethodDeclaration? getter;
30-
for (var n in node.withParents) {
30+
for (var n in node.withAncestors) {
3131
if (n is MethodDeclaration) {
3232
getter = n;
3333
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ConvertIntoGetter extends ResolvedCorrectionProducer {
4545
if (_type == _Type.implicitThis) {
4646
fieldDeclaration = node.thisOrAncestorOfType();
4747
} else {
48-
for (var n in node.withParents) {
48+
for (var n in node.withAncestors) {
4949
if (n is FieldDeclaration) {
5050
fieldDeclaration = n;
5151
break;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ConvertToGenericFunctionSyntax extends ParsedCorrectionProducer {
3232

3333
@override
3434
Future<void> compute(ChangeBuilder builder) async {
35-
for (var node in this.node.withParents) {
35+
for (var node in this.node.withAncestors) {
3636
if (node is FunctionTypeAlias) {
3737
return _convertFunctionTypeAlias(builder, node);
3838
} else if (node is FunctionTypedFormalParameter) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class _PushConstVisitor extends GeneralizingAstVisitor<void> {
126126
}
127127

128128
bool _containsExcluded(AstNode node) {
129-
return {for (var e in excluded) ...e.withParents}.contains(node);
129+
return {for (var e in excluded) ...e.withAncestors}.contains(node);
130130
}
131131
}
132132

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RemoveTypeAnnotation extends ParsedCorrectionProducer {
4141
return _varAndType(builder);
4242
}
4343

44-
for (var node in this.node.withParents) {
44+
for (var node in this.node.withAncestors) {
4545
if (node is DeclaredIdentifier) {
4646
return _removeFromDeclaredIdentifier(builder, node);
4747
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class UseEffectiveIntegerDivision extends ResolvedCorrectionProducer {
2525

2626
@override
2727
Future<void> compute(ChangeBuilder builder) async {
28-
for (var n in node.withParents) {
28+
for (var n in node.withAncestors) {
2929
if (n is! MethodInvocation) continue;
3030
if (n.offset != errorOffset && n.length != errorLength) continue;
3131

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ String getElementQualifiedName(Element element) {
104104
/// Returns a class or an unit member enclosing the given [input].
105105
AstNode? getEnclosingClassOrUnitMember(AstNode input) {
106106
var member = input;
107-
for (var node in input.withParents) {
107+
for (var node in input.withAncestors) {
108108
switch (node) {
109109
case ClassDeclaration _:
110110
case CompilationUnit _:
@@ -121,7 +121,7 @@ AstNode? getEnclosingClassOrUnitMember(AstNode input) {
121121

122122
/// Return the enclosing executable [AstNode].
123123
AstNode? getEnclosingExecutableNode(AstNode input) {
124-
for (var node in input.withParents) {
124+
for (var node in input.withAncestors) {
125125
if (node is FunctionDeclaration) {
126126
return node;
127127
}
@@ -253,7 +253,7 @@ Expression? getNodeQualifier(SimpleIdentifier node) {
253253
/// Return parent [AstNode]s from compilation unit (at index "0") to the given
254254
/// [node].
255255
List<AstNode> getParents(AstNode node) {
256-
return node.withParents.toList().reversed.toList();
256+
return node.withAncestors.toList().reversed.toList();
257257
}
258258

259259
/// If given [node] is name of qualified property extraction, returns target

pkg/analysis_server/lib/src/services/refactoring/legacy/extract_method.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ class _ExtractMethodAnalyzer extends StatementAnalyzer {
13761376

13771377
void _checkParent(AstNode node) {
13781378
var firstParent = firstSelectedNode!.parent;
1379-
for (var parent in node.withParents) {
1379+
for (var parent in node.withAncestors) {
13801380
if (identical(parent, firstParent)) {
13811381
return;
13821382
}

0 commit comments

Comments
 (0)