Version 2.14.0-41.0.dev
Merge commit '7b9cfb48377914c1339b5ffeab0eb22b791b0282' into 'dev'
diff --git a/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart b/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart
index 74a310a..808f5f9 100644
--- a/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/scanner/token.dart
@@ -1281,10 +1281,12 @@
'AMPERSAND_AMPERSAND_EQ',
ASSIGNMENT_PRECEDENCE,
AMPERSAND_AMPERSAND_EQ_TOKEN,
+ binaryOperatorOfCompoundAssignment: TokenType.AMPERSAND_AMPERSAND,
isOperator: true);
static const TokenType AMPERSAND_EQ = const TokenType(
'&=', 'AMPERSAND_EQ', ASSIGNMENT_PRECEDENCE, AMPERSAND_EQ_TOKEN,
+ binaryOperatorOfCompoundAssignment: TokenType.AMPERSAND,
isOperator: true);
static const TokenType AT =
@@ -1312,11 +1314,11 @@
// This is not yet part of the language and not supported by fasta
static const TokenType BAR_BAR_EQ = const TokenType(
'||=', 'BAR_BAR_EQ', ASSIGNMENT_PRECEDENCE, BAR_BAR_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.BAR_BAR, isOperator: true);
static const TokenType BAR_EQ = const TokenType(
'|=', 'BAR_EQ', ASSIGNMENT_PRECEDENCE, BAR_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.BAR, isOperator: true);
static const TokenType COLON =
const TokenType(':', 'COLON', NO_PRECEDENCE, COLON_TOKEN);
@@ -1330,7 +1332,7 @@
static const TokenType CARET_EQ = const TokenType(
'^=', 'CARET_EQ', ASSIGNMENT_PRECEDENCE, CARET_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.CARET, isOperator: true);
static const TokenType CLOSE_CURLY_BRACKET = const TokenType(
'}', 'CLOSE_CURLY_BRACKET', NO_PRECEDENCE, CLOSE_CURLY_BRACKET_TOKEN);
@@ -1372,7 +1374,7 @@
static const TokenType GT_GT_EQ = const TokenType(
'>>=', 'GT_GT_EQ', ASSIGNMENT_PRECEDENCE, GT_GT_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.GT_GT, isOperator: true);
static const TokenType GT_GT_GT = const TokenType(
'>>>', 'GT_GT_GT', SHIFT_PRECEDENCE, GT_GT_GT_TOKEN,
@@ -1380,7 +1382,7 @@
static const TokenType GT_GT_GT_EQ = const TokenType(
'>>>=', 'GT_GT_GT_EQ', ASSIGNMENT_PRECEDENCE, GT_GT_GT_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.GT_GT_GT, isOperator: true);
static const TokenType HASH =
const TokenType('#', 'HASH', NO_PRECEDENCE, HASH_TOKEN);
@@ -1407,7 +1409,7 @@
static const TokenType LT_LT_EQ = const TokenType(
'<<=', 'LT_LT_EQ', ASSIGNMENT_PRECEDENCE, LT_LT_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.LT_LT, isOperator: true);
static const TokenType MINUS = const TokenType(
'-', 'MINUS', ADDITIVE_PRECEDENCE, MINUS_TOKEN,
@@ -1415,7 +1417,7 @@
static const TokenType MINUS_EQ = const TokenType(
'-=', 'MINUS_EQ', ASSIGNMENT_PRECEDENCE, MINUS_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.MINUS, isOperator: true);
static const TokenType MINUS_MINUS = const TokenType(
'--', 'MINUS_MINUS', POSTFIX_PRECEDENCE, MINUS_MINUS_TOKEN,
@@ -1436,7 +1438,7 @@
static const TokenType PERCENT_EQ = const TokenType(
'%=', 'PERCENT_EQ', ASSIGNMENT_PRECEDENCE, PERCENT_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.PERCENT, isOperator: true);
static const TokenType PERIOD =
const TokenType('.', 'PERIOD', SELECTOR_PRECEDENCE, PERIOD_TOKEN);
@@ -1451,7 +1453,7 @@
static const TokenType PLUS_EQ = const TokenType(
'+=', 'PLUS_EQ', ASSIGNMENT_PRECEDENCE, PLUS_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.PLUS, isOperator: true);
static const TokenType PLUS_PLUS = const TokenType(
'++', 'PLUS_PLUS', POSTFIX_PRECEDENCE, PLUS_PLUS_TOKEN,
@@ -1471,6 +1473,7 @@
static const TokenType QUESTION_QUESTION_EQ = const TokenType('??=',
'QUESTION_QUESTION_EQ', ASSIGNMENT_PRECEDENCE, QUESTION_QUESTION_EQ_TOKEN,
+ binaryOperatorOfCompoundAssignment: TokenType.QUESTION_QUESTION,
isOperator: true);
static const TokenType SEMICOLON =
@@ -1482,7 +1485,7 @@
static const TokenType SLASH_EQ = const TokenType(
'/=', 'SLASH_EQ', ASSIGNMENT_PRECEDENCE, SLASH_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.SLASH, isOperator: true);
static const TokenType STAR = const TokenType(
'*', 'STAR', MULTIPLICATIVE_PRECEDENCE, STAR_TOKEN,
@@ -1490,7 +1493,7 @@
static const TokenType STAR_EQ = const TokenType(
'*=', 'STAR_EQ', ASSIGNMENT_PRECEDENCE, STAR_EQ_TOKEN,
- isOperator: true);
+ binaryOperatorOfCompoundAssignment: TokenType.STAR, isOperator: true);
static const TokenType STRING_INTERPOLATION_EXPRESSION = const TokenType(
'\${',
@@ -1514,6 +1517,7 @@
static const TokenType TILDE_SLASH_EQ = const TokenType(
'~/=', 'TILDE_SLASH_EQ', ASSIGNMENT_PRECEDENCE, TILDE_SLASH_EQ_TOKEN,
+ binaryOperatorOfCompoundAssignment: TokenType.TILDE_SLASH,
isOperator: true);
static const TokenType BACKPING =
@@ -1647,6 +1651,12 @@
//TokenType.RECOVERY,
];
+ /**
+ * The binary operator that is invoked by this compound assignment operator,
+ * or `null` otherwise.
+ */
+ final TokenType? binaryOperatorOfCompoundAssignment;
+
final int kind;
/**
@@ -1700,9 +1710,10 @@
final String? stringValue;
const TokenType(this.lexeme, this.name, this.precedence, this.kind,
- {this.isModifier: false,
- this.isOperator: false,
+ {this.binaryOperatorOfCompoundAssignment,
this.isBinaryOperator: false,
+ this.isModifier: false,
+ this.isOperator: false,
this.isTopLevelKeyword: false,
this.isUserDefinableOperator: false,
String? stringValue: 'unspecified'})
diff --git a/pkg/analysis_server/benchmark/integration/input_converter.dart b/pkg/analysis_server/benchmark/integration/input_converter.dart
index 0f86919..da47e28 100644
--- a/pkg/analysis_server/benchmark/integration/input_converter.dart
+++ b/pkg/analysis_server/benchmark/integration/input_converter.dart
@@ -253,51 +253,62 @@
/// The number of lines read before the underlying converter was determined
/// or the end of file was reached.
- int headerLineCount = 0;
+ int _headerLineCount = 0;
/// The underlying converter used to translate lines into operations
/// or `null` if it has not yet been determined.
- Converter<String, Operation?>? converter;
+ Converter<String, Operation?>? _converter;
- /// [active] is `true` if converting lines to operations
+ /// [_active] is `true` if converting lines to operations
/// or `false` if an exception has occurred.
- bool active = true;
+ bool _active = true;
InputConverter(this.tmpSrcDirPath, this.srcPathMap);
@override
Operation? convert(String line) {
- if (!active) {
+ if (!_active) {
return null;
}
- var converter = this.converter;
- if (converter != null) {
- try {
- return converter.convert(line);
- } catch (e) {
- active = false;
- rethrow;
+ try {
+ var converter = _getConverter(line);
+ if (converter == null) {
+ logger.log(Level.INFO, 'skipped input line: $line');
+ return null;
}
- }
- if (headerLineCount == 20) {
- throw 'Failed to determine input file format';
- }
- if (InstrumentationInputConverter.isFormat(line)) {
- converter = InstrumentationInputConverter(tmpSrcDirPath, srcPathMap);
- } else if (LogFileInputConverter.isFormat(line)) {
- converter = LogFileInputConverter(tmpSrcDirPath, srcPathMap);
- }
- if (converter != null) {
return converter.convert(line);
+ } catch (_) {
+ _active = false;
+ rethrow;
}
- logger.log(Level.INFO, 'skipped input line: $line');
- return null;
}
@override
_InputSink startChunkedConversion(outSink) {
return _InputSink(this, outSink);
}
+
+ /// Return the previously determined converter, or determine it from the
+ /// given [line]. Return `null` if cannot be determined yet. Throw an
+ /// exception if could not be determined after some number of tries.
+ Converter<String, Operation?>? _getConverter(String line) {
+ var converter = _converter;
+ if (converter != null) {
+ return converter;
+ }
+
+ if (_headerLineCount++ == 20) {
+ throw 'Failed to determine input file format';
+ }
+
+ if (InstrumentationInputConverter.isFormat(line)) {
+ _converter = InstrumentationInputConverter(tmpSrcDirPath, srcPathMap);
+ } else if (LogFileInputConverter.isFormat(line)) {
+ _converter = LogFileInputConverter(tmpSrcDirPath, srcPathMap);
+ }
+
+ return _converter;
+ }
}
/// A container of [PathMapEntry]s used to translate a source path in the log
diff --git a/pkg/analysis_server/benchmark/integration/instrumentation_input_converter.dart b/pkg/analysis_server/benchmark/integration/instrumentation_input_converter.dart
index 037c9b0..a701840 100644
--- a/pkg/analysis_server/benchmark/integration/instrumentation_input_converter.dart
+++ b/pkg/analysis_server/benchmark/integration/instrumentation_input_converter.dart
@@ -32,7 +32,7 @@
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;
diff --git a/pkg/analysis_server/lib/protocol/protocol.dart b/pkg/analysis_server/lib/protocol/protocol.dart
index e9d5c9d..9d15dac 100644
--- a/pkg/analysis_server/lib/protocol/protocol.dart
+++ b/pkg/analysis_server/lib/protocol/protocol.dart
@@ -46,7 +46,7 @@
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 @@
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 @@
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;
}
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index 4c5becb..57d87fe 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -1227,7 +1227,7 @@
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 @@
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 @@
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;
}
diff --git a/pkg/analysis_server/lib/src/lsp/mapping.dart b/pkg/analysis_server/lib/src/lsp/mapping.dart
index f9d8355..fa51e73 100644
--- a/pkg/analysis_server/lib/src/lsp/mapping.dart
+++ b/pkg/analysis_server/lib/src/lsp/mapping.dart
@@ -364,12 +364,7 @@
supportsDeprecatedFlag || supportsDeprecatedTag),
deprecated:
supportsDeprecatedFlag && declaration.isDeprecated ? true : null,
- // Relevance is a number, highest being best. LSP does text sort so subtract
- // from a large number so that a text sort will result in the correct order.
- // 555 -> 999455
- // 10 -> 999990
- // 1 -> 999999
- sortText: (1000000 - itemRelevance).toString(),
+ sortText: relevanceToSortText(itemRelevance),
filterText: completion != label
? completion
: null, // filterText uses label if not set
@@ -776,6 +771,22 @@
}
}
+/// Converts a numeric relevance to a sortable string.
+///
+/// The servers relevance value is a number with highest being best. LSP uses a
+/// a string sort on the `sortText` field. Subtracting the relevance from a large
+/// number will produce text that will sort correctly.
+///
+/// Relevance can be 0, so it's important to subtract from a number like 999
+/// and not 1000 or the 0 relevance items will sort at the top instead of the
+/// bottom.
+///
+/// 555 -> 9999999 - 555 -> 9 999 444
+/// 10 -> 9999999 - 10 -> 9 999 989
+/// 1 -> 9999999 - 1 -> 9 999 998
+/// 0 -> 9999999 - 0 -> 9 999 999
+String relevanceToSortText(int relevance) => (9999999 - relevance).toString();
+
lsp.Location? searchResultToLocation(
server.SearchResult result, server.LineInfo? lineInfo) {
final location = result.location;
@@ -957,12 +968,7 @@
deprecated: supportsCompletionDeprecatedFlag && suggestion.isDeprecated
? true
: null,
- // Relevance is a number, highest being best. LSP does text sort so subtract
- // from a large number so that a text sort will result in the correct order.
- // 555 -> 999455
- // 10 -> 999990
- // 1 -> 999999
- sortText: (1000000 - suggestion.relevance).toString(),
+ sortText: relevanceToSortText(suggestion.relevance),
filterText: filterText != label
? filterText
: null, // filterText uses label if not set
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
index 08f8fb6..07c4956 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
@@ -901,7 +901,7 @@
/// 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.');
}
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
index e47f4f0..05f7592 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
@@ -133,7 +133,7 @@
/// 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 @@
/// 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 @@
/// 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 @@
/// [_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 @@
/// 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) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
index 66989f9..1ea7a5a 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart
@@ -199,7 +199,8 @@
}
void _addIncludedSuggestionRelevanceTags(DartCompletionRequestImpl request) {
- var includedSuggestionRelevanceTags = this.includedSuggestionRelevanceTags!;
+ final includedSuggestionRelevanceTags =
+ this.includedSuggestionRelevanceTags!;
var location = request.opType.completionLocation;
if (location != null) {
var locationTable = elementKindRelevance[location];
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
index f6d2263..7da38ea 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/feature_computer.dart
@@ -1015,7 +1015,7 @@
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) {
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
index dafe115..d44cb1a 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
@@ -56,7 +56,7 @@
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 @@
@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 @@
@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 @@
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) {
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 c21bf0b..0c52fb4 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
@@ -373,7 +373,7 @@
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;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_async.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_async.dart
index 289a537..32499c0 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_async.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_async.dart
@@ -46,7 +46,7 @@
} 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);
});
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_const.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_const.dart
index 84311ad..cd0bf2a 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_const.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_const.dart
@@ -17,27 +17,27 @@
@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 ');
});
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_late.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_late.dart
index cc3293b..733d4ea 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_late.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_late.dart
@@ -21,7 +21,7 @@
if (!libraryElement.isNonNullableByDefault) {
return;
}
- var node = this.node;
+ final node = this.node;
if (node is SimpleIdentifier) {
var variable = node.parent;
var variableList = variable?.parent;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_parameter_named.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_parameter_named.dart
index da82a33..0dd82a1 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_parameter_named.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_parameter_named.dart
@@ -21,7 +21,7 @@
@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;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_required_argument.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_required_argument.dart
index c3aa42d..84d563c 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_required_argument.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_required_argument.dart
@@ -42,7 +42,7 @@
}
}
- var diagnostic = this.diagnostic;
+ final diagnostic = this.diagnostic;
if (diagnostic == null) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_ne_null.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_ne_null.dart
index d5facaf..970dedf 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_ne_null.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_ne_null.dart
@@ -20,7 +20,7 @@
@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;
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 11bf784..33c5944 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
@@ -23,7 +23,7 @@
return;
}
Expression? target;
- var coveredNode = this.coveredNode;
+ final coveredNode = this.coveredNode;
var coveredNodeParent = coveredNode?.parent;
if (coveredNode is SimpleIdentifier) {
if (coveredNodeParent is MethodInvocation) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart
index 08bd321..8a89c1f 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_type_annotation.dart
@@ -27,7 +27,7 @@
@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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/change_argument_name.dart b/pkg/analysis_server/lib/src/services/correction/dart/change_argument_name.dart
index 75c187f..0442afb 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/change_argument_name.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/change_argument_name.dart
@@ -53,7 +53,7 @@
}
_NamedExpressionContext? _getNamedParameterNames() {
- var node = this.node;
+ final node = this.node;
var namedExpression = node.parent?.parent;
if (node is SimpleIdentifier &&
namedExpression is NamedExpression &&
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/change_to.dart b/pkg/analysis_server/lib/src/services/correction/dart/change_to.dart
index 0f81d93..0ec47fc 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/change_to.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/change_to.dart
@@ -53,7 +53,7 @@
}
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 @@
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 @@
}
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 @@
}
Future<void> _proposeGetterOrSetter(ChangeBuilder builder) async {
- var node = this.node;
+ final node = this.node;
if (node is SimpleIdentifier) {
// prepare target
Expression? target;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_into_is_not.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_into_is_not.dart
index e84c81f..b81db26 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_into_is_not.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_into_is_not.dart
@@ -21,7 +21,7 @@
// 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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_quotes.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_quotes.dart
index 5e45165..67cfb7d 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_quotes.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_quotes.dart
@@ -20,7 +20,7 @@
@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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_null.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_null.dart
index d8ca1d2..24ba7dd 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_null.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_null.dart
@@ -19,7 +19,7 @@
@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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_multiline_string.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_multiline_string.dart
index 51861d9..0807076 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_multiline_string.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_multiline_string.dart
@@ -15,12 +15,12 @@
@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 ? "'''" : '"""';
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware.dart
index 013e4fe..da0f269 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_null_aware.dart
@@ -25,18 +25,18 @@
@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 @@
// 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 @@
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));
});
}
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart
index a40b1b2..b9020ea 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_package_import.dart
@@ -23,12 +23,12 @@
@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.
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart
index 48a99d7..7b97d09 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_relative_import.dart
@@ -24,16 +24,16 @@
@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 @@
Uri importUri;
try {
- var uriContent = node.uriContent;
+ var uriContent = targetNode.uriContent;
if (uriContent == null) {
return;
}
@@ -75,7 +75,7 @@
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),
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_class.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_class.dart
index 833a8db..9c01f35 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_class.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_class.dart
@@ -22,29 +22,29 @@
@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 @@
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 @@
builder.write(suffix);
});
if (prefixElement == null) {
- builder.addLinkedPosition(range.node(node), 'NAME');
+ builder.addLinkedPosition(range.node(targetNode), 'NAME');
}
});
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
index a76ce2a..2edd32e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_method.dart
@@ -95,7 +95,7 @@
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 @@
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;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_mixin.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_mixin.dart
index 14c4598..dbc9020 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_mixin.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_mixin.dart
@@ -24,7 +24,7 @@
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;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/data_driven.dart b/pkg/analysis_server/lib/src/services/correction/dart/data_driven.dart
index 5261db3..ed399ac 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/data_driven.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/data_driven.dart
@@ -54,7 +54,7 @@
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();
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/extend_class_for_mixin.dart b/pkg/analysis_server/lib/src/services/correction/dart/extend_class_for_mixin.dart
index 52ed499..b9557d0 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/extend_class_for_mixin.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/extend_class_for_mixin.dart
@@ -19,7 +19,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var diagnostic = this.diagnostic;
+ final diagnostic = this.diagnostic;
if (diagnostic == null) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/flutter_convert_to_children.dart b/pkg/analysis_server/lib/src/services/correction/dart/flutter_convert_to_children.dart
index 1c0f0ca..755c644 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/flutter_convert_to_children.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/flutter_convert_to_children.dart
@@ -18,7 +18,7 @@
// 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 &&
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart b/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart
index 2274c6e..1499ae6 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/import_library.dart
@@ -52,44 +52,44 @@
]);
}
} 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]);
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/inline_invocation.dart b/pkg/analysis_server/lib/src/services/correction/dart/inline_invocation.dart
index c2e0711..c784ce4 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/inline_invocation.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/inline_invocation.dart
@@ -29,7 +29,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = this.node;
+ final node = this.node;
if (node is! SimpleIdentifier || node.name != 'add') {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/insert_semicolon.dart b/pkg/analysis_server/lib/src/services/correction/dart/insert_semicolon.dart
index b50d526..c2bf057 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/insert_semicolon.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/insert_semicolon.dart
@@ -14,7 +14,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var diagnostic = this.diagnostic;
+ final diagnostic = this.diagnostic;
if (diagnostic == null) {
return;
}
@@ -32,7 +32,7 @@
}
bool _isAwaitNode() {
- var node = this.node;
+ final node = this.node;
return node is SimpleIdentifier && node.name == 'await';
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/join_variable_declaration.dart b/pkg/analysis_server/lib/src/services/correction/dart/join_variable_declaration.dart
index 015acb8..8b97a1d 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/join_variable_declaration.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/join_variable_declaration.dart
@@ -16,7 +16,7 @@
@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 &&
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/make_field_not_final.dart b/pkg/analysis_server/lib/src/services/correction/dart/make_field_not_final.dart
index a2c636a..374d184 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/make_field_not_final.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/make_field_not_final.dart
@@ -23,7 +23,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = this.node;
+ final node = this.node;
if (node is! SimpleIdentifier) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/make_final.dart b/pkg/analysis_server/lib/src/services/correction/dart/make_final.dart
index 3ff063a..aba8e02 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/make_final.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/make_final.dart
@@ -19,7 +19,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = this.node;
+ final node = this.node;
var parent = node.parent;
var grandParent = parent?.parent;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart b/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart
index 20b6cac..2f2107d 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/make_return_type_nullable.dart
@@ -20,7 +20,7 @@
return;
}
- var node = this.node;
+ final node = this.node;
if (node is! Expression) {
return;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/make_variable_not_final.dart b/pkg/analysis_server/lib/src/services/correction/dart/make_variable_not_final.dart
index 0ac959f..f3f1695 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/make_variable_not_final.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/make_variable_not_final.dart
@@ -23,7 +23,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var node = this.node;
+ final node = this.node;
if (node is! SimpleIdentifier) {
return;
}
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 3c37c95..9f349e7 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
@@ -16,7 +16,7 @@
@override
Future<void> compute(ChangeBuilder builder) async {
- var coveredNode = this.coveredNode;
+ final coveredNode = this.coveredNode;
var parent = coveredNode?.parent;
if (coveredNode is Expression) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_interpolation_braces.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_interpolation_braces.dart
index d63185f..c5ed780 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_interpolation_braces.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_interpolation_braces.dart
@@ -18,7 +18,7 @@
@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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_parameters_in_getter_declaration.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_parameters_in_getter_declaration.dart
index cf13f53..236ac60 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_parameters_in_getter_declaration.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_parameters_in_getter_declaration.dart
@@ -15,7 +15,7 @@
@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;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_question_mark.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_question_mark.dart
index 96e0280..7039b72 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_question_mark.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_question_mark.dart
@@ -18,17 +18,17 @@
@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;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_this_expression.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_this_expression.dart
index 68f1350..c9c41ae 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_this_expression.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_this_expression.dart
@@ -18,7 +18,7 @@
@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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_new_with_const.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_new_with_const.dart
index e8db9a3..fda7453 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_new_with_const.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_new_with_const.dart
@@ -18,12 +18,12 @@
@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');
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_with_conditional_assignment.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_with_conditional_assignment.dart
index 9d69d50..acdd6a4 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_with_conditional_assignment.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_with_conditional_assignment.dart
@@ -19,7 +19,7 @@
@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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/shadow_field.dart b/pkg/analysis_server/lib/src/services/correction/dart/shadow_field.dart
index c46f159..b18b4ef 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/shadow_field.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/shadow_field.dart
@@ -67,6 +67,7 @@
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.');
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/wrap_in_future.dart b/pkg/analysis_server/lib/src/services/correction/dart/wrap_in_future.dart
index c1892ff..cbe9212 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/wrap_in_future.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/wrap_in_future.dart
@@ -19,7 +19,7 @@
// 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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart
index 86dcc3b..1631742 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/add_type_parameter.dart
@@ -73,7 +73,7 @@
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 @@
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);
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/rename_parameter.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/rename_parameter.dart
index 729692e..1072578 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/rename_parameter.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/rename_parameter.dart
@@ -114,7 +114,7 @@
/// 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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart b/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
index 320aae7..9f1c68a 100644
--- a/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
+++ b/pkg/analysis_server/lib/src/services/correction/statement_analyzer.dart
@@ -92,7 +92,7 @@
@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 @@
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 @@
@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 @@
@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 @@
@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(
diff --git a/pkg/analysis_server/lib/src/services/correction/status.dart b/pkg/analysis_server/lib/src/services/correction/status.dart
index d148d34..9909658 100644
--- a/pkg/analysis_server/lib/src/services/correction/status.dart
+++ b/pkg/analysis_server/lib/src/services/correction/status.dart
@@ -55,7 +55,7 @@
/// 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;
}
diff --git a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
index f9c3c66..257fa24 100644
--- a/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
+++ b/pkg/analysis_server/lib/src/services/kythe/kythe_visitors.dart
@@ -440,7 +440,7 @@
void visitEnumConstantDeclaration(EnumConstantDeclaration node) {
// constant node
var constDeclVName =
- addNodeAndFacts(schema.CONSTANT_KIND, element: node.declaredElement!);
+ addNodeAndFacts(schema.CONSTANT_KIND, element: node.declaredElement);
// anchor- defines/binding, defines
addAnchorEdgesContainingEdge(
diff --git a/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart b/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart
index 7d7ebbe..d0990db 100644
--- a/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart
+++ b/pkg/analysis_server/lib/src/services/pub/pub_package_service.dart
@@ -168,15 +168,15 @@
/// 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].
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
index 16ca48b..2432c5b 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
@@ -121,7 +121,7 @@
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 @@
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 @@
// prepare selection
String? selectionSource;
- var singleExpression = this.singleExpression;
+ final singleExpression = this.singleExpression;
if (singleExpression != null) {
var tokens = TokenUtils.getNodeTokens(singleExpression);
selectionSource = _encodeExpressionTokens(singleExpression, tokens);
diff --git a/pkg/analysis_server/lib/src/services/refactoring/rename_local.dart b/pkg/analysis_server/lib/src/services/refactoring/rename_local.dart
index eb2745e..6fe772e 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/rename_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/rename_local.dart
@@ -93,7 +93,7 @@
/// 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 {
diff --git a/pkg/analysis_server/lib/src/utilities/extensions/ast.dart b/pkg/analysis_server/lib/src/utilities/extensions/ast.dart
index 92403c0..af573e9 100644
--- a/pkg/analysis_server/lib/src/utilities/extensions/ast.dart
+++ b/pkg/analysis_server/lib/src/utilities/extensions/ast.dart
@@ -117,7 +117,7 @@
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 VariableDeclarationListExtension on VariableDeclarationList {
Token? get finalKeyword {
- var keyword = this.keyword;
+ final keyword = this.keyword;
return keyword != null && keyword.keyword == Keyword.FINAL ? keyword : null;
}
}
diff --git a/pkg/analysis_server/lib/src/utilities/request_statistics.dart b/pkg/analysis_server/lib/src/utilities/request_statistics.dart
index 3921409..7cdf234 100644
--- a/pkg/analysis_server/lib/src/utilities/request_statistics.dart
+++ b/pkg/analysis_server/lib/src/utilities/request_statistics.dart
@@ -218,7 +218,7 @@
_RequestStatisticsItem(this.name, {this.timeValue});
Map<String, Object> toJson() {
- var timeValue = this.timeValue;
+ final timeValue = this.timeValue;
if (timeValue != null) {
return {
'name': name,
diff --git a/pkg/analysis_server/test/integration/support/integration_tests.dart b/pkg/analysis_server/test/integration/support/integration_tests.dart
index 827f06d..4585df2 100644
--- a/pkg/analysis_server/test/integration/support/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/support/integration_tests.dart
@@ -379,8 +379,8 @@
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)) {
diff --git a/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart b/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
index 5b8f242..2a9e372 100644
--- a/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
@@ -123,7 +123,7 @@
CodeActionKind('quickfix.create.file'), "Create file 'newfile.dart'")!;
final edit = fixAction.edit!;
- expect(edit.documentChanges!, isNotNull);
+ expect(edit.documentChanges, isNotNull);
// Ensure applying the changes creates the file and with the expected content.
final contents = {
diff --git a/pkg/analysis_server/test/lsp/mapping_test.dart b/pkg/analysis_server/test/lsp/mapping_test.dart
index ce08941..896b994 100644
--- a/pkg/analysis_server/test/lsp/mapping_test.dart
+++ b/pkg/analysis_server/test/lsp/mapping_test.dart
@@ -72,6 +72,22 @@
expect(result, isNull);
}
+ void test_relevanceToSortText() {
+ // The expected order is the same as from the highest relevance.
+ final expectedOrder =
+ [999999, 1000, 100, 1, 0].map(lsp.relevanceToSortText).toList();
+
+ // Test with inputs in both directions to ensure the results are actually
+ // unique and sorted.
+ final results1 =
+ [999999, 1000, 100, 1, 0].map(lsp.relevanceToSortText).toList()..sort();
+ final results2 =
+ [0, 1, 100, 1000, 999999].map(lsp.relevanceToSortText).toList()..sort();
+
+ expect(results1, equals(expectedOrder));
+ expect(results2, equals(expectedOrder));
+ }
+
Future<void> test_tabStopsInSnippets_contains() async {
var result = lsp.buildSnippetStringWithTabStops('a, b, c', [3, 1]);
expect(result, equals(r'a, ${0:b}, c'));
diff --git a/pkg/analysis_server/test/search/element_references_test.dart b/pkg/analysis_server/test/search/element_references_test.dart
index 9515144..144cf47 100644
--- a/pkg/analysis_server/test/search/element_references_test.dart
+++ b/pkg/analysis_server/test/search/element_references_test.dart
@@ -799,7 +799,7 @@
}
''');
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);
diff --git a/pkg/analysis_server/test/services/refactoring/inline_method_test.dart b/pkg/analysis_server/test/services/refactoring/inline_method_test.dart
index 281b5f0..4a0f551 100644
--- a/pkg/analysis_server/test/services/refactoring/inline_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/inline_method_test.dart
@@ -1760,11 +1760,11 @@
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;
}
diff --git a/pkg/analysis_server/test/socket_server_test.dart b/pkg/analysis_server/test/socket_server_test.dart
index 53d4588..1c7bb82 100644
--- a/pkg/analysis_server/test/socket_server_test.dart
+++ b/pkg/analysis_server/test/socket_server_test.dart
@@ -110,7 +110,7 @@
null);
server.createAnalysisServer(channel);
- errorNotifier.server = server.analysisServer!;
+ errorNotifier.server = server.analysisServer;
AnalysisEngine.instance.instrumentationService = errorNotifier;
return server;
diff --git a/pkg/analysis_server/test/stress/utilities/git.dart b/pkg/analysis_server/test/stress/utilities/git.dart
index 05cc2a3..5db46e7 100644
--- a/pkg/analysis_server/test/stress/utilities/git.dart
+++ b/pkg/analysis_server/test/stress/utilities/git.dart
@@ -287,8 +287,8 @@
/// 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));
}
diff --git a/pkg/analysis_server/test/utils/test_support.dart b/pkg/analysis_server/test/utils/test_support.dart
index a917926..a791cfb 100644
--- a/pkg/analysis_server/test/utils/test_support.dart
+++ b/pkg/analysis_server/test/utils/test_support.dart
@@ -80,7 +80,7 @@
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;
diff --git a/pkg/analysis_server/tool/code_completion/completion_metrics.dart b/pkg/analysis_server/tool/code_completion/completion_metrics.dart
index 596d170..99eea81 100644
--- a/pkg/analysis_server/tool/code_completion/completion_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/completion_metrics.dart
@@ -436,7 +436,7 @@
/// 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 @@
/// 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();
}
diff --git a/pkg/analysis_server/tool/instrumentation/page/log_page.dart b/pkg/analysis_server/tool/instrumentation/page/log_page.dart
index 6853dc1..9288cf5 100644
--- a/pkg/analysis_server/tool/instrumentation/page/log_page.dart
+++ b/pkg/analysis_server/tool/instrumentation/page/log_page.dart
@@ -224,7 +224,7 @@
/// 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);
//
diff --git a/pkg/analysis_server/tool/spec/api.dart b/pkg/analysis_server/tool/spec/api.dart
index 95fddb4f..8e6696e 100644
--- a/pkg/analysis_server/tool/spec/api.dart
+++ b/pkg/analysis_server/tool/spec/api.dart
@@ -202,7 +202,7 @@
value: '$domainName.$event')
];
- var params = this.params;
+ final params = this.params;
if (params != null) {
fields.add(TypeObjectField('params', params, null));
}
@@ -275,7 +275,7 @@
value: '$domainName.$method')
];
- var params = this.params;
+ final params = this.params;
if (params != null) {
fields.add(TypeObjectField('params', params, null));
}
@@ -292,7 +292,7 @@
optional: true)
];
- var result = this.result;
+ final result = this.result;
if (result != null) {
fields.add(TypeObjectField('result', result, null));
}
diff --git a/pkg/analyzer/lib/file_system/physical_file_system.dart b/pkg/analyzer/lib/file_system/physical_file_system.dart
index 3bf1331..51e3bc8 100644
--- a/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/pkg/analyzer/lib/file_system/physical_file_system.dart
@@ -23,7 +23,7 @@
String? _getStandardStateLocation() {
final Map<String, String> env = io.Platform.environment;
if (env.containsKey('ANALYZER_STATE_LOCATION_OVERRIDE')) {
- return env['ANALYZER_STATE_LOCATION_OVERRIDE']!;
+ return env['ANALYZER_STATE_LOCATION_OVERRIDE'];
}
final home = io.Platform.isWindows ? env['LOCALAPPDATA'] : env['HOME'];
diff --git a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
index 85fe63e..fe3dce6 100644
--- a/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/dependency/reference_collector.dart
@@ -7,7 +7,6 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/analysis/dependency/node.dart';
-import 'package:analyzer/src/dart/ast/token.dart';
/// Collector of information about external nodes referenced by a node.
///
@@ -202,11 +201,13 @@
if (assignmentType != TokenType.EQ &&
assignmentType != TokenType.QUESTION_QUESTION_EQ) {
- var operatorType = operatorFromCompoundAssignment(assignmentType);
- _recordClassMemberReference(
- targetType: node.readType,
- name: operatorType.lexeme,
- );
+ var operatorType = assignmentType.binaryOperatorOfCompoundAssignment;
+ if (operatorType != null) {
+ _recordClassMemberReference(
+ targetType: node.readType,
+ name: operatorType.lexeme,
+ );
+ }
}
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/index.dart b/pkg/analyzer/lib/src/dart/analysis/index.dart
index c15e091..e728899 100644
--- a/pkg/analyzer/lib/src/dart/analysis/index.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/index.dart
@@ -94,7 +94,7 @@
String? classMemberName;
if (element.enclosingElement is ClassElement ||
element.enclosingElement is ExtensionElement) {
- classMemberName = element.name!;
+ classMemberName = element.name;
element = element.enclosingElement!;
}
diff --git a/pkg/analyzer/lib/src/dart/ast/token.dart b/pkg/analyzer/lib/src/dart/ast/token.dart
index d1753398..17d6198 100644
--- a/pkg/analyzer/lib/src/dart/ast/token.dart
+++ b/pkg/analyzer/lib/src/dart/ast/token.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'package:analyzer/dart/ast/token.dart';
-
export 'package:_fe_analyzer_shared/src/scanner/token.dart'
show
BeginToken,
@@ -17,36 +15,3 @@
SyntheticStringToken,
SyntheticToken,
TokenClass;
-
-/// Return the binary operator that is invoked by the given compound assignment
-/// [operator]. Throw [StateError] if the assignment [operator] does not
-/// correspond to a binary operator.
-TokenType operatorFromCompoundAssignment(TokenType operator) {
- if (operator == TokenType.AMPERSAND_EQ) {
- return TokenType.AMPERSAND;
- } else if (operator == TokenType.BAR_EQ) {
- return TokenType.BAR;
- } else if (operator == TokenType.CARET_EQ) {
- return TokenType.CARET;
- } else if (operator == TokenType.GT_GT_EQ) {
- return TokenType.GT_GT;
- } else if (operator == TokenType.GT_GT_GT_EQ) {
- return TokenType.GT_GT_GT;
- } else if (operator == TokenType.LT_LT_EQ) {
- return TokenType.LT_LT;
- } else if (operator == TokenType.MINUS_EQ) {
- return TokenType.MINUS;
- } else if (operator == TokenType.PERCENT_EQ) {
- return TokenType.PERCENT;
- } else if (operator == TokenType.PLUS_EQ) {
- return TokenType.PLUS;
- } else if (operator == TokenType.SLASH_EQ) {
- return TokenType.SLASH;
- } else if (operator == TokenType.STAR_EQ) {
- return TokenType.STAR;
- } else if (operator == TokenType.TILDE_SLASH_EQ) {
- return TokenType.TILDE_SLASH;
- } else {
- throw StateError('Unknown assignment operator: $operator');
- }
-}
diff --git a/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart
index b975efd..840b7b8 100644
--- a/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/assignment_expression_resolver.dart
@@ -11,7 +11,6 @@
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
-import 'package:analyzer/src/dart/ast/token.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/dart/resolver/invocation_inference_helper.dart';
@@ -28,7 +27,7 @@
AssignmentExpressionResolver({
required ResolverVisitor resolver,
- }) : _resolver = resolver,
+ }) : _resolver = resolver,
_typePropertyResolver = resolver.typePropertyResolver,
_inferenceHelper = resolver.inferenceHelper,
_assignmentShared = AssignmentExpressionShared(
@@ -177,7 +176,10 @@
return;
}
- var binaryOperatorType = operatorFromCompoundAssignment(operatorType);
+ var binaryOperatorType = operatorType.binaryOperatorOfCompoundAssignment;
+ if (binaryOperatorType == null) {
+ return;
+ }
var methodName = binaryOperatorType.lexeme;
var result = _typePropertyResolver.resolve(
diff --git a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
index 45c9c66..a838b86 100644
--- a/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
+++ b/pkg/analyzer/lib/src/error/unused_local_elements_verifier.dart
@@ -85,7 +85,7 @@
@override
void visitFunctionExpression(FunctionExpression node) {
if (node.parent is! FunctionDeclaration) {
- usedElements.addElement(node.declaredElement!);
+ usedElements.addElement(node.declaredElement);
}
super.visitFunctionExpression(node);
}
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 0036512..aefa6c7 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -467,10 +467,10 @@
target = target.function;
} else if (target is MethodInvocation) {
argumentList = target.argumentList;
- target = target.target!;
+ target = target.target;
} else if (target is PropertyAccess) {
argumentList = null;
- target = target.target!;
+ target = target.target;
} else {
break;
}
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index cedd048..3e45b52 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -561,7 +561,7 @@
void visitEnumDeclaration(EnumDeclaration node) {
var outerEnum = _enclosingEnum;
try {
- _enclosingEnum = node.declaredElement!;
+ _enclosingEnum = node.declaredElement;
_duplicateDefinitionVerifier.checkEnum(node);
super.visitEnumDeclaration(node);
} finally {
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 2ccfebc..b7c8023 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -1221,7 +1221,7 @@
@override
void visitConstructorDeclaration(ConstructorDeclaration node) {
var outerFunction = _enclosingFunction;
- _enclosingFunction = node.declaredElement!;
+ _enclosingFunction = node.declaredElement;
flowAnalysis!.topLevelDeclaration_enter(node, node.parameters, node.body);
flowAnalysis!.executableDeclaration_enter(node, node.parameters, false);
@@ -1510,7 +1510,7 @@
@override
void visitFunctionExpression(covariant FunctionExpressionImpl node) {
var outerFunction = _enclosingFunction;
- _enclosingFunction = node.declaredElement!;
+ _enclosingFunction = node.declaredElement;
if (node.parent is FunctionDeclaration) {
_functionExpressionResolver.resolve(node);
@@ -1711,7 +1711,7 @@
@override
void visitMethodDeclaration(MethodDeclaration node) {
var outerFunction = _enclosingFunction;
- _enclosingFunction = node.declaredElement!;
+ _enclosingFunction = node.declaredElement;
flowAnalysis!.topLevelDeclaration_enter(node, node.parameters, node.body);
flowAnalysis!.executableDeclaration_enter(node, node.parameters, false);
diff --git a/pkg/analyzer/lib/src/lint/pub.dart b/pkg/analyzer/lib/src/lint/pub.dart
index db19bb6..d68ecdf 100644
--- a/pkg/analyzer/lib/src/lint/pub.dart
+++ b/pkg/analyzer/lib/src/lint/pub.dart
@@ -303,7 +303,7 @@
@override
Source get source => (resourceProvider ?? PhysicalResourceProvider.INSTANCE)
.getFile(span.sourceUrl!.toFilePath())
- .createSource(span.sourceUrl!);
+ .createSource(span.sourceUrl);
@override
String toString() => '$text';
diff --git a/pkg/analyzer/lib/src/summary2/reference_resolver.dart b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
index 5d78a69..ecb1d5b 100644
--- a/pkg/analyzer/lib/src/summary2/reference_resolver.dart
+++ b/pkg/analyzer/lib/src/summary2/reference_resolver.dart
@@ -62,7 +62,7 @@
var outerReference = reference;
var element = node.declaredElement as ClassElementImpl;
- reference = element.reference!;
+ reference = element.reference;
element.accessors; // create elements
element.constructors; // create elements
element.methods; // create elements
@@ -91,7 +91,7 @@
var outerReference = reference;
var element = node.declaredElement as ClassElementImpl;
- reference = element.reference!;
+ reference = element.reference;
_createTypeParameterElements(element, node.typeParameters);
scope = TypeParameterScope(scope, element.typeParameters);
@@ -119,7 +119,7 @@
var outerReference = reference;
var element = node.declaredElement as ConstructorElementImpl;
- reference = element.reference!;
+ reference = element.reference;
element.parameters; // create elements
scope = TypeParameterScope(scope, element.typeParameters);
@@ -153,7 +153,7 @@
var outerReference = reference;
var element = node.declaredElement as ExtensionElementImpl;
- reference = element.reference!;
+ reference = element.reference;
_createTypeParameterElements(element, node.typeParameters);
scope = TypeParameterScope(scope, element.typeParameters);
@@ -208,7 +208,7 @@
var outerReference = reference;
var element = node.declaredElement as ExecutableElementImpl;
- reference = element.reference!;
+ reference = element.reference;
element.parameters; // create elements
_createTypeParameterElements(
@@ -238,7 +238,7 @@
var outerReference = reference;
var element = node.declaredElement as TypeAliasElementImpl;
- reference = element.reference!;
+ reference = element.reference;
_createTypeParameterElements(element, node.typeParameters);
scope = TypeParameterScope(outerScope, element.typeParameters);
@@ -247,7 +247,7 @@
node.typeParameters?.accept(this);
var function = element.aliasedElement as GenericFunctionTypeElementImpl;
- reference = function.reference!;
+ reference = function.reference;
function.parameters; // create elements
node.parameters.accept(this);
@@ -291,7 +291,7 @@
var element = GenericFunctionTypeElementImpl.forLinkedNode(
unitReference.element as CompilationUnitElementImpl,
- reference!,
+ reference,
node,
);
element.parameters; // create elements
@@ -318,7 +318,7 @@
var outerReference = reference;
var element = node.declaredElement as TypeAliasElementImpl;
- reference = element.reference!;
+ reference = element.reference;
_createTypeParameterElements(element, node.typeParameters);
scope = TypeParameterScope(outerScope, element.typeParameters);
@@ -349,7 +349,7 @@
var outerReference = reference;
var element = node.declaredElement as ExecutableElementImpl;
- reference = element.reference!;
+ reference = element.reference;
element.parameters; // create elements
_createTypeParameterElements(element, node.typeParameters);
@@ -372,7 +372,7 @@
var outerReference = reference;
var element = node.declaredElement as MixinElementImpl;
- reference = element.reference!;
+ reference = element.reference;
element.accessors; // create elements
element.constructors; // create elements
element.methods; // create elements
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 1852dbe..ab12ee4 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -1636,7 +1636,7 @@
expect(result.units, hasLength(1));
expect(result.units![0].path, testFile);
expect(result.units![0].content, content);
- expect(result.units![0].unit!, isNotNull);
+ expect(result.units![0].unit, isNotNull);
expect(result.units![0].errors, isEmpty);
}
@@ -1689,7 +1689,7 @@
expect(result.uri.toString(), 'package:test/test.dart');
expect(result.state, ResultState.VALID);
expect(result.content, content);
- expect(result.unit!, isNotNull);
+ expect(result.unit, isNotNull);
expect(result.errors, hasLength(0));
var f = result.unit!.declarations[0] as FunctionDeclaration;
@@ -2135,7 +2135,7 @@
var result = await resultFuture;
expect(result.path, testFile);
- expect(result.unit!, isNotNull);
+ expect(result.unit, isNotNull);
}
test_getResult_twoPendingFutures() async {
@@ -2150,7 +2150,7 @@
ResolvedUnitResult result2 = await future2;
expect(result2, same(result1));
expect(result1.path, testFile);
- expect(result1.unit!, isNotNull);
+ expect(result1.unit, isNotNull);
}
@deprecated
@@ -3158,7 +3158,7 @@
// A and B references.
ResolvedUnitResult result = await driver.getResultValid(c);
expect(result.errors, isNotEmpty);
- expect(result.unit!, isNotNull);
+ expect(result.unit, isNotNull);
}
test_part_getUnitElement2_afterLibrary() async {
@@ -3536,7 +3536,7 @@
// analyze the delayed parts.
ResolvedUnitResult result = allResults.lastWhere((r) => r.path == c);
expect(result.errors, isEmpty);
- expect(result.unit!, isNotNull);
+ expect(result.unit, isNotNull);
}
test_removeFile_changeFile_implicitlyAnalyzed() async {
@@ -3786,7 +3786,7 @@
expect(result.path, testFile);
expect(result.uri.toString(), 'package:test/test.dart');
expect(result.content, content);
- expect(result.unit!, isNotNull);
+ expect(result.unit, isNotNull);
expect(result.errors, hasLength(0));
var f = result.unit!.declarations[0] as FunctionDeclaration;
@@ -3811,7 +3811,7 @@
expect(allResults, hasLength(3));
ResolvedUnitResult result = allResults[0];
expect(result.path, b);
- expect(result.unit!, isNotNull);
+ expect(result.unit, isNotNull);
expect(result.errors, hasLength(0));
}
diff --git a/pkg/analyzer/test/src/dart/resolution/resolution.dart b/pkg/analyzer/test/src/dart/resolution/resolution.dart
index 5b351a0..ca2b79e 100644
--- a/pkg/analyzer/test/src/dart/resolution/resolution.dart
+++ b/pkg/analyzer/test/src/dart/resolution/resolution.dart
@@ -324,7 +324,7 @@
}) {
assertElement(node, element);
assertType(node.extendedType, extendedType);
- assertElementTypeStrings(node.typeArgumentTypes!, typeArgumentTypes);
+ assertElementTypeStrings(node.typeArgumentTypes, typeArgumentTypes);
}
void assertFunctionExpressionInvocation(
diff --git a/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart b/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
index b65d7e4..933f6f9 100644
--- a/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/receiver_of_type_never_test.dart
@@ -569,7 +569,7 @@
assertBinaryExpression(
findNode.binary('=='),
element: elementMatcher(
- objectElement.getMethod('==')!,
+ objectElement.getMethod('=='),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'bool',
@@ -619,7 +619,7 @@
assertSimpleIdentifier(
findNode.simple('toString'),
element: elementMatcher(
- objectElement.getMethod('toString')!,
+ objectElement.getMethod('toString'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'String Function()',
@@ -636,7 +636,7 @@
assertSimpleIdentifier(
findNode.simple('hashCode'),
element: elementMatcher(
- objectElement.getGetter('hashCode')!,
+ objectElement.getGetter('hashCode'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int',
diff --git a/pkg/analyzer/test/src/diagnostics/use_of_nullable_value_test.dart b/pkg/analyzer/test/src/diagnostics/use_of_nullable_value_test.dart
index f76dd2b..64accd6 100644
--- a/pkg/analyzer/test/src/diagnostics/use_of_nullable_value_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/use_of_nullable_value_test.dart
@@ -504,7 +504,7 @@
writeElement: findElement.setter('x'),
writeType: 'int',
operatorElement: elementMatcher(
- numElement.getMethod('+')!,
+ numElement.getMethod('+'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int',
@@ -517,7 +517,7 @@
writeElement: findElement.setter('y'),
writeType: 'int?',
operatorElement: elementMatcher(
- numElement.getMethod('+')!,
+ numElement.getMethod('+'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int',
@@ -560,7 +560,7 @@
writeElement: findElement.setter('x'),
writeType: 'int',
operatorElement: elementMatcher(
- numElement.getMethod('+')!,
+ numElement.getMethod('+'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int?',
@@ -573,7 +573,7 @@
writeElement: findElement.setter('x'),
writeType: 'int',
operatorElement: elementMatcher(
- numElement.getMethod('+')!,
+ numElement.getMethod('+'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int',
@@ -607,7 +607,7 @@
writeElement: findElement.parameter('x'),
writeType: 'int',
operatorElement: elementMatcher(
- numElement.getMethod('+')!,
+ numElement.getMethod('+'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int',
@@ -620,7 +620,7 @@
writeElement: findElement.parameter('y'),
writeType: 'int?',
operatorElement: elementMatcher(
- numElement.getMethod('+')!,
+ numElement.getMethod('+'),
isLegacy: isNullSafetySdkAndLegacyLibrary,
),
type: 'int',
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index ce28397..b1bfca5 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -583,7 +583,7 @@
writeNode(e.name);
if (e.constructorName != null) {
buffer.write('.');
- writeNode(e.constructorName!);
+ writeNode(e.constructorName);
}
if (e.arguments != null) {
writeList('(', ')', e.arguments!.arguments, ', ', writeNode,
@@ -598,7 +598,7 @@
writeNode(e.condition);
if (e.message != null) {
buffer.write(', ');
- writeNode(e.message!);
+ writeNode(e.message);
}
buffer.write(')');
} else if (e is BinaryExpression) {
@@ -623,13 +623,13 @@
writeNode(e.type);
if (e.name != null) {
buffer.write('.');
- writeNode(e.name!);
+ writeNode(e.name);
}
} else if (e is DoubleLiteral) {
buffer.write(e.value);
} else if (e is GenericFunctionType) {
if (e.returnType != null) {
- writeNode(e.returnType!);
+ writeNode(e.returnType);
buffer.write(' ');
}
buffer.write('Function');
diff --git a/pkg/compiler/lib/src/ir/constants.dart b/pkg/compiler/lib/src/ir/constants.dart
index 861711b..c951716 100644
--- a/pkg/compiler/lib/src/ir/constants.dart
+++ b/pkg/compiler/lib/src/ir/constants.dart
@@ -21,7 +21,6 @@
Dart2jsConstantEvaluator(
ir.TypeEnvironment typeEnvironment, ReportErrorFunction reportError,
{Map<String, String> environment: const {},
- bool enableTripleShift = false,
bool supportReevaluationForTesting: false,
ir.EvaluationMode evaluationMode})
: _supportReevaluationForTesting = supportReevaluationForTesting,
@@ -31,7 +30,7 @@
environment,
typeEnvironment,
new ErrorReporter(reportError),
- enableTripleShift: enableTripleShift,
+ enableTripleShift: true,
evaluationMode: evaluationMode);
@override
diff --git a/pkg/compiler/lib/src/js_model/element_map_impl.dart b/pkg/compiler/lib/src/js_model/element_map_impl.dart
index 4d42c97..a1c35bf 100644
--- a/pkg/compiler/lib/src/js_model/element_map_impl.dart
+++ b/pkg/compiler/lib/src/js_model/element_map_impl.dart
@@ -1170,7 +1170,6 @@
reportLocatedMessage(reporter, message, context);
},
environment: _environment.toMap(),
- enableTripleShift: options.enableTripleShift,
evaluationMode: options.useLegacySubtyping
? ir.EvaluationMode.weak
: ir.EvaluationMode.strong);
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index a677ae9..d568cea 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -817,7 +817,6 @@
reportLocatedMessage(reporter, message, context);
},
environment: _environment.toMap(),
- enableTripleShift: options.enableTripleShift,
evaluationMode: options.useLegacySubtyping
? ir.EvaluationMode.weak
: ir.EvaluationMode.strong);
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index ce9cddb..7f0403f 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -133,11 +133,6 @@
fe.isExperimentEnabled(fe.ExperimentalFlag.nonNullable,
explicitExperimentalFlags: explicitExperimentalFlags);
- /// Whether `--enable-experiment=triple-shift` is provided.
- bool get enableTripleShift =>
- fe.isExperimentEnabled(fe.ExperimentalFlag.tripleShift,
- explicitExperimentalFlags: explicitExperimentalFlags);
-
/// A possibly null state object for kernel compilation.
fe.InitializedCompilerState kernelInitializedCompilerState;
diff --git a/pkg/compiler/test/codegen/codegen_test_helper.dart b/pkg/compiler/test/codegen/codegen_test_helper.dart
index e4f9c73..f28f670 100644
--- a/pkg/compiler/test/codegen/codegen_test_helper.dart
+++ b/pkg/compiler/test/codegen/codegen_test_helper.dart
@@ -33,7 +33,7 @@
shards: 2,
directory: 'data',
skip: skip,
- options: [Flags.soundNullSafety, '--enable-experiment=triple-shift']);
+ options: [Flags.soundNullSafety]);
}
runTests2(List<String> args, [int shardIndex]) {
diff --git a/pkg/compiler/test/codegen/shift_right_unsigned_test.dart b/pkg/compiler/test/codegen/shift_right_unsigned_test.dart
index d4d6d2c..8b5dcc0 100644
--- a/pkg/compiler/test/codegen/shift_right_unsigned_test.dart
+++ b/pkg/compiler/test/codegen/shift_right_unsigned_test.dart
@@ -132,7 +132,6 @@
entry: 'main',
methodName: 'foo',
disableTypeInference: false,
- enableTripleShift: true,
soundNullSafety: true,
check: checkerForAbsentPresent(test));
}
diff --git a/pkg/compiler/test/helpers/compiler_helper.dart b/pkg/compiler/test/helpers/compiler_helper.dart
index 514b1ca..463d171 100644
--- a/pkg/compiler/test/helpers/compiler_helper.dart
+++ b/pkg/compiler/test/helpers/compiler_helper.dart
@@ -44,7 +44,6 @@
bool disableInlining: true,
bool disableTypeInference: true,
bool omitImplicitChecks: true,
- bool enableTripleShift: false, // TODO(30890): remove.
bool enableVariance: false,
void check(String generatedEntry),
bool returnAll: false,
@@ -66,9 +65,6 @@
if (disableInlining) {
options.add(Flags.disableInlining);
}
- if (enableTripleShift) {
- options.add('${Flags.enableLanguageExperiments}=triple-shift');
- }
if (enableVariance) {
options.add('${Flags.enableLanguageExperiments}=variance');
}
diff --git a/pkg/compiler/test/inference/data/shift_right_unsigned.dart b/pkg/compiler/test/inference/data/shift_right_unsigned.dart
index a229111..52390cc 100644
--- a/pkg/compiler/test/inference/data/shift_right_unsigned.dart
+++ b/pkg/compiler/test/inference/data/shift_right_unsigned.dart
@@ -21,20 +21,20 @@
test1() {
int a = 1234;
int b = 2;
- return a /*invoke: [exact=JSUInt31]*/>>> b;
+ return a /*invoke: [exact=JSUInt31]*/ >>> b;
}
/*member: test2:[subclass=JSUInt32]*/
test2() {
- return g1 /*invoke: [subclass=JSInt]*/>>> g1;
+ return g1 /*invoke: [subclass=JSInt]*/ >>> g1;
}
/*member: test3:[subclass=JSUInt32]*/
test3() {
- return g1 /*invoke: [subclass=JSInt]*/>>> 1;
+ return g1 /*invoke: [subclass=JSInt]*/ >>> 1;
}
/*member: test4:[exact=JSUInt31]*/
test4() {
- return 10 /*invoke: [exact=JSUInt31]*/>>> g1;
+ return 10 /*invoke: [exact=JSUInt31]*/ >>> g1;
}
diff --git a/pkg/compiler/test/inference/inference_test_helper.dart b/pkg/compiler/test/inference/inference_test_helper.dart
index b51b0e6..33565b7 100644
--- a/pkg/compiler/test/inference/inference_test_helper.dart
+++ b/pkg/compiler/test/inference/inference_test_helper.dart
@@ -32,7 +32,7 @@
await checkTests(dataDir, const TypeMaskDataComputer(),
forUserLibrariesOnly: true,
args: args,
- options: [stopAfterTypeInference, '--enable-experiment=triple-shift'],
+ options: [stopAfterTypeInference],
testedConfigs: allInternalConfigs,
skip: skip,
shardIndex: shardIndex ?? 0,
diff --git a/pkg/compiler/test/optimization/optimization_test.dart b/pkg/compiler/test/optimization/optimization_test.dart
index baf38d0..c89e863 100644
--- a/pkg/compiler/test/optimization/optimization_test.dart
+++ b/pkg/compiler/test/optimization/optimization_test.dart
@@ -27,7 +27,7 @@
Directory dataDir = new Directory.fromUri(Platform.script.resolve('data'));
bool strict = args.contains('-s');
await checkTests(dataDir, new OptimizationDataComputer(strict: strict),
- options: [Flags.disableInlining, '--enable-experiment=triple-shift'],
+ options: [Flags.disableInlining],
args: args);
});
}
diff --git a/tools/VERSION b/tools/VERSION
index 8450a34..1f35b2e 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 40
+PRERELEASE 41
PRERELEASE_PATCH 0
\ No newline at end of file