mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Make local variables that hide fields be final (analysis_server)
As per our earlier conversation, I looked for places where a local variable was introduced to overcome field promotion and has the same name as the field. Where possible I made them final; where not possible I changed the name. Change-Id: Iad3d2139693ca66f1eb22a3926c3b84a4115f13d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196552 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
3498404125
commit
1ad68b9b16
|
@ -32,7 +32,7 @@ class InstrumentationInputConverter extends CommonInputConverter {
|
|||
try {
|
||||
fields = _parseFields(line);
|
||||
if (fields.length < 2) {
|
||||
var readBuffer = this.readBuffer;
|
||||
final readBuffer = this.readBuffer;
|
||||
if (readBuffer != null) {
|
||||
readBuffer.writeln(fields.length == 1 ? fields[0] : '');
|
||||
return null;
|
||||
|
|
|
@ -46,7 +46,7 @@ class Notification {
|
|||
Map<String, Object> toJson() {
|
||||
var jsonObject = <String, Object>{};
|
||||
jsonObject[EVENT] = event;
|
||||
var params = this.params;
|
||||
final params = this.params;
|
||||
if (params != null) {
|
||||
jsonObject[PARAMS] = params;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class Request {
|
|||
if (params.isNotEmpty) {
|
||||
jsonObject[PARAMS] = params;
|
||||
}
|
||||
var clientRequestTime = this.clientRequestTime;
|
||||
final clientRequestTime = this.clientRequestTime;
|
||||
if (clientRequestTime != null) {
|
||||
jsonObject[CLIENT_REQUEST_TIME] = clientRequestTime;
|
||||
}
|
||||
|
@ -505,11 +505,11 @@ class Response {
|
|||
Map<String, Object> toJson() {
|
||||
var jsonObject = <String, Object>{};
|
||||
jsonObject[ID] = id;
|
||||
var error = this.error;
|
||||
final error = this.error;
|
||||
if (error != null) {
|
||||
jsonObject[ERROR] = error.toJson();
|
||||
}
|
||||
var result = this.result;
|
||||
final result = this.result;
|
||||
if (result != null) {
|
||||
jsonObject[RESULT] = result;
|
||||
}
|
||||
|
|
|
@ -1227,7 +1227,7 @@ class _RefactoringManager {
|
|||
initStatus = await refactoring.checkInitialConditions();
|
||||
_checkForReset_afterInitialConditions();
|
||||
if (refactoring is ExtractLocalRefactoring) {
|
||||
var feedback = this.feedback as ExtractLocalVariableFeedback;
|
||||
final feedback = this.feedback as ExtractLocalVariableFeedback;
|
||||
feedback.names = refactoring.names;
|
||||
feedback.offsets = refactoring.offsets;
|
||||
feedback.lengths = refactoring.lengths;
|
||||
|
@ -1236,7 +1236,7 @@ class _RefactoringManager {
|
|||
feedback.coveringExpressionLengths =
|
||||
refactoring.coveringExpressionLengths;
|
||||
} else if (refactoring is ExtractMethodRefactoring) {
|
||||
var feedback = this.feedback as ExtractMethodFeedback;
|
||||
final feedback = this.feedback as ExtractMethodFeedback;
|
||||
feedback.canCreateGetter = refactoring.canCreateGetter;
|
||||
feedback.returnType = refactoring.returnType;
|
||||
feedback.names = refactoring.names;
|
||||
|
@ -1255,7 +1255,7 @@ class _RefactoringManager {
|
|||
className: refactoring.className);
|
||||
}
|
||||
} else if (refactoring is RenameRefactoring) {
|
||||
var feedback = this.feedback as RenameFeedback;
|
||||
final feedback = this.feedback as RenameFeedback;
|
||||
feedback.elementKindName = refactoring.elementKindName;
|
||||
feedback.oldName = refactoring.oldName;
|
||||
}
|
||||
|
|
|
@ -901,7 +901,7 @@ class PluginSession {
|
|||
/// Send a request, based on the given [parameters]. Return a future that will
|
||||
/// complete when a response is received.
|
||||
Future<Response> sendRequest(RequestParams parameters) {
|
||||
var channel = this.channel;
|
||||
final channel = this.channel;
|
||||
if (channel == null) {
|
||||
throw StateError('Cannot send a request to a plugin that has stopped.');
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ class ArgListContributor extends DartCompletionContributor {
|
|||
|
||||
/// Return the number of arguments in the argument list.
|
||||
int _argCount() {
|
||||
var argumentList = this.argumentList;
|
||||
final argumentList = this.argumentList;
|
||||
if (argumentList != null) {
|
||||
var paren = argumentList.rightParenthesis;
|
||||
if (request.target.entity == paren) {
|
||||
|
@ -159,7 +159,7 @@ class ArgListContributor extends DartCompletionContributor {
|
|||
/// Return `true` if the caret is preceding an arg where a name could be added
|
||||
/// (turning a positional arg into a named arg).
|
||||
bool _isAddingLabelToPositional() {
|
||||
var argumentList = this.argumentList;
|
||||
final argumentList = this.argumentList;
|
||||
if (argumentList != null) {
|
||||
var entity = request.target.entity;
|
||||
if (entity is! Expression) {
|
||||
|
@ -194,7 +194,7 @@ class ArgListContributor extends DartCompletionContributor {
|
|||
/// Return `true` if the completion target is at the end of the list of
|
||||
/// arguments.
|
||||
bool _isAppendingToArgList() {
|
||||
var argumentList = this.argumentList;
|
||||
final argumentList = this.argumentList;
|
||||
if (argumentList != null) {
|
||||
var entity = request.target.entity;
|
||||
if (entity == argumentList.rightParenthesis) {
|
||||
|
@ -275,7 +275,7 @@ class ArgListContributor extends DartCompletionContributor {
|
|||
/// [_isInsertingToArgListWithNoSynthetic] have been called and both returned
|
||||
/// `false`.
|
||||
bool _isInsertingToArgListWithSynthetic() {
|
||||
var argumentList = this.argumentList;
|
||||
final argumentList = this.argumentList;
|
||||
if (argumentList != null) {
|
||||
var entity = request.target.entity;
|
||||
if (entity is SimpleIdentifier) {
|
||||
|
@ -295,7 +295,7 @@ class ArgListContributor extends DartCompletionContributor {
|
|||
/// Return a list containing the currently specified named arguments.
|
||||
List<String> _namedArgs() {
|
||||
var namedArgs = <String>[];
|
||||
var argumentList = this.argumentList;
|
||||
final argumentList = this.argumentList;
|
||||
if (argumentList != null) {
|
||||
for (var arg in argumentList.arguments) {
|
||||
if (arg is NamedExpression) {
|
||||
|
|
|
@ -199,7 +199,8 @@ class DartCompletionManager {
|
|||
}
|
||||
|
||||
void _addIncludedSuggestionRelevanceTags(DartCompletionRequestImpl request) {
|
||||
var includedSuggestionRelevanceTags = this.includedSuggestionRelevanceTags!;
|
||||
final includedSuggestionRelevanceTags =
|
||||
this.includedSuggestionRelevanceTags!;
|
||||
var location = request.opType.completionLocation;
|
||||
if (location != null) {
|
||||
var locationTable = elementKindRelevance[location];
|
||||
|
|
|
@ -1015,7 +1015,7 @@ extension on AstNode {
|
|||
extension on ArgumentList {
|
||||
/// Return the [FunctionType], if there is one, for this [ArgumentList].
|
||||
FunctionType? get functionType {
|
||||
var parent = this.parent;
|
||||
final parent = this.parent;
|
||||
if (parent is InstanceCreationExpression) {
|
||||
return parent.constructorName.staticElement?.type;
|
||||
} else if (parent is MethodInvocation) {
|
||||
|
|
|
@ -56,7 +56,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
|
|||
return;
|
||||
}
|
||||
}
|
||||
var entity = this.entity;
|
||||
final entity = this.entity;
|
||||
if (entity == node.rightParenthesis) {
|
||||
_addExpressionKeywords(node);
|
||||
var previous = node.findPrevious(entity as Token);
|
||||
|
@ -142,7 +142,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitClassDeclaration(ClassDeclaration node) {
|
||||
var entity = this.entity;
|
||||
final entity = this.entity;
|
||||
// Don't suggest class name
|
||||
if (entity == node.name) {
|
||||
return;
|
||||
|
@ -544,7 +544,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitMixinDeclaration(MixinDeclaration node) {
|
||||
var entity = this.entity;
|
||||
final entity = this.entity;
|
||||
// Don't suggest mixin name
|
||||
if (entity == node.name) {
|
||||
return;
|
||||
|
@ -906,7 +906,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
|
|||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
var entity = this.entity;
|
||||
final entity = this.entity;
|
||||
if (entity is Statement) {
|
||||
var entityIndex = block.statements.indexOf(entity);
|
||||
if (entityIndex > 0) {
|
||||
|
|
|
@ -373,7 +373,7 @@ abstract class _AbstractCorrectionProducer {
|
|||
AstNode? get coveredNode {
|
||||
// TODO(brianwilkerson) Consider renaming this to `coveringNode`.
|
||||
if (_coveredNode == null) {
|
||||
var diagnostic = this.diagnostic;
|
||||
final diagnostic = this.diagnostic;
|
||||
if (diagnostic == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class AddAsync extends CorrectionProducer {
|
|||
} else {
|
||||
var body = node.thisOrAncestorOfType<FunctionBody>();
|
||||
if (body != null && body.keyword == null) {
|
||||
var typeProvider = this.typeProvider;
|
||||
final typeProvider = this.typeProvider;
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.convertFunctionFromSyncToAsync(body, typeProvider);
|
||||
});
|
||||
|
|
|
@ -17,27 +17,27 @@ class AddConst extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
AstNode? node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
node = node.parent;
|
||||
AstNode? targetNode = node;
|
||||
if (targetNode is SimpleIdentifier) {
|
||||
targetNode = targetNode.parent;
|
||||
}
|
||||
if (node is ConstructorDeclaration) {
|
||||
var node_final = node;
|
||||
if (targetNode is ConstructorDeclaration) {
|
||||
var node_final = targetNode;
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
final offset = node_final.firstTokenAfterCommentAndMetadata.offset;
|
||||
builder.addSimpleInsertion(offset, 'const ');
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (node is TypeName) {
|
||||
node = node.parent;
|
||||
if (targetNode is TypeName) {
|
||||
targetNode = targetNode.parent;
|
||||
}
|
||||
if (node is ConstructorName) {
|
||||
node = node.parent;
|
||||
if (targetNode is ConstructorName) {
|
||||
targetNode = targetNode.parent;
|
||||
}
|
||||
if (node is InstanceCreationExpression) {
|
||||
if (node.keyword == null) {
|
||||
var node_final = node;
|
||||
if (targetNode is InstanceCreationExpression) {
|
||||
if (targetNode.keyword == null) {
|
||||
var node_final = targetNode;
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addSimpleInsertion(node_final.offset, 'const ');
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddLate extends CorrectionProducer {
|
|||
if (!libraryElement.isNonNullableByDefault) {
|
||||
return;
|
||||
}
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
var variable = node.parent;
|
||||
var variableList = variable?.parent;
|
||||
|
|
|
@ -21,7 +21,7 @@ class AddMissingParameterNamed extends CorrectionProducer {
|
|||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
// Prepare the name of the missing parameter.
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is! SimpleIdentifier) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class AddMissingRequiredArgument extends CorrectionProducer {
|
|||
}
|
||||
}
|
||||
|
||||
var diagnostic = this.diagnostic;
|
||||
final diagnostic = this.diagnostic;
|
||||
if (diagnostic == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class AddNeNull extends CorrectionProducerWithDiagnostic {
|
|||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
if (unit.featureSet.isEnabled(Feature.non_nullable)) {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is Expression &&
|
||||
node.staticType?.nullabilitySuffix == NullabilitySuffix.none) {
|
||||
return;
|
||||
|
|
|
@ -23,7 +23,7 @@ class AddNullCheck extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
Expression? target;
|
||||
var coveredNode = this.coveredNode;
|
||||
final coveredNode = this.coveredNode;
|
||||
var coveredNodeParent = coveredNode?.parent;
|
||||
if (coveredNode is SimpleIdentifier) {
|
||||
if (coveredNodeParent is MethodInvocation) {
|
||||
|
|
|
@ -27,7 +27,7 @@ class AddTypeAnnotation extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
var parent = node.parent;
|
||||
if (parent is SimpleFormalParameter) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class ChangeArgumentName extends MultiCorrectionProducer {
|
|||
}
|
||||
|
||||
_NamedExpressionContext? _getNamedParameterNames() {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
var namedExpression = node.parent?.parent;
|
||||
if (node is SimpleIdentifier &&
|
||||
namedExpression is NamedExpression &&
|
||||
|
|
|
@ -53,7 +53,7 @@ class ChangeTo extends CorrectionProducer {
|
|||
}
|
||||
|
||||
Future<void> _proposeAnnotation(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is Annotation) {
|
||||
var name = node.name;
|
||||
if (name.staticElement == null) {
|
||||
|
@ -105,7 +105,7 @@ class ChangeTo extends CorrectionProducer {
|
|||
|
||||
Future<void> _proposeClassOrMixinMember(ChangeBuilder builder,
|
||||
Expression? target, _ElementPredicate predicate) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
var targetIdentifierElement =
|
||||
target is Identifier ? target.staticElement : null;
|
||||
if (node is SimpleIdentifier) {
|
||||
|
@ -139,7 +139,7 @@ class ChangeTo extends CorrectionProducer {
|
|||
}
|
||||
|
||||
Future<void> _proposeFunction(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
// Prepare the optional import prefix name.
|
||||
String? prefixName;
|
||||
|
@ -181,7 +181,7 @@ class ChangeTo extends CorrectionProducer {
|
|||
}
|
||||
|
||||
Future<void> _proposeGetterOrSetter(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
// prepare target
|
||||
Expression? target;
|
||||
|
|
|
@ -21,7 +21,7 @@ class ConvertIntoIsNot extends CorrectionProducer {
|
|||
// Find the is expression
|
||||
var isExpression = node.thisOrAncestorOfType<IsExpression>();
|
||||
if (isExpression == null) {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is PrefixExpression) {
|
||||
var operand = node.operand;
|
||||
if (operand is ParenthesizedExpression) {
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class ConvertQuotes extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleStringLiteral) {
|
||||
await _simpleStringLiteral(builder, node);
|
||||
} else if (node is StringInterpolation) {
|
||||
|
|
|
@ -19,7 +19,7 @@ class ConvertToIfNull extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is ConditionalExpression &&
|
||||
node.offset == errorOffset &&
|
||||
node.length == errorLength) {
|
||||
|
|
|
@ -15,12 +15,12 @@ class ConvertToMultilineString extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
if (node is InterpolationElement) {
|
||||
node = node.parent!;
|
||||
var targetNode = node;
|
||||
if (targetNode is InterpolationElement) {
|
||||
targetNode = targetNode.parent!;
|
||||
}
|
||||
if (node is SingleStringLiteral) {
|
||||
var literal = node;
|
||||
if (targetNode is SingleStringLiteral) {
|
||||
var literal = targetNode;
|
||||
if (!literal.isSynthetic && !literal.isMultiline) {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
var newQuote = literal.isSingleQuoted ? "'''" : '"""';
|
||||
|
|
|
@ -25,18 +25,18 @@ class ConvertToNullAware extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
var parent = node.parent;
|
||||
var targetNode = node;
|
||||
var parent = targetNode.parent;
|
||||
if (parent is BinaryExpression) {
|
||||
var grandParent = parent.parent;
|
||||
if (grandParent is ConditionalExpression) {
|
||||
node = grandParent;
|
||||
targetNode = grandParent;
|
||||
}
|
||||
}
|
||||
if (node is! ConditionalExpression) {
|
||||
if (targetNode is! ConditionalExpression) {
|
||||
return;
|
||||
}
|
||||
var condition = node.condition.unParenthesized;
|
||||
var condition = targetNode.condition.unParenthesized;
|
||||
SimpleIdentifier identifier;
|
||||
Expression nullExpression;
|
||||
Expression nonNullExpression;
|
||||
|
@ -67,11 +67,11 @@ class ConvertToNullAware extends CorrectionProducer {
|
|||
// is the save variable being compared to `null`.
|
||||
//
|
||||
if (condition.operator.type == TokenType.EQ_EQ) {
|
||||
nullExpression = node.thenExpression;
|
||||
nonNullExpression = node.elseExpression;
|
||||
nullExpression = targetNode.thenExpression;
|
||||
nonNullExpression = targetNode.elseExpression;
|
||||
} else if (condition.operator.type == TokenType.BANG_EQ) {
|
||||
nonNullExpression = node.thenExpression;
|
||||
nullExpression = node.elseExpression;
|
||||
nonNullExpression = targetNode.thenExpression;
|
||||
nullExpression = targetNode.elseExpression;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ class ConvertToNullAware extends CorrectionProducer {
|
|||
periodOffset = operator.offset;
|
||||
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addDeletion(range.startStart(node, nonNullExpression));
|
||||
builder.addDeletion(range.startStart(targetNode, nonNullExpression));
|
||||
builder.addSimpleInsertion(periodOffset, '?');
|
||||
builder.addDeletion(range.endEnd(nonNullExpression, node));
|
||||
builder.addDeletion(range.endEnd(nonNullExpression, targetNode));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,12 @@ class ConvertToPackageImport extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
if (node is StringLiteral) {
|
||||
node = node.parent!;
|
||||
var targetNode = node;
|
||||
if (targetNode is StringLiteral) {
|
||||
targetNode = targetNode.parent!;
|
||||
}
|
||||
if (node is ImportDirective) {
|
||||
var importDirective = node;
|
||||
if (targetNode is ImportDirective) {
|
||||
var importDirective = targetNode;
|
||||
var uriSource = importDirective.uriSource;
|
||||
|
||||
// Ignore if invalid URI.
|
||||
|
|
|
@ -24,16 +24,16 @@ class ConvertToRelativeImport extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
if (node is StringLiteral) {
|
||||
node = node.parent!;
|
||||
var targetNode = node;
|
||||
if (targetNode is StringLiteral) {
|
||||
targetNode = targetNode.parent!;
|
||||
}
|
||||
if (node is! ImportDirective) {
|
||||
if (targetNode is! ImportDirective) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore if invalid URI.
|
||||
if (node.uriSource == null) {
|
||||
if (targetNode.uriSource == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ConvertToRelativeImport extends CorrectionProducer {
|
|||
|
||||
Uri importUri;
|
||||
try {
|
||||
var uriContent = node.uriContent;
|
||||
var uriContent = targetNode.uriContent;
|
||||
if (uriContent == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class ConvertToRelativeImport extends CorrectionProducer {
|
|||
from: path.dirname(sourceUri.path),
|
||||
);
|
||||
|
||||
final node_final = node;
|
||||
final node_final = targetNode;
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addSimpleReplacement(
|
||||
range.node(node_final.uri).getExpanded(-1),
|
||||
|
|
|
@ -22,29 +22,29 @@ class CreateClass extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
var targetNode = node;
|
||||
Element? prefixElement;
|
||||
SimpleIdentifier nameNode;
|
||||
ArgumentList? arguments;
|
||||
|
||||
if (node is Annotation) {
|
||||
var name = node.name;
|
||||
arguments = node.arguments;
|
||||
if (targetNode is Annotation) {
|
||||
var name = targetNode.name;
|
||||
arguments = targetNode.arguments;
|
||||
if (name.staticElement != null || arguments == null) {
|
||||
// TODO(brianwilkerson) Consider supporting creating a class when the
|
||||
// arguments are missing by also adding an empty argument list.
|
||||
return;
|
||||
}
|
||||
node = name;
|
||||
targetNode = name;
|
||||
}
|
||||
if (node is SimpleIdentifier) {
|
||||
nameNode = node;
|
||||
} else if (node is PrefixedIdentifier) {
|
||||
prefixElement = node.prefix.staticElement;
|
||||
if (targetNode is SimpleIdentifier) {
|
||||
nameNode = targetNode;
|
||||
} else if (targetNode is PrefixedIdentifier) {
|
||||
prefixElement = targetNode.prefix.staticElement;
|
||||
if (prefixElement == null) {
|
||||
return;
|
||||
}
|
||||
nameNode = node.identifier;
|
||||
nameNode = targetNode.identifier;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class CreateClass extends CorrectionProducer {
|
|||
String? filePath;
|
||||
if (prefixElement == null) {
|
||||
targetUnit = unit.declaredElement!;
|
||||
var enclosingMember = node.thisOrAncestorMatching((node) =>
|
||||
var enclosingMember = targetNode.thisOrAncestorMatching((node) =>
|
||||
node is CompilationUnitMember && node.parent is CompilationUnit);
|
||||
if (enclosingMember == null) {
|
||||
return;
|
||||
|
@ -111,7 +111,7 @@ class CreateClass extends CorrectionProducer {
|
|||
builder.write(suffix);
|
||||
});
|
||||
if (prefixElement == null) {
|
||||
builder.addLinkedPosition(range.node(node), 'NAME');
|
||||
builder.addLinkedPosition(range.node(targetNode), 'NAME');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class CreateMethod extends CorrectionProducer {
|
|||
|
||||
CompilationUnitMember? targetNode;
|
||||
var target = invocation.realTarget;
|
||||
var utils = this.utils;
|
||||
var utilsForTargetNode = utils;
|
||||
if (target is ExtensionOverride) {
|
||||
targetElement = target.staticElement;
|
||||
if (targetElement is ExtensionElement) {
|
||||
|
@ -152,12 +152,13 @@ class CreateMethod extends CorrectionProducer {
|
|||
if (targetResolveResult is! ResolvedUnitResult) {
|
||||
return;
|
||||
}
|
||||
utils = CorrectionUtils(targetResolveResult);
|
||||
utilsForTargetNode = CorrectionUtils(targetResolveResult);
|
||||
}
|
||||
if (targetElement == null || targetNode == null) {
|
||||
return;
|
||||
}
|
||||
var targetLocation = utils.prepareNewMethodLocation(targetNode);
|
||||
var targetLocation =
|
||||
utilsForTargetNode.prepareNewMethodLocation(targetNode);
|
||||
if (targetLocation == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ class CreateMixin extends CorrectionProducer {
|
|||
Future<void> compute(ChangeBuilder builder) async {
|
||||
Element? prefixElement;
|
||||
SimpleIdentifier nameNode;
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
var parent = node.parent;
|
||||
var grandParent = parent?.parent;
|
||||
|
|
|
@ -54,7 +54,7 @@ class DataDriven extends MultiCorrectionProducer {
|
|||
return setsForTests;
|
||||
}
|
||||
var transformSets = TransformSetManager.instance.forLibrary(library);
|
||||
var overrideSet = this.overrideSet;
|
||||
final overrideSet = this.overrideSet;
|
||||
if (overrideSet != null) {
|
||||
transformSets =
|
||||
transformSets.map((set) => set.applyOverrides(overrideSet)).toList();
|
||||
|
|
|
@ -19,7 +19,7 @@ class ExtendClassForMixin extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var diagnostic = this.diagnostic;
|
||||
final diagnostic = this.diagnostic;
|
||||
if (diagnostic == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class FlutterConvertToChildren extends CorrectionProducer {
|
|||
// Find "child: widget" under selection.
|
||||
NamedExpression namedExp;
|
||||
{
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
var parent = node.parent;
|
||||
var parent2 = parent?.parent;
|
||||
if (node is SimpleIdentifier &&
|
||||
|
|
|
@ -52,44 +52,44 @@ class ImportLibrary extends MultiCorrectionProducer {
|
|||
]);
|
||||
}
|
||||
} else if (_importKind == _ImportKind.forTopLevelVariable) {
|
||||
var node = this.node;
|
||||
if (node is Annotation) {
|
||||
var name = node.name;
|
||||
var targetNode = node;
|
||||
if (targetNode is Annotation) {
|
||||
var name = targetNode.name;
|
||||
if (name.staticElement == null) {
|
||||
if (node.arguments != null) {
|
||||
if (targetNode.arguments != null) {
|
||||
return;
|
||||
}
|
||||
node = name;
|
||||
targetNode = name;
|
||||
}
|
||||
}
|
||||
if (node is SimpleIdentifier) {
|
||||
var name = node.name;
|
||||
if (targetNode is SimpleIdentifier) {
|
||||
var name = targetNode.name;
|
||||
yield* _importLibraryForElement(
|
||||
name,
|
||||
const [ElementKind.TOP_LEVEL_VARIABLE],
|
||||
const [TopLevelDeclarationKind.variable]);
|
||||
}
|
||||
} else if (_importKind == _ImportKind.forType) {
|
||||
var node = this.node;
|
||||
if (node is Annotation) {
|
||||
var name = node.name;
|
||||
var targetNode = node;
|
||||
if (targetNode is Annotation) {
|
||||
var name = targetNode.name;
|
||||
if (name.staticElement == null) {
|
||||
if (node.arguments == null) {
|
||||
if (targetNode.arguments == null) {
|
||||
return;
|
||||
}
|
||||
node = name;
|
||||
targetNode = name;
|
||||
}
|
||||
}
|
||||
if (mightBeTypeIdentifier(node)) {
|
||||
var typeName = (node is SimpleIdentifier)
|
||||
? node.name
|
||||
: (node as PrefixedIdentifier).prefix.name;
|
||||
if (mightBeTypeIdentifier(targetNode)) {
|
||||
var typeName = (targetNode is SimpleIdentifier)
|
||||
? targetNode.name
|
||||
: (targetNode as PrefixedIdentifier).prefix.name;
|
||||
yield* _importLibraryForElement(
|
||||
typeName,
|
||||
const [ElementKind.CLASS, ElementKind.FUNCTION_TYPE_ALIAS],
|
||||
const [TopLevelDeclarationKind.type]);
|
||||
} else if (mightBeImplicitConstructor(node)) {
|
||||
var typeName = (node as SimpleIdentifier).name;
|
||||
} else if (mightBeImplicitConstructor(targetNode)) {
|
||||
var typeName = (targetNode as SimpleIdentifier).name;
|
||||
yield* _importLibraryForElement(typeName, const [ElementKind.CLASS],
|
||||
const [TopLevelDeclarationKind.type]);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class InlineInvocation extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is! SimpleIdentifier || node.name != 'add') {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class InsertSemicolon extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var diagnostic = this.diagnostic;
|
||||
final diagnostic = this.diagnostic;
|
||||
if (diagnostic == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class InsertSemicolon extends CorrectionProducer {
|
|||
}
|
||||
|
||||
bool _isAwaitNode() {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
return node is SimpleIdentifier && node.name == 'await';
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class JoinVariableDeclaration extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is SimpleIdentifier) {
|
||||
var parent = node.parent;
|
||||
if (parent is AssignmentExpression &&
|
||||
|
|
|
@ -23,7 +23,7 @@ class MakeFieldNotFinal extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is! SimpleIdentifier) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class MakeFinal extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
var parent = node.parent;
|
||||
var grandParent = parent?.parent;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class MakeReturnTypeNullable extends CorrectionProducer {
|
|||
return;
|
||||
}
|
||||
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is! Expression) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class MakeVariableNotFinal extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is! SimpleIdentifier) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class RemoveDeadCode extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var coveredNode = this.coveredNode;
|
||||
final coveredNode = this.coveredNode;
|
||||
var parent = coveredNode?.parent;
|
||||
|
||||
if (coveredNode is Expression) {
|
||||
|
|
|
@ -18,7 +18,7 @@ class RemoveInterpolationBraces extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is InterpolationExpression) {
|
||||
var right = node.rightBracket;
|
||||
if (right != null) {
|
||||
|
|
|
@ -15,7 +15,7 @@ class RemoveParametersInGetterDeclaration extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is MethodDeclaration) {
|
||||
// Support for the analyzer error.
|
||||
var name = node.name;
|
||||
|
|
|
@ -18,17 +18,17 @@ class RemoveQuestionMark extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
AstNode? node = this.node;
|
||||
if (node is VariableDeclaration) {
|
||||
var parent = node.parent;
|
||||
AstNode? targetNode = node;
|
||||
if (targetNode is VariableDeclaration) {
|
||||
var parent = targetNode.parent;
|
||||
if (parent is VariableDeclarationList) {
|
||||
node = parent.type;
|
||||
targetNode = parent.type;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (node is TypeName) {
|
||||
var questionMark = node.question;
|
||||
if (targetNode is TypeName) {
|
||||
var questionMark = targetNode.question;
|
||||
if (questionMark == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class RemoveThisExpression extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is ConstructorFieldInitializer) {
|
||||
var thisKeyword = node.thisKeyword;
|
||||
if (thisKeyword != null) {
|
||||
|
|
|
@ -18,12 +18,12 @@ class ReplaceNewWithConst extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
AstNode? node = this.node;
|
||||
if (node is ConstructorName) {
|
||||
node = node.parent;
|
||||
AstNode? targetNode = node;
|
||||
if (targetNode is ConstructorName) {
|
||||
targetNode = targetNode.parent;
|
||||
}
|
||||
if (node is InstanceCreationExpression) {
|
||||
final keyword = node.keyword;
|
||||
if (targetNode is InstanceCreationExpression) {
|
||||
final keyword = targetNode.keyword;
|
||||
if (keyword != null) {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addSimpleReplacement(range.token(keyword), 'const');
|
||||
|
|
|
@ -19,7 +19,7 @@ class ReplaceWithConditionalAssignment extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
var ifStatement =
|
||||
node is IfStatement ? node : node.thisOrAncestorOfType<IfStatement>();
|
||||
if (ifStatement == null) {
|
||||
|
|
|
@ -67,6 +67,7 @@ class ShadowField extends CorrectionProducer {
|
|||
builder.addInsertion(offset, (builder) {
|
||||
// TODO(brianwilkerson) Conditionally write a type annotation instead of
|
||||
// 'var' when we're able to discover user preferences.
|
||||
// TODO(brianwilkerson) Consider writing `final` rather than `var`.
|
||||
builder.write('var ');
|
||||
builder.write(fieldName);
|
||||
builder.write(' = this.');
|
||||
|
|
|
@ -19,7 +19,7 @@ class WrapInFuture extends CorrectionProducer {
|
|||
// Extract the information needed to build the edit.
|
||||
//
|
||||
Expression? expression;
|
||||
var node = this.node;
|
||||
final node = this.node;
|
||||
if (node is ReturnStatement) {
|
||||
expression = node.expression;
|
||||
} else if (node is Expression) {
|
||||
|
|
|
@ -73,7 +73,7 @@ class AddTypeParameter extends Change<_Data> {
|
|||
return _TypeArgumentData(typeArguments, parent.argumentList.offset);
|
||||
} else if (parent is MethodDeclaration) {
|
||||
// invalid_override
|
||||
var extendedType = this.extendedType;
|
||||
final extendedType = this.extendedType;
|
||||
if (extendedType != null && !extendedType.validate(context)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class AddTypeParameter extends Change<_Data> {
|
|||
|
||||
void writeParameter(DartEditBuilder builder) {
|
||||
builder.write(name);
|
||||
var extendedType = this.extendedType;
|
||||
final extendedType = this.extendedType;
|
||||
if (extendedType != null) {
|
||||
builder.write(' extends ');
|
||||
extendedType.writeOn(builder, context);
|
||||
|
|
|
@ -114,7 +114,7 @@ extension on MethodDeclaration {
|
|||
/// Return the parameter of this method whose name matches the given [name],
|
||||
/// or `null` if there is no such parameter.
|
||||
FormalParameter? parameterNamed(String name) {
|
||||
var parameters = this.parameters;
|
||||
final parameters = this.parameters;
|
||||
if (parameters != null) {
|
||||
for (var parameter in parameters.parameters) {
|
||||
if (parameter.declaredElement?.name == name) {
|
||||
|
|
|
@ -92,7 +92,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
@override
|
||||
void visitDoStatement(DoStatement node) {
|
||||
super.visitDoStatement(node);
|
||||
var selectedNodes = this.selectedNodes;
|
||||
final selectedNodes = this.selectedNodes;
|
||||
if (_contains(selectedNodes, node.body)) {
|
||||
invalidSelection(
|
||||
"Operation not applicable to a 'do' statement's body and expression.");
|
||||
|
@ -104,7 +104,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
super.visitForStatement(node);
|
||||
var forLoopParts = node.forLoopParts;
|
||||
if (forLoopParts is ForParts) {
|
||||
var selectedNodes = this.selectedNodes;
|
||||
final selectedNodes = this.selectedNodes;
|
||||
bool containsInit;
|
||||
if (forLoopParts is ForPartsWithExpression) {
|
||||
containsInit = _contains(selectedNodes, forLoopParts.initialization);
|
||||
|
@ -132,7 +132,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
@override
|
||||
void visitSwitchStatement(SwitchStatement node) {
|
||||
super.visitSwitchStatement(node);
|
||||
var selectedNodes = this.selectedNodes;
|
||||
final selectedNodes = this.selectedNodes;
|
||||
List<SwitchMember> switchMembers = node.members;
|
||||
for (var selectedNode in selectedNodes) {
|
||||
if (switchMembers.contains(selectedNode)) {
|
||||
|
@ -146,7 +146,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
@override
|
||||
void visitTryStatement(TryStatement node) {
|
||||
super.visitTryStatement(node);
|
||||
var firstSelectedNode = this.firstSelectedNode;
|
||||
final firstSelectedNode = this.firstSelectedNode;
|
||||
if (firstSelectedNode != null) {
|
||||
if (firstSelectedNode == node.body ||
|
||||
firstSelectedNode == node.finallyBlock) {
|
||||
|
@ -169,7 +169,7 @@ class StatementAnalyzer extends SelectionAnalyzer {
|
|||
@override
|
||||
void visitWhileStatement(WhileStatement node) {
|
||||
super.visitWhileStatement(node);
|
||||
var selectedNodes = this.selectedNodes;
|
||||
final selectedNodes = this.selectedNodes;
|
||||
if (_contains(selectedNodes, node.condition) &&
|
||||
_contains(selectedNodes, node.body)) {
|
||||
invalidSelection(
|
||||
|
|
|
@ -55,7 +55,7 @@ class RefactoringStatus {
|
|||
/// Returns the message of the [RefactoringProblem] with highest severity;
|
||||
/// may be `null` if no problems.
|
||||
String? get message {
|
||||
var problem = this.problem;
|
||||
final problem = this.problem;
|
||||
if (problem == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -168,15 +168,15 @@ class PubPackageService {
|
|||
/// Begin a request to pre-load the package name list.
|
||||
void beginPackageNamePreload() {
|
||||
// If first time, try to read from disk.
|
||||
var packageCache = this.packageCache;
|
||||
if (packageCache == null) {
|
||||
packageCache ??= readDiskCache() ?? PackageDetailsCache.empty();
|
||||
this.packageCache = packageCache;
|
||||
var cache = packageCache;
|
||||
if (cache == null) {
|
||||
cache ??= readDiskCache() ?? PackageDetailsCache.empty();
|
||||
packageCache = cache;
|
||||
}
|
||||
|
||||
// If there is no queued request, initialize one when the current cache expires.
|
||||
_nextPackageNameListRequestTimer ??=
|
||||
Timer(packageCache.cacheTimeRemaining, _fetchFromServer);
|
||||
Timer(cache.cacheTimeRemaining, _fetchFromServer);
|
||||
}
|
||||
|
||||
/// Gets the cached package details for package [packageName].
|
||||
|
|
|
@ -121,7 +121,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
|||
Future<SourceChange> createChange() {
|
||||
var change = SourceChange(refactoringName);
|
||||
// prepare occurrences
|
||||
List<SourceRange> occurrences;
|
||||
late final List<SourceRange> occurrences;
|
||||
if (extractAll) {
|
||||
occurrences = this.occurrences;
|
||||
} else {
|
||||
|
@ -130,7 +130,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
|||
occurrences.sort((a, b) => a.offset - b.offset);
|
||||
// If the whole expression of a statement is selected, like '1 + 2',
|
||||
// then convert it into a variable declaration statement.
|
||||
var singleExpression = this.singleExpression;
|
||||
final singleExpression = this.singleExpression;
|
||||
if (singleExpression != null &&
|
||||
singleExpression.parent is ExpressionStatement &&
|
||||
occurrences.length == 1) {
|
||||
|
@ -490,7 +490,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl
|
|||
|
||||
// prepare selection
|
||||
String? selectionSource;
|
||||
var singleExpression = this.singleExpression;
|
||||
final singleExpression = this.singleExpression;
|
||||
if (singleExpression != null) {
|
||||
var tokens = TokenUtils.getNodeTokens(singleExpression);
|
||||
selectionSource = _encodeExpressionTokens(singleExpression, tokens);
|
||||
|
|
|
@ -93,7 +93,7 @@ class RenameLocalRefactoringImpl extends RenameRefactoringImpl {
|
|||
|
||||
/// Fills [elements] with [Element]s to rename.
|
||||
Future _prepareElements() async {
|
||||
var element = this.element;
|
||||
final element = this.element;
|
||||
if (element is ParameterElement && element.isNamed) {
|
||||
elements = await getHierarchyNamedParameters(searchEngine, element);
|
||||
} else {
|
||||
|
|
|
@ -117,7 +117,7 @@ extension FunctionBodyExtensions on FunctionBody {
|
|||
|
||||
extension MethodDeclarationExtension on MethodDeclaration {
|
||||
Token? get propertyKeywordGet {
|
||||
var propertyKeyword = this.propertyKeyword;
|
||||
final propertyKeyword = this.propertyKeyword;
|
||||
return propertyKeyword != null && propertyKeyword.keyword == Keyword.GET
|
||||
? propertyKeyword
|
||||
: null;
|
||||
|
@ -126,7 +126,7 @@ extension MethodDeclarationExtension on MethodDeclaration {
|
|||
|
||||
extension VariableDeclarationListExtension on VariableDeclarationList {
|
||||
Token? get finalKeyword {
|
||||
var keyword = this.keyword;
|
||||
final keyword = this.keyword;
|
||||
return keyword != null && keyword.keyword == Keyword.FINAL ? keyword : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ class _RequestStatisticsItem {
|
|||
_RequestStatisticsItem(this.name, {this.timeValue});
|
||||
|
||||
Map<String, Object> toJson() {
|
||||
var timeValue = this.timeValue;
|
||||
final timeValue = this.timeValue;
|
||||
if (timeValue != null) {
|
||||
return {
|
||||
'name': name,
|
||||
|
|
|
@ -379,8 +379,8 @@ class MatchesJsonObject extends _RecursiveMatcher {
|
|||
mismatches.add(simpleDescription('is not a map'));
|
||||
return;
|
||||
}
|
||||
var requiredFields = this.requiredFields;
|
||||
var optionalFields = this.optionalFields;
|
||||
final requiredFields = this.requiredFields;
|
||||
final optionalFields = this.optionalFields;
|
||||
if (requiredFields != null) {
|
||||
requiredFields.forEach((String key, Matcher valueMatcher) {
|
||||
if (!item.containsKey(key)) {
|
||||
|
|
|
@ -799,7 +799,7 @@ main() {
|
|||
}
|
||||
''');
|
||||
await findElementReferences('ppp;', false);
|
||||
var searchElement = this.searchElement!;
|
||||
final searchElement = this.searchElement!;
|
||||
expect(searchElement.kind, ElementKind.PREFIX);
|
||||
expect(searchElement.name, 'ppp');
|
||||
expect(searchElement.location!.startLine, 1);
|
||||
|
|
|
@ -1760,11 +1760,11 @@ void f(bool p, bool p2, bool p3) {
|
|||
var status = await refactoring.checkInitialConditions();
|
||||
assertRefactoringStatusOK(status);
|
||||
// configure
|
||||
var deleteSource = this.deleteSource;
|
||||
final deleteSource = this.deleteSource;
|
||||
if (deleteSource != null) {
|
||||
refactoring.deleteSource = deleteSource;
|
||||
}
|
||||
var inlineAll = this.inlineAll;
|
||||
final inlineAll = this.inlineAll;
|
||||
if (inlineAll != null) {
|
||||
refactoring.inlineAll = inlineAll;
|
||||
}
|
||||
|
|
|
@ -287,8 +287,8 @@ class DiffRecord {
|
|||
|
||||
/// Return `true` if this diff applies to a file with the given name.
|
||||
bool isFor(String fileName) {
|
||||
var srcPath = this.srcPath;
|
||||
var dstPath = this.dstPath;
|
||||
final srcPath = this.srcPath;
|
||||
final dstPath = this.dstPath;
|
||||
return (srcPath != null && fileName == path.basename(srcPath)) ||
|
||||
(dstPath != null && fileName == path.basename(dstPath));
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class ExpectedError {
|
|||
if (message != null && error.message != message) {
|
||||
return false;
|
||||
}
|
||||
var messageContains = this.messageContains;
|
||||
final messageContains = this.messageContains;
|
||||
if (messageContains != null &&
|
||||
error.message.contains(messageContains) != true) {
|
||||
return false;
|
||||
|
|
|
@ -436,7 +436,7 @@ class CompletionMetrics {
|
|||
/// Perform any operations required in order to revert computing the kind of
|
||||
/// completions represented by this metrics collector.
|
||||
void disable() {
|
||||
var disableFunction = this.disableFunction;
|
||||
final disableFunction = this.disableFunction;
|
||||
if (disableFunction != null) {
|
||||
disableFunction();
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ class CompletionMetrics {
|
|||
/// Perform any initialization required in order to compute the kind of
|
||||
/// completions represented by this metrics collector.
|
||||
void enable() {
|
||||
var enableFunction = this.enableFunction;
|
||||
final enableFunction = this.enableFunction;
|
||||
if (enableFunction != null) {
|
||||
enableFunction();
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ function selectEntryGroup(pageStart) {
|
|||
/// Write the entries in the instrumentation log to the given [sink].
|
||||
void _writeLeftColumn(StringSink sink) {
|
||||
var length = entries.length;
|
||||
var pageLength = this.pageLength;
|
||||
final pageLength = this.pageLength;
|
||||
var pageEnd =
|
||||
pageLength == null ? length : math.min(pageStart + pageLength, length);
|
||||
//
|
||||
|
|
|
@ -202,7 +202,7 @@ class Notification extends ApiNode {
|
|||
value: '$domainName.$event')
|
||||
];
|
||||
|
||||
var params = this.params;
|
||||
final params = this.params;
|
||||
if (params != null) {
|
||||
fields.add(TypeObjectField('params', params, null));
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ class Request extends ApiNode {
|
|||
value: '$domainName.$method')
|
||||
];
|
||||
|
||||
var params = this.params;
|
||||
final params = this.params;
|
||||
if (params != null) {
|
||||
fields.add(TypeObjectField('params', params, null));
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ class Request extends ApiNode {
|
|||
optional: true)
|
||||
];
|
||||
|
||||
var result = this.result;
|
||||
final result = this.result;
|
||||
if (result != null) {
|
||||
fields.add(TypeObjectField('result', result, null));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue