DAS: Rename coveredNode to coveringNode; small changes
This is preparing _AbstractCorrectionProducer to be a sealed public
class for plugins:
* Move `_coveringNode` and `coveringNode` to
CorrectionProducer from _AbstractCorrectionProducer; these are only
used by CorrectionProducer subclasses.
* Seal CorrectionProducer; the ultimate subclasses should subclass
either ParsedCorrectionProducer or ResolvedCorrectionProducer.
* Make CorrectionProducerContext final.
Change-Id: Iccbe0d92042eb826c6c53499e052c37442e312ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367761
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart b/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart
index 19a9ff2..56a3057 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart
@@ -94,8 +94,15 @@
}
/// An object that can compute a correction (fix or assist) in a Dart file.
-abstract class CorrectionProducer<T extends ParsedUnitResult>
+sealed class CorrectionProducer<T extends ParsedUnitResult>
extends _AbstractCorrectionProducer<T> {
+ /// The most deeply nested node that completely covers the highlight region of
+ /// the diagnostic, or `null` if there is no diagnostic, such a node does not
+ /// exist, or if it hasn't been computed yet.
+ ///
+ /// Use [coveringNode] to access this field.
+ AstNode? _coveringNode;
+
/// The applicability of this producer.
///
/// This property is to be implemented by each subclass, but outside code must
@@ -137,6 +144,24 @@
applicability == CorrectionApplicability.automatically ||
applicability == CorrectionApplicability.automaticallyButOncePerFile;
+ /// The most deeply nested node that completely covers the highlight region of
+ /// the diagnostic, or `null` if there is no diagnostic or if such a node does
+ /// not exist.
+ AstNode? get coveringNode {
+ if (_coveringNode == null) {
+ var diagnostic = this.diagnostic;
+ if (diagnostic == null) {
+ return null;
+ }
+ var errorOffset = diagnostic.problemMessage.offset;
+ var errorLength = diagnostic.problemMessage.length;
+ _coveringNode =
+ NodeLocator2(errorOffset, math.max(errorOffset + errorLength - 1, 0))
+ .searchWithin(unit);
+ }
+ return _coveringNode;
+ }
+
/// The length of the source range associated with the error message being
/// fixed, or `null` if there is no diagnostic.
int? get errorLength => diagnostic?.problemMessage.length;
@@ -180,7 +205,7 @@
void configure(CorrectionProducerContext<T> context);
}
-class CorrectionProducerContext<UnitResult extends ParsedUnitResult> {
+final class CorrectionProducerContext<UnitResult extends ParsedUnitResult> {
final int _selectionOffset;
final int _selectionLength;
@@ -315,13 +340,13 @@
Future<List<ResolvedCorrectionProducer>> get producers;
}
-/// An object that can compute a correction (fix or assist) in a Dart file using
-/// the parsed AST.
+/// A [CorrectionProducer] that can compute a correction (fix or assist) in a
+/// Dart file using the parsed AST.
abstract class ParsedCorrectionProducer
extends CorrectionProducer<ParsedUnitResult> {}
-/// An object that can compute a correction (fix or assist) in a Dart file using
-/// the resolved AST.
+/// A [CorrectionProducer] that can compute a correction (fix or assist) in a
+/// Dart file using the resolved AST.
abstract class ResolvedCorrectionProducer
extends CorrectionProducer<ResolvedUnitResult> {
AnalysisOptionsImpl get analysisOptions =>
@@ -538,42 +563,16 @@
}
}
-/// The behavior shared by [ResolvedCorrectionProducer] and
+/// The behavior shared by [CorrectionProducer] and
/// [MultiCorrectionProducer].
-abstract class _AbstractCorrectionProducer<T extends ParsedUnitResult> {
+sealed class _AbstractCorrectionProducer<T extends ParsedUnitResult> {
/// The context used to produce corrections.
// TODO(migration): Make it not `late`, require in constructor.
late CorrectionProducerContext<T> _context;
- /// The most deeply nested node that completely covers the highlight region of
- /// the diagnostic, or `null` if there is no diagnostic, such a node does not
- /// exist, or if it hasn't been computed yet.
- ///
- /// Use [coveredNode] to access this field.
- AstNode? _coveredNode;
-
/// Whether the fixes are being built for the bulk-fix request.
bool get applyingBulkFixes => _context._applyingBulkFixes;
- /// The most deeply nested node that completely covers the highlight region of
- /// the diagnostic, or `null` if there is no diagnostic or if such a node does
- /// not exist.
- AstNode? get coveredNode {
- // TODO(brianwilkerson): Consider renaming this to `coveringNode`.
- if (_coveredNode == null) {
- var diagnostic = this.diagnostic;
- if (diagnostic == null) {
- return null;
- }
- var errorOffset = diagnostic.problemMessage.offset;
- var errorLength = diagnostic.problemMessage.length;
- _coveredNode =
- NodeLocator2(errorOffset, math.max(errorOffset + errorLength - 1, 0))
- .searchWithin(unit);
- }
- return _coveredNode;
- }
-
/// The diagnostic being fixed, or `null` if this producer is being
/// used to produce an assist.
Diagnostic? get diagnostic => _context._diagnostic;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_explicit_cast.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_explicit_cast.dart
index 9403871..cf989b9 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_explicit_cast.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_explicit_cast.dart
@@ -27,7 +27,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var target = coveredNode;
+ var target = coveringNode;
if (target is! Expression) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_leading_newline_to_string.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_leading_newline_to_string.dart
index 904cbed..b91febd 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_leading_newline_to_string.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_leading_newline_to_string.dart
@@ -21,7 +21,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var stringLiteral = coveredNode;
+ var stringLiteral = coveringNode;
if (stringLiteral is! SimpleStringLiteral) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_null_check.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_null_check.dart
index 7f8d3d5..62ed646 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_null_check.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_null_check.dart
@@ -43,59 +43,59 @@
@override
Future<void> compute(ChangeBuilder builder) async {
Expression? target;
- var coveredNode = this.coveredNode;
- var coveredNodeParent = coveredNode?.parent;
+ var coveringNode = this.coveringNode;
+ var coveringNodeParent = coveringNode?.parent;
- if (await _isNullAware(builder, coveredNode)) {
+ if (await _isNullAware(builder, coveringNode)) {
return;
}
- if (coveredNode is SimpleIdentifier) {
- if (coveredNodeParent is MethodInvocation) {
- target = coveredNodeParent.realTarget;
- } else if (coveredNodeParent is PrefixedIdentifier) {
- target = coveredNodeParent.prefix;
- } else if (coveredNodeParent is PropertyAccess) {
- target = coveredNodeParent.realTarget;
- } else if (coveredNodeParent is CascadeExpression &&
+ if (coveringNode is SimpleIdentifier) {
+ if (coveringNodeParent is MethodInvocation) {
+ target = coveringNodeParent.realTarget;
+ } else if (coveringNodeParent is PrefixedIdentifier) {
+ target = coveringNodeParent.prefix;
+ } else if (coveringNodeParent is PropertyAccess) {
+ target = coveringNodeParent.realTarget;
+ } else if (coveringNodeParent is CascadeExpression &&
await _isNullAware(
- builder, coveredNodeParent.cascadeSections.first)) {
+ builder, coveringNodeParent.cascadeSections.first)) {
return;
} else {
- target = coveredNode;
+ target = coveringNode;
}
- } else if (coveredNode is IndexExpression) {
- target = coveredNode.realTarget;
+ } else if (coveringNode is IndexExpression) {
+ target = coveringNode.realTarget;
if (target.staticType?.nullabilitySuffix != NullabilitySuffix.question) {
- target = coveredNode;
+ target = coveringNode;
}
- } else if (coveredNode is Expression &&
- coveredNodeParent is FunctionExpressionInvocation) {
- target = coveredNode;
- } else if (coveredNodeParent is AssignmentExpression) {
- target = coveredNodeParent.rightHandSide;
- } else if (coveredNode is PostfixExpression) {
- target = coveredNode.operand;
- } else if (coveredNode is PrefixExpression) {
- target = coveredNode.operand;
- } else if (coveredNode is BinaryExpression) {
- if (coveredNode.operator.type != TokenType.QUESTION_QUESTION) {
- target = coveredNode.leftOperand;
+ } else if (coveringNode is Expression &&
+ coveringNodeParent is FunctionExpressionInvocation) {
+ target = coveringNode;
+ } else if (coveringNodeParent is AssignmentExpression) {
+ target = coveringNodeParent.rightHandSide;
+ } else if (coveringNode is PostfixExpression) {
+ target = coveringNode.operand;
+ } else if (coveringNode is PrefixExpression) {
+ target = coveringNode.operand;
+ } else if (coveringNode is BinaryExpression) {
+ if (coveringNode.operator.type != TokenType.QUESTION_QUESTION) {
+ target = coveringNode.leftOperand;
} else {
- var expectedType = coveredNode.staticParameterElement?.type;
+ var expectedType = coveringNode.staticParameterElement?.type;
if (expectedType == null) return;
- var leftType = coveredNode.leftOperand.staticType;
+ var leftType = coveringNode.leftOperand.staticType;
var leftAssignable = leftType != null &&
typeSystem.isAssignableTo(
typeSystem.promoteToNonNull(leftType), expectedType,
strictCasts: analysisOptions.strictCasts);
if (leftAssignable) {
- target = coveredNode.rightOperand;
+ target = coveringNode.rightOperand;
}
}
- } else if (coveredNode is AsExpression) {
- target = coveredNode.expression;
+ } else if (coveringNode is AsExpression) {
+ target = coveringNode.expression;
}
if (target == null) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/change_type_annotation.dart b/pkg/analysis_server/lib/src/services/correction/dart/change_type_annotation.dart
index a256c59..cf79ddf 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/change_type_annotation.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/change_type_annotation.dart
@@ -29,13 +29,13 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var declaration = coveredNode?.parent;
+ var declaration = coveringNode?.parent;
if (declaration is! VariableDeclaration) {
return;
}
var initializer = declaration.initializer;
- if (initializer == null || initializer != coveredNode) {
+ if (initializer == null || initializer != coveringNode) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware_spread.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware_spread.dart
index 714c7de..2bd2ce9 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware_spread.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware_spread.dart
@@ -19,7 +19,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var parent = coveredNode?.parent;
+ var parent = coveringNode?.parent;
if (parent is SpreadElement && !parent.isNullAware) {
await builder.addDartFileEdit(file, (builder) {
builder.addSimpleInsertion(parent.spreadOperator.end, '?');
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart b/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart
index da3a044..3672183 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/move_type_arguments_to_class.dart
@@ -22,7 +22,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var typeArguments = coveredNode;
+ var typeArguments = coveringNode;
if (typeArguments is! TypeArgumentList) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_annotation.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_annotation.dart
index 37ab901..6214ab9 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_annotation.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_annotation.dart
@@ -44,7 +44,7 @@
);
}
- var node = coveredNode;
+ var node = coveringNode;
if (node is Annotation) {
await addFix(node);
} else if (node is DefaultFormalParameter) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_dead_code.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_dead_code.dart
index 5515bf2..71bd83e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_dead_code.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_dead_code.dart
@@ -20,8 +20,8 @@
CorrectionApplicability.singleLocation;
@override
- AstNode? get coveredNode {
- var node = super.coveredNode;
+ AstNode? get coveringNode {
+ var node = super.coveringNode;
if (node is BinaryExpression) {
var problemMessage = diagnostic?.problemMessage;
if (problemMessage != null) {
@@ -41,14 +41,14 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var coveredNode = this.coveredNode;
- var parent = coveredNode?.parent;
+ var coveringNode = this.coveringNode;
+ var parent = coveringNode?.parent;
- if (coveredNode is Expression) {
+ if (coveringNode is Expression) {
if (parent is BinaryExpression) {
- if (parent.rightOperand == coveredNode) {
+ if (parent.rightOperand == coveringNode) {
await builder.addDartFileEdit(file, (builder) {
- builder.addDeletion(range.endEnd(parent.leftOperand, coveredNode));
+ builder.addDeletion(range.endEnd(parent.leftOperand, coveringNode));
});
}
} else if (parent is ForParts) {
@@ -56,8 +56,7 @@
if (forStatement is! ForStatement) return;
await _computeForStatementParts(builder, forStatement, parent);
}
- } else if (coveredNode is Block) {
- var block = coveredNode;
+ } else if (coveringNode is Block) {
var statementsToRemove = <Statement>[];
var problemMessage = diagnostic?.problemMessage;
if (problemMessage == null) {
@@ -65,7 +64,7 @@
}
var errorRange =
SourceRange(problemMessage.offset, problemMessage.length);
- for (var statement in block.statements) {
+ for (var statement in coveringNode.statements) {
if (range.node(statement).intersects(errorRange)) {
statementsToRemove.add(statement);
}
@@ -76,34 +75,34 @@
builder.addDeletion(rangeToRemove);
});
}
- } else if (coveredNode is Statement) {
- if (coveredNode is EmptyStatement) {
+ } else if (coveringNode is Statement) {
+ if (coveringNode is EmptyStatement) {
return;
}
- if (coveredNode is DoStatement &&
- await _computeDoStatement(builder, coveredNode)) {
+ if (coveringNode is DoStatement &&
+ await _computeDoStatement(builder, coveringNode)) {
return;
}
- var rangeToRemove = utils.getLinesRangeStatements([coveredNode]);
+ var rangeToRemove = utils.getLinesRangeStatements([coveringNode]);
await builder.addDartFileEdit(file, (builder) {
builder.addDeletion(rangeToRemove);
});
- } else if (coveredNode is CatchClause && parent is TryStatement) {
+ } else if (coveringNode is CatchClause && parent is TryStatement) {
var catchClauses = parent.catchClauses;
- var index = catchClauses.indexOf(coveredNode);
+ var index = catchClauses.indexOf(coveringNode);
var previous = index == 0 ? parent.body : catchClauses[index - 1];
await builder.addDartFileEdit(file, (builder) {
- builder.addDeletion(range.endEnd(previous, coveredNode));
+ builder.addDeletion(range.endEnd(previous, coveringNode));
});
- } else if (coveredNode is ForParts) {
- var forStatement = coveredNode.parent;
+ } else if (coveringNode is ForParts) {
+ var forStatement = coveringNode.parent;
if (forStatement is! ForStatement) return;
- await _computeForStatementParts(builder, forStatement, coveredNode);
- } else if (coveredNode is SwitchPatternCase) {
+ await _computeForStatementParts(builder, forStatement, coveringNode);
+ } else if (coveringNode is SwitchPatternCase) {
await builder.addDartFileEdit(file, (builder) {
- builder.addDeletion(range.deletionRange(coveredNode));
+ builder.addDeletion(range.deletionRange(coveringNode));
});
}
}
@@ -171,7 +170,7 @@
Future<void> _computeForStatementParts(ChangeBuilder builder,
ForStatement forStatement, ForParts forParts) async {
- var beginNode = coveredNode;
+ var beginNode = coveringNode;
if (beginNode == null) return;
var updaters = forParts.updaters;
if (!updaters.contains(beginNode)) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_duplicate_case.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_duplicate_case.dart
index 63a0e4f..8c3e914 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_duplicate_case.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_duplicate_case.dart
@@ -23,7 +23,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = coveredNode?.parent;
+ var node = coveringNode?.parent;
if (node is! SwitchCase) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_name_from_combinator.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_name_from_combinator.dart
index 7aecd8d..ac5e75b 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_name_from_combinator.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_name_from_combinator.dart
@@ -26,7 +26,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = coveredNode;
+ var node = coveringNode;
if (node is SimpleIdentifier) {
var parent = node.parent;
if (parent is Combinator) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_parentheses_in_getter_invocation.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_parentheses_in_getter_invocation.dart
index fa50921..00f9365 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_parentheses_in_getter_invocation.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_parentheses_in_getter_invocation.dart
@@ -20,7 +20,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var invocation = coveredNode?.parent;
+ var invocation = coveringNode?.parent;
if (invocation is FunctionExpressionInvocation) {
await builder.addDartFileEdit(file, (builder) {
builder.addDeletion(range.node(invocation.argumentList));
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_type_arguments.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_type_arguments.dart
index 50ca2a9..c84f914 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_type_arguments.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_type_arguments.dart
@@ -20,7 +20,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var typeArguments = coveredNode;
+ var typeArguments = coveringNode;
if (typeArguments is! TypeArgumentList) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_cast.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_cast.dart
index 052dbcf..76eeff4 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_cast.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_cast.dart
@@ -24,7 +24,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var asExpression = coveredNode;
+ var asExpression = coveringNode;
if (asExpression is! AsExpression) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_parentheses.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_parentheses.dart
index 3cc7a20..c1f9061 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_parentheses.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_parentheses.dart
@@ -22,7 +22,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var outer = coveredNode;
+ var outer = coveringNode;
if (outer is ParenthesizedExpression &&
outer.parent is! ParenthesizedExpression) {
var left = outer.leftParenthesis;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_var_keyword.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_var_keyword.dart
index 18101d6..e7d2fd3 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_var_keyword.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_var_keyword.dart
@@ -20,7 +20,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = coveredNode;
+ var node = coveringNode;
if (node is DeclaredVariablePattern) {
var keyword = node.keyword;
if (keyword != null) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_null_with_closure.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_null_with_closure.dart
index f0f3d79..9fa1527 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_null_with_closure.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_null_with_closure.dart
@@ -27,11 +27,11 @@
AstNode? nodeToFix;
var parameters = const <ParameterElement>[];
- var coveredNode = this.coveredNode;
- if (coveredNode is NamedExpression) {
- var expression = coveredNode.expression;
+ var coveringNode = this.coveringNode;
+ if (coveringNode is NamedExpression) {
+ var expression = coveringNode.expression;
if (expression is NullLiteral) {
- var element = coveredNode.element;
+ var element = coveringNode.element;
if (element is ParameterElement) {
var type = element.type;
if (type is FunctionType) {
@@ -40,8 +40,8 @@
}
nodeToFix = expression;
}
- } else if (coveredNode is NullLiteral) {
- nodeToFix = coveredNode;
+ } else if (coveringNode is NullLiteral) {
+ nodeToFix = coveringNode;
}
if (nodeToFix == null) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_with_not_null_aware.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_with_not_null_aware.dart
index ff35ae3..62f949d 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_with_not_null_aware.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_with_not_null_aware.dart
@@ -29,7 +29,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = coveredNode;
+ var node = coveringNode;
if (node is MethodInvocation) {
var operator = node.operator;
if (operator != null) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_with_null_aware.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_with_null_aware.dart
index bf8db1d..a93b883 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_with_null_aware.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_with_null_aware.dart
@@ -43,7 +43,7 @@
}
Future<void> _computeInChain(ChangeBuilder builder) async {
- var node = coveredNode;
+ var node = coveringNode;
if (node is Expression) {
var node_final = node;
await builder.addDartFileEdit(file, (builder) {
@@ -67,13 +67,13 @@
}
Future<void> _computeSingle(ChangeBuilder builder) async {
- var node = coveredNode?.parent;
+ var node = coveringNode?.parent;
if (node is CascadeExpression) {
node = node.cascadeSections.first;
} else {
- var coveredNode = this.coveredNode;
- if (coveredNode is IndexExpression) {
- await _insert(builder, coveredNode.leftBracket);
+ var coveringNode = this.coveringNode;
+ if (coveringNode is IndexExpression) {
+ await _insert(builder, coveringNode.leftBracket);
return;
}
var parent = node?.parent;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/sort_constructor_first.dart b/pkg/analysis_server/lib/src/services/correction/dart/sort_constructor_first.dart
index 7fda7d8..86c258a 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/sort_constructor_first.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/sort_constructor_first.dart
@@ -23,7 +23,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var constructor = coveredNode?.parent;
+ var constructor = coveringNode?.parent;
var clazz = constructor?.parent;
if (clazz is! ClassDeclaration || constructor is! ConstructorDeclaration) {
return;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/sort_unnamed_constructor_first.dart b/pkg/analysis_server/lib/src/services/correction/dart/sort_unnamed_constructor_first.dart
index abc2037..2f46cbf 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/sort_unnamed_constructor_first.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/sort_unnamed_constructor_first.dart
@@ -23,7 +23,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var clazz = coveredNode?.parent?.parent;
+ var clazz = coveringNode?.parent?.parent;
if (clazz is! ClassDeclaration) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/use_eq_eq_null.dart b/pkg/analysis_server/lib/src/services/correction/dart/use_eq_eq_null.dart
index adcb499ea..23ecdb6 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/use_eq_eq_null.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/use_eq_eq_null.dart
@@ -22,8 +22,8 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- if (coveredNode is IsExpression) {
- var isExpression = coveredNode as IsExpression;
+ if (coveringNode is IsExpression) {
+ var isExpression = coveringNode as IsExpression;
await builder.addDartFileEdit(file, (builder) {
builder.addReplacement(
range.endEnd(isExpression.expression, isExpression), (builder) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/use_not_eq_null.dart b/pkg/analysis_server/lib/src/services/correction/dart/use_not_eq_null.dart
index aea266a..cd8e844 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/use_not_eq_null.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/use_not_eq_null.dart
@@ -22,8 +22,8 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- if (coveredNode is IsExpression) {
- var isExpression = coveredNode as IsExpression;
+ if (coveringNode is IsExpression) {
+ var isExpression = coveringNode as IsExpression;
await builder.addDartFileEdit(file, (builder) {
builder.addReplacement(
range.endEnd(isExpression.expression, isExpression), (builder) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/use_rethrow.dart b/pkg/analysis_server/lib/src/services/correction/dart/use_rethrow.dart
index f1ff7e3..33952e7 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/use_rethrow.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/use_rethrow.dart
@@ -22,10 +22,10 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var coveredNode = this.coveredNode;
- if (coveredNode is ThrowExpression) {
+ var coveringNode = this.coveringNode;
+ if (coveringNode is ThrowExpression) {
await builder.addDartFileEdit(file, (builder) {
- builder.addSimpleReplacement(range.node(coveredNode), 'rethrow');
+ builder.addSimpleReplacement(range.node(coveringNode), 'rethrow');
});
}
}