Version 3.9.0-31.0.dev
Merge 2936dca6adc0f13444f2dca946a76db713426263 into dev
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 8b394c3..27a2df3 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -75,13 +75,13 @@
import 'package:analyzer/src/dart/analysis/status.dart' as analysis;
import 'package:analyzer/src/dart/analysis/unlinked_unit_store.dart';
import 'package:analyzer/src/dart/ast/element_locator.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:analyzer/src/util/performance/operation_performance.dart';
import 'package:analyzer/src/utilities/extensions/analysis_session.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
import 'package:analyzer_plugin/protocol/protocol.dart';
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart'
as analyzer_plugin;
@@ -740,7 +740,7 @@
var result = await getResolvedUnit(file);
var unit = result?.unit;
if (unit != null) {
- return NodeLocator(offset).searchWithin(unit);
+ return unit.nodeCovering(offset: offset);
}
return null;
}
diff --git a/pkg/analysis_server/lib/src/cider/rename.dart b/pkg/analysis_server/lib/src/cider/rename.dart
index b4c853f..51d62b8 100644
--- a/pkg/analysis_server/lib/src/cider/rename.dart
+++ b/pkg/analysis_server/lib/src/cider/rename.dart
@@ -19,6 +19,7 @@
import 'package:analyzer/src/utilities/extensions/collection.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';
import 'package:analyzer/src/utilities/extensions/flutter.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
class CanRenameResponse {
final LineInfo lineInfo;
@@ -349,9 +350,9 @@
) async {
var resolvedUnit = await canRename._fileResolver.resolve(path: path);
var lineInfo = resolvedUnit.lineInfo;
- var node = NodeLocator(
- lineInfo.getOffsetOfLine(loc.lineNumber - 1) + loc.columnNumber,
- ).searchWithin(resolvedUnit.unit);
+ var node = resolvedUnit.unit.nodeCovering(
+ offset: lineInfo.getOffsetOfLine(loc.lineNumber - 1) + loc.columnNumber,
+ );
if (node is SimpleIdentifier) {
var parent = node.parent;
if (parent is InterpolationExpression && parent.rightBracket == null) {
diff --git a/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart b/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart
index 4d27f6f5..ff67cc0 100644
--- a/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_call_hierarchy.dart
@@ -10,8 +10,8 @@
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/source/source_range.dart';
import 'package:analyzer/src/dart/ast/element_locator.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dart/element/element.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
/// Returns the container for [element] that should be used in Call Hierarchy.
///
@@ -330,7 +330,7 @@
/// Finds a target node for call hierarchy navigation at [offset].
AstNode? _findTargetNode(int offset) {
- var node = NodeLocator(offset).searchWithin(_result.unit);
+ var node = _result.unit.nodeCovering(offset: offset);
if (node is SimpleIdentifier &&
node.parent != null &&
node.parent is! VariableDeclaration &&
@@ -436,7 +436,7 @@
);
if (result is ParsedUnitResult) {
- var node = NodeLocator(offset).searchWithin(result.unit);
+ var node = result.unit.nodeCovering(offset: offset);
if (node != null && !node.isSynthetic) {
var parent = node.parent;
// Handle named constructors which have their `.` included in the
diff --git a/pkg/analysis_server/lib/src/computer/computer_hover.dart b/pkg/analysis_server/lib/src/computer/computer_hover.dart
index 8ffd0a7..93a39a5 100644
--- a/pkg/analysis_server/lib/src/computer/computer_hover.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_hover.dart
@@ -10,8 +10,8 @@
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/ast/element_locator.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
import 'package:path/path.dart' as path;
/// Information about a library to display in a hover.
@@ -35,7 +35,7 @@
/// Returns the computed hover, maybe `null`.
HoverInformation? compute() {
- var node = NodeLocator(_offset).searchWithin(_unit);
+ var node = _unit.nodeCovering(offset: _offset);
if (node == null) {
return null;
}
diff --git a/pkg/analysis_server/lib/src/computer/computer_selection_ranges.dart b/pkg/analysis_server/lib/src/computer/computer_selection_ranges.dart
index 552596f..45e371b 100644
--- a/pkg/analysis_server/lib/src/computer/computer_selection_ranges.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_selection_ranges.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
/// Computes selection ranges for a specific offset of a Dart [CompilationUnit].
///
@@ -19,7 +19,7 @@
/// Returns selection ranges for nodes containing [_offset], starting with the
/// closest working up to the outer-most node.
List<SelectionRange> compute() {
- var node = NodeLocator(_offset).searchWithin(_unit);
+ var node = _unit.nodeCovering(offset: _offset);
if (node == null) {
return [];
}
diff --git a/pkg/analysis_server/lib/src/computer/computer_type_arguments_signature.dart b/pkg/analysis_server/lib/src/computer/computer_type_arguments_signature.dart
index e4c2630..7933188 100644
--- a/pkg/analysis_server/lib/src/computer/computer_type_arguments_signature.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_type_arguments_signature.dart
@@ -9,8 +9,8 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/src/dart/ast/element_locator.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dartdoc/dartdoc_directive_info.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
/// A computer for the signature help information about the type parameters for
/// the [TypeArgumentList] surrounding the specified offset of a Dart
@@ -29,7 +29,7 @@
this.preferredFormats, {
this.documentationPreference = DocumentationPreference.full,
}) : _documentationComputer = DartDocumentationComputer(dartdocInfo),
- _node = NodeLocator(offset).searchWithin(unit);
+ _node = unit.nodeCovering(offset: offset);
/// The [TypeArgumentList] node located by [compute].
TypeArgumentList get argumentList => _argumentList;
diff --git a/pkg/analysis_server/lib/src/handler/legacy/edit_get_available_refactorings.dart b/pkg/analysis_server/lib/src/handler/legacy/edit_get_available_refactorings.dart
index 71b4b867..68b41ff 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/edit_get_available_refactorings.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/edit_get_available_refactorings.dart
@@ -8,7 +8,7 @@
import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
import 'package:analysis_server/src/services/refactoring/legacy/refactoring.dart';
import 'package:analyzer/dart/element/element2.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
/// The handler for the `edit.getAvailableRefactorings` request.
@@ -74,7 +74,7 @@
// check elements
var resolvedUnit = await server.getResolvedUnit(file);
if (resolvedUnit != null) {
- var node = NodeLocator(offset).searchWithin(resolvedUnit.unit);
+ var node = resolvedUnit.unit.nodeCovering(offset: offset);
var element = server.getElementOfNode(node);
if (element != null) {
var refactoringWorkspace = server.refactoringWorkspace;
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/code_actions/dart.dart b/pkg/analysis_server/lib/src/lsp/handlers/code_actions/dart.dart
index ab4da6b..bf36e2e 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/code_actions/dart.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/code_actions/dart.dart
@@ -26,8 +26,8 @@
import 'package:analyzer/dart/analysis/session.dart'
show InconsistentAnalysisException;
import 'package:analyzer/dart/element/element2.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/util/performance/operation_performance.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
/// Produces [CodeAction]s from Dart source commands, fixes, assists and
/// refactors from the server.
@@ -400,7 +400,7 @@
if (shouldIncludeKind(CodeActionKind.RefactorRewrite)) {
timer.restart();
- var node = NodeLocator(offset).searchWithin(unitResult.unit);
+ var node = unitResult.unit.nodeCovering(offset: offset);
var element = server.getElementOfNode(node);
// Getter to Method
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart b/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart
index 59c6425..bb10d77 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/commands/abstract_refactor.dart
@@ -15,7 +15,7 @@
import 'package:analysis_server/src/services/refactoring/legacy/refactoring.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element2.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
final _manager = LspRefactorManager._();
@@ -125,7 +125,7 @@
return success(refactor);
case RefactoringKind.CONVERT_GETTER_TO_METHOD:
- var node = NodeLocator(offset).searchWithin(result.unit);
+ var node = result.unit.nodeCovering(offset: offset);
var element = server.getElementOfNode(node);
if (element is GetterElement) {
var refactor = ConvertGetterToMethodRefactoring(
@@ -141,7 +141,7 @@
);
case RefactoringKind.CONVERT_METHOD_TO_GETTER:
- var node = NodeLocator(offset).searchWithin(result.unit);
+ var node = result.unit.nodeCovering(offset: offset);
var element = server.getElementOfNode(node);
if (element is ExecutableElement2) {
var refactor = ConvertMethodToGetterRefactoring(
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart
index ea76b37..67c1b71 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart
@@ -11,8 +11,8 @@
import 'package:analysis_server/src/search/type_hierarchy.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element2.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/util/performance/operation_performance.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
typedef StaticOptions =
Either3<bool, ImplementationOptions, ImplementationRegistrationOptions>;
@@ -62,7 +62,7 @@
CancellationToken token,
OperationPerformanceImpl performance,
) async {
- var node = NodeLocator(offset).searchWithin(result.unit);
+ var node = result.unit.nodeCovering(offset: offset);
var element = server.getElementOfNode(node);
if (element == null) {
return success([]);
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
index 13cadb6..535e10e 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
@@ -13,8 +13,8 @@
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element2.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/util/performance/operation_performance.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
typedef StaticOptions = Either2<bool, ReferenceOptions>;
@@ -63,7 +63,7 @@
ReferenceParams params,
OperationPerformanceImpl performance,
) async {
- var node = NodeLocator(offset).searchWithin(result.unit);
+ var node = result.unit.nodeCovering(offset: offset);
node = _getReferenceTargetNode(node);
var element = switch (server.getElementOfNode(node)) {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_rename.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_rename.dart
index 21c06ab..f8aaa0a 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_rename.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_rename.dart
@@ -16,7 +16,7 @@
import 'package:analysis_server/src/utilities/extensions/string.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element2.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
AstNode? _tweakLocatedNode(AstNode? node, int offset) {
if (node is RepresentationDeclaration) {
@@ -61,8 +61,8 @@
var unit = await path.mapResult(requireResolvedUnit);
var offset = unit.mapResultSync((unit) => toOffset(unit.lineInfo, pos));
- return (unit, offset).mapResults((unit, offset) async {
- var node = NodeLocator(offset).searchWithin(unit.unit);
+ return (unit, offset).mapResults((result, offset) async {
+ var node = result.unit.nodeCovering(offset: offset);
node = _tweakLocatedNode(node, offset);
var element = server.getElementOfNode(node, useMockForImport: true);
@@ -77,7 +77,7 @@
var refactoring = RenameRefactoring.create(
server.refactoringWorkspace,
- unit,
+ result,
refactorDetails.element,
);
if (refactoring == null) {
@@ -97,7 +97,7 @@
TextDocumentPrepareRenameResult.t1(
PrepareRenamePlaceholder(
range: toRange(
- unit.lineInfo,
+ result.lineInfo,
// If the offset is set to -1 it means there is no location for the
// old name. However since we must provide a range for LSP, we'll use
// a 0-character span at the originally requested location to ensure
@@ -155,10 +155,10 @@
return (path, docIdentifier, unit, offset).mapResults((
path,
docIdentifier,
- unit,
+ result,
offset,
) async {
- var node = NodeLocator(offset).searchWithin(unit.unit);
+ var node = result.unit.nodeCovering(offset: offset);
node = _tweakLocatedNode(node, offset);
var element = server.getElementOfNode(node, useMockForImport: true);
if (node == null || element == null) {
@@ -172,7 +172,7 @@
var refactoring = RenameRefactoring.create(
server.refactoringWorkspace,
- unit,
+ result,
refactorDetails.element,
);
if (refactoring == null) {
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart
index 066e472..9f3feb1 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_type_definition.dart
@@ -13,8 +13,8 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:analyzer/src/dart/ast/extensions.dart';
-import 'package:analyzer/src/dart/ast/utilities.dart';
import 'package:analyzer/src/dart/element/element.dart';
+import 'package:analyzer/utilities/extensions/ast.dart';
typedef StaticOptions =
Either3<bool, TypeDefinitionOptions, TypeDefinitionRegistrationOptions>;
@@ -75,7 +75,7 @@
var offset = toOffset(result.lineInfo, pos);
return offset.mapResult((offset) async {
- var node = NodeLocator(offset).searchWithin(result.unit);
+ var node = result.unit.nodeCovering(offset: offset);
if (node == null) {
return success(_emptyResult);
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_super_parameter.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_super_parameter.dart
index 5ba17e4..60669fa 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_super_parameter.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_super_parameter.dart
@@ -74,9 +74,10 @@
i >= superPositionalParameters.length ||
parameter.name.lexeme != superPositionalParameters[i].name3) {
arePositionalOrdered = false;
- break;
}
lastPositionalParameter = parameter;
+ } else {
+ break;
}
}
@@ -102,13 +103,11 @@
needsInitialComma: false,
);
- if (missingNamedParameters.isNotEmpty) {
- _writeNamed(
- builder,
- missingNamedParameters,
- needsInitialComma: missingPositionalParameters.isNotEmpty,
- );
- }
+ _writeNamed(
+ builder,
+ missingNamedParameters,
+ needsInitialComma: missingPositionalParameters.isNotEmpty,
+ );
});
});
} else {
@@ -171,6 +170,7 @@
FormalParameter? lastNamedParameter,
required bool needsInitialComma,
}) {
+ if (parameters.isEmpty) return;
var firstParameter = true;
void writeComma() {
if (firstParameter) {
@@ -214,6 +214,7 @@
List<FormalParameterElement> parameters, {
required bool needsInitialComma,
}) {
+ if (parameters.isEmpty) return;
var firstParameter = true;
void writeComma() {
if (firstParameter && !needsInitialComma) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart
index 544df9e..7e883dd 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/add_type_annotation_test.dart
@@ -23,10 +23,10 @@
Future<void> test_classField_final() async {
await resolveTestCode('''
class A {
- final f = 0;
+ ^final f = 0;
}
''');
- await assertHasAssistAt('final ', '''
+ await assertHasAssist('''
class A {
final int f = 0;
}
@@ -47,10 +47,10 @@
Future<void> test_classField_int() async {
await resolveTestCode('''
class A {
- var f = 0;
+ ^var f = 0;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
class A {
int f = 0;
}
@@ -60,10 +60,10 @@
Future<void> test_classField_recordType() async {
await resolveTestCode('''
class A {
- var f = (2, b: 3);
+ ^var f = (2, b: 3);
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
class A {
(int, {int b}) f = (2, b: 3);
}
@@ -73,10 +73,10 @@
Future<void> test_classField_typeParameter() async {
await resolveTestCode('''
class A<T> {
- var f = <T>[];
+ ^var f = <T>[];
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
class A<T> {
List<T> f = <T>[];
}
@@ -86,24 +86,24 @@
Future<void> test_declaredIdentifier() async {
await resolveTestCode('''
void f(List<String> items) {
- for (var item in items) {
- }
-}
-''');
- // on identifier
- await assertHasAssistAt('item in', '''
-void f(List<String> items) {
- for (String item in items) {
+ /*0*/for (var /*1*/item in items) {
}
}
''');
// on "for"
- await assertHasAssistAt('for (', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (String item in items) {
}
}
''');
+ // on identifier
+ await assertHasAssist('''
+void f(List<String> items) {
+ for (String item in items) {
+ }
+}
+''', index: 1);
}
Future<void> test_declaredIdentifier_addImport_dartUri() async {
@@ -114,11 +114,11 @@
await resolveTestCode('''
import 'my_lib.dart';
void f() {
- for (var map in getMap()) {
+ for (var ^map in getMap()) {
}
}
''');
- await assertHasAssistAt('map in', '''
+ await assertHasAssist('''
import 'dart:collection';
import 'my_lib.dart';
@@ -132,11 +132,11 @@
Future<void> test_declaredIdentifier_final() async {
await resolveTestCode('''
void f(List<String> items) {
- for (final item in items) {
+ for (final ^item in items) {
}
}
''');
- await assertHasAssistAt('item in', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (final String item in items) {
}
@@ -148,12 +148,12 @@
await resolveTestCode('''
class A<T> {
void f(List<List<T>> items) {
- for (var item in items) {
+ for (var ^item in items) {
}
}
}
''');
- await assertHasAssistAt('item in', '''
+ await assertHasAssist('''
class A<T> {
void f(List<List<T>> items) {
for (List<T> item in items) {
@@ -166,32 +166,32 @@
Future<void> test_declaredIdentifier_hasTypeAnnotation() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ for (String ^item in items) {
}
}
''');
- await assertNoAssistAt('item in');
+ await assertNoAssist();
}
Future<void> test_declaredIdentifier_inForEachBody() async {
await resolveTestCode('''
void f(List<String> items) {
for (var item in items) {
- 42;
+ ^42;
}
}
''');
- await assertNoAssistAt('42;');
+ await assertNoAssist();
}
Future<void> test_declaredIdentifier_recordType() async {
await resolveTestCode('''
void f(List<(int, {int a})> items) {
- for (final item in items) {
+ for (final ^item in items) {
}
}
''');
- await assertHasAssistAt('item in', '''
+ await assertHasAssist('''
void f(List<(int, {int a})> items) {
for (final (int, {int a}) item in items) {
}
@@ -203,11 +203,11 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- for (var item in unknownList) {
+ for (var ^item in unknownList) {
}
}
''');
- await assertNoAssistAt('item in');
+ await assertNoAssist();
}
Future<void> test_local_addImport_dartUri() async {
@@ -218,10 +218,10 @@
await resolveTestCode('''
import 'my_lib.dart';
void f() {
- var v = getMap();
+ var ^v = getMap();
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
import 'dart:collection';
import 'my_lib.dart';
@@ -286,10 +286,10 @@
await resolveTestCode('''
import 'ccc/lib_b.dart';
void f() {
- var v = newMyClass();
+ var ^v = newMyClass();
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
import 'aa/bbb/lib_a.dart';
import 'ccc/lib_b.dart';
void f() {
@@ -301,19 +301,19 @@
Future<void> test_local_bottom() async {
await resolveTestCode('''
void f() {
- var v = throw 42;
+ ^var v = throw 42;
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_local_function() async {
await resolveTestCode('''
void f() {
- var v = () => 1;
+ var ^v = () => 1;
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
int Function() v = () => 1;
}
@@ -324,9 +324,9 @@
await resolveTestCode('''
void f({int arg = 0}) {}
-var v = f;
+var ^v = f;
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f({int arg = 0}) {}
void Function({int arg}) v = f;
@@ -337,9 +337,9 @@
await resolveTestCode('''
void f([int arg = 0]) {}
-var v = f;
+var ^v = f;
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f([int arg = 0]) {}
void Function([int arg]) v = f;
@@ -350,11 +350,11 @@
await resolveTestCode('''
class A {
void m(List<int> items) {
- var v = items;
+ var ^v = items;
}
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
class A {
void m(List<int> items) {
List<int> v = items;
@@ -367,11 +367,11 @@
await resolveTestCode('''
class A<T> {
void m(List<T> items) {
- var v = items;
+ var ^v = items;
}
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
class A<T> {
void m(List<T> items) {
List<T> v = items;
@@ -383,19 +383,19 @@
Future<void> test_local_hasTypeAnnotation() async {
await resolveTestCode('''
void f() {
- int v = 42;
+ int v^ = 42;
}
''');
- await assertNoAssistAt(' = 42');
+ await assertNoAssist();
}
Future<void> test_local_int() async {
await resolveTestCode('''
void f() {
- var v = 0;
+ var ^v = 0;
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
int v = 0;
}
@@ -405,10 +405,10 @@
Future<void> test_local_List() async {
await resolveTestCode('''
void f() {
- var v = <String>[];
+ var ^v = <String>[];
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
List<String> v = <String>[];
}
@@ -420,10 +420,10 @@
class C {}
C f() => C();
void g() {
- var x = f();
+ var ^x = f();
}
''');
- await assertHasAssistAt('x =', '''
+ await assertHasAssist('''
class C {}
C f() => C();
void g() {
@@ -435,19 +435,19 @@
Future<void> test_local_multiple() async {
await resolveTestCode('''
void f() {
- var a = 1, b = '';
+ ^var a = 1, b = '';
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_local_multiple_same_type() async {
await resolveTestCode('''
void f() {
- var a = '', b = '';
+ ^var a = '', b = '';
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
String a = '', b = '';
}
@@ -458,34 +458,34 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_local_noInitializer_oneAssignment_dynamic() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(p) {
- var v;
+ ^var v;
v = p;
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_local_noInitializer_oneAssignment_functionType() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(int Function(int) p) {
- var v;
+ ^var v;
v = p;
}
''');
// TODO(brianwilkerson): Improve `DartChangeBuilder.writeType` so that
// unnecessary parameter names (`p1`) are not written.
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f(int Function(int) p) {
int Function(int p1) v;
v = p;
@@ -497,13 +497,13 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
() {
v = '';
}();
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
String v;
() {
@@ -517,11 +517,11 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
v = '';
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
String v;
v = '';
@@ -533,13 +533,13 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(int a, String b) {
- var v;
+ ^var v;
v = a;
v = null;
v = b;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f(int a, String b) {
Object? v;
v = a;
@@ -553,12 +553,12 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
v = 0;
v = 3.1;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
num v;
v = 0;
@@ -571,12 +571,12 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
v = null;
v = 0;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
int? v;
v = null;
@@ -589,12 +589,12 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(int a, int? b) {
- var v;
+ ^var v;
v = a;
v = b;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f(int a, int? b) {
int? v;
v = a;
@@ -607,12 +607,12 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
v = 'a';
v = 'b';
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
String v;
v = 'a';
@@ -624,28 +624,28 @@
Future<void> test_local_null() async {
await resolveTestCode('''
void f() {
- var v = null;
+ ^var v = null;
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_local_onInitializer() async {
await resolveTestCode('''
void f() {
- var abc = 0;
+ var abc = ^0;
}
''');
- await assertNoAssistAt('0;');
+ await assertNoAssist();
}
Future<void> test_local_onName() async {
await resolveTestCode('''
void f() {
- var abc = 0;
+ var a^bc = 0;
}
''');
- await assertHasAssistAt('bc', '''
+ await assertHasAssist('''
void f() {
int abc = 0;
}
@@ -655,10 +655,10 @@
Future<void> test_local_onVar() async {
await resolveTestCode('''
void f() {
- var v = 0;
+ ^var v = 0;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
int v = 0;
}
@@ -668,10 +668,10 @@
Future<void> test_local_recordType() async {
await resolveTestCode('''
void f() {
- var v = (x: 0, y: 0);
+ var ^v = (x: 0, y: 0);
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
({int x, int y}) v = (x: 0, y: 0);
}
@@ -682,40 +682,40 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- var v = unknownVar;
+ ^var v = unknownVar;
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_mapLiteral_notype() async {
await resolveTestCode('''
-var map = {};
+var map = ^{};
''');
- await assertHasAssistAt('{}', '''
+ await assertHasAssist('''
var map = <dynamic, dynamic>{};
''');
}
Future<void> test_mapLiteral_writtenAnnotation() async {
await resolveTestCode('''
-var map = <String, int>{};
+var map = <String, int>^{};
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_mapLiteral_writtenAnnotation2() async {
await resolveTestCode('''
-var map = <String, int>{};
+var map = <String, int>{^};
''');
- await assertNoAssistAt('}');
+ await assertNoAssist();
}
Future<void> test_mapLiteral_writtenStaticType() async {
await resolveTestCode('''
-Map<String, int> map = {};
+Map<String, int> map = ^{};
''');
- await assertHasAssistAt('{}', '''
+ await assertHasAssist('''
Map<String, int> map = <String, int>{};
''');
}
@@ -724,10 +724,10 @@
await resolveTestCode('''
foo(f(int p)) {}
void f() {
- foo((test) {});
+ foo((^test) {});
}
''');
- await assertHasAssistAt('test', '''
+ await assertHasAssist('''
foo(f(int p)) {}
void f() {
foo((int test) {});
@@ -738,9 +738,9 @@
Future<void> test_parameter_final_type_noName() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-typedef F = void Function(final int);
+typedef F = void Function(^final int);
''');
- await assertNoAssistAt('final');
+ await assertNoAssist();
}
@FailingTest(
@@ -753,10 +753,10 @@
await resolveTestCode('''
foo(f(void Function(int) p)) {}
void f() {
- foo((test) {});
+ foo((^test) {});
}
''');
- await assertHasAssistAt('test', '''
+ await assertHasAssist('''
foo(f(void Function(int) p)) {}
void f() {
foo((void Function(int) test) {});
@@ -768,30 +768,30 @@
await resolveTestCode('''
foo(f(int p)) {}
void f() {
- foo((num test) {});
+ foo((num ^test) {});
}
''');
- await assertNoAssistAt('test');
+ await assertNoAssist();
}
Future<void> test_parameter_noPropagatedType() async {
await resolveTestCode('''
foo(f(p)) {}
void f() {
- foo((test) {});
+ foo((^test) {});
}
''');
- await assertNoAssistAt('test');
+ await assertNoAssist();
}
Future<void> test_parameter_recordType() async {
await resolveTestCode('''
foo(f((int, int) p)) {}
void f() {
- foo((test) {});
+ foo((^test) {});
}
''');
- await assertHasAssistAt('test', '''
+ await assertHasAssist('''
foo(f((int, int) p)) {}
void f() {
foo(((int, int) test) {});
@@ -809,10 +809,10 @@
await resolveTestCode('''
import 'my_lib.dart';
void f() {
- foo((test) {});
+ foo((^test) {});
}
- ''');
- await assertNoAssistAt('test)');
+''');
+ await assertNoAssist();
}
Future<void> test_privateType_declaredIdentifier() async {
@@ -826,12 +826,12 @@
import 'my_lib.dart';
class A<T> {
void m() {
- for (var item in getValues()) {
+ for (^var item in getValues()) {
}
}
}
''');
- await assertNoAssistAt('var item');
+ await assertNoAssist();
}
Future<void> test_privateType_list() async {
@@ -846,10 +846,10 @@
await resolveTestCode('''
import 'my_lib.dart';
void f() {
- var v = getValues();
+ ^var v = getValues();
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
import 'my_lib.dart';
void f() {
List v = getValues();
@@ -862,10 +862,10 @@
class _A {}
_A getValue() => _A();
void f() {
- var v = getValue();
+ ^var v = getValue();
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
class _A {}
_A getValue() => _A();
void f() {
@@ -884,40 +884,40 @@
await resolveTestCode('''
import 'my_lib.dart';
void f() {
- var v = getValue();
+ ^var v = getValue();
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_topLevelVariable_int() async {
await resolveTestCode('''
-var v = 0;
+^var v = 0;
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
int v = 0;
''');
}
Future<void> test_topLevelVariable_multiple() async {
await resolveTestCode('''
-var a = 1, v = '';
+^var a = 1, v = '';
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_topLevelVariable_noValue() async {
await resolveTestCode('''
-var v;
+^var v;
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_topLevelVariable_record() async {
await resolveTestCode('''
-var v = (a: 1, 2);
+^var v = (a: 1, 2);
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
(int, {int a}) v = (a: 1, 2);
''');
}
@@ -925,13 +925,13 @@
Future<void> test_typeParameter() async {
await resolveTestCode('''
void f<T>(List<T> items) {
- for (var item in items) {
- var x = item;
+ for (var /*0*/item in items) {
+ var /*1*/x = item;
}
}
''');
// on identifier
- await assertHasAssistAt('item in', '''
+ await assertHasAssist('''
void f<T>(List<T> items) {
for (T item in items) {
var x = item;
@@ -939,12 +939,12 @@
}
''');
// on inner variable
- await assertHasAssistAt('x', '''
+ await assertHasAssist('''
void f<T>(List<T> items) {
for (var item in items) {
T x = item;
}
}
-''');
+''', index: 1);
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/assign_to_local_variable_test.dart b/pkg/analysis_server/test/src/services/correction/assist/assign_to_local_variable_test.dart
index 0c5981e..da4e721 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/assign_to_local_variable_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/assign_to_local_variable_test.dart
@@ -25,21 +25,21 @@
await resolveTestCode('''
void f() {
var vvv;
- vvv = 42;
+ ^vvv = 42;
}
''');
- await assertNoAssistAt('vvv =');
+ await assertNoAssist();
}
Future<void> test_inClosure() async {
await resolveTestCode(r'''
void f() {
print(() {
- 12345;
+ 12^345;
});
}
''');
- await assertHasAssistAt('345', '''
+ await assertHasAssist('''
void f() {
print(() {
var i = 12345;
@@ -52,11 +52,11 @@
await resolveTestCode('''
void f() {
List<int> bytes;
- readBytes();
+ ^readBytes();
}
List<int> readBytes() => <int>[];
''');
- await assertHasAssistAt('readBytes();', '''
+ await assertHasAssist('''
void f() {
List<int> bytes;
var readBytes = readBytes();
@@ -77,21 +77,21 @@
Future<void> test_invocationArgument() async {
await resolveTestCode(r'''
void f() {
- g(12345);
+ g(12^345);
}
void g(p) {}
''');
- await assertNoAssistAt('345');
+ await assertNoAssist();
}
Future<void> test_lint_prefer_final_locals() async {
createAnalysisOptionsFile(lints: [LintNames.prefer_final_locals]);
await resolveTestCode(r'''
void f() {
- 12345;
+ 12^345;
}
''');
- await assertHasAssistAt('345', '''
+ await assertHasAssist('''
void f() {
final i = 12345;
}
@@ -103,28 +103,28 @@
await resolveTestCode('''
Future<void> _extractDataForSite() async {
final Map<String, Object> data = {};
- final data['table'][] //marker
+ final data['table'][^]
}
''');
- await assertNoAssistAt('] //marker');
+ await assertNoAssist();
}
Future<void> test_throw() async {
await resolveTestCode('''
void f() {
- throw 42;
+ ^throw 42;
}
''');
- await assertNoAssistAt('throw ');
+ await assertNoAssist();
}
Future<void> test_void() async {
await resolveTestCode('''
void f() {
- f();
+ ^f();
}
void g() {}
''');
- await assertNoAssistAt('f();');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart b/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart
index 98385c4..1ff7849 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/assist_processor.dart
@@ -2,6 +2,8 @@
// 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 'dart:math';
+
import 'package:analysis_server_plugin/edit/assist/assist.dart';
import 'package:analysis_server_plugin/edit/assist/dart_assist_context.dart';
import 'package:analysis_server_plugin/src/correction/assist_processor.dart';
@@ -38,21 +40,8 @@
@override
void addTestSource(String code) {
- code = normalizeSource(code);
- var parsedCode = TestCode.parse(code);
- code = parsedCode.code;
- if (parsedCode.positions.isNotEmpty) {
- _offset = parsedCode.position.offset;
- _length = 0;
- } else if (parsedCode.ranges.isNotEmpty) {
- var range = parsedCode.range.sourceRange;
- _offset = range.offset;
- _length = range.length;
- } else {
- _offset = 0;
- _length = 0;
- }
super.addTestSource(code);
+ _setPositionOrRange(0);
}
void assertExitPosition({String? before, String? after}) {
@@ -79,7 +68,9 @@
Future<SourceChange> assertHasAssist(
String expected, {
Map<String, List<String>>? additionallyChangedFiles,
+ int index = 0,
}) async {
+ _setPositionOrRange(index);
if (useLineEndingsForPlatform) {
expected = normalizeNewlinesForPlatform(expected);
additionallyChangedFiles = additionallyChangedFiles?.map(
@@ -115,26 +106,6 @@
return _change;
}
- /// Asserts that there is an [Assist] of the given [kind] at the offset of the
- /// given [snippet] which produces the [expected] code when applied to [testCode].
- Future<void> assertHasAssistAt(
- String snippet,
- String expected, {
- int length = 0,
- }) async {
- expected = normalizeSource(expected);
- _offset = findOffset(snippet);
- _length = length;
- var assist = await _assertHasAssist();
- _change = assist.change;
- expect(_change.id, kind.id);
- // apply to "file"
- var fileEdits = _change.edits;
- expect(fileEdits, hasLength(1));
- _resultCode = SourceEdit.applySequence(testCode, _change.edits[0].edits);
- expect(_resultCode, expected);
- }
-
void assertLinkedGroup(
int groupIndex,
List<String> expectedStrings, [
@@ -149,20 +120,8 @@
}
/// Asserts that there is no [Assist] of the given [kind] at [_offset].
- Future<void> assertNoAssist() async {
- var assists = await _computeAssists();
- for (var assist in assists) {
- if (assist.kind == kind) {
- fail('Unexpected assist $kind in\n${assists.join('\n')}');
- }
- }
- }
-
- /// Asserts that there is no [Assist] of the given [kind] at the offset of the
- /// given [snippet].
- Future<void> assertNoAssistAt(String snippet, {int length = 0}) async {
- _offset = findOffset(snippet);
- _length = length;
+ Future<void> assertNoAssist([int index = 0]) async {
+ _setPositionOrRange(index);
var assists = await _computeAssists();
for (var assist in assists) {
if (assist.kind == kind) {
@@ -221,4 +180,24 @@
}
return positions;
}
+
+ void _setPositionOrRange(int index) {
+ if (index < 0) {
+ throw ArgumentError('Index must be non-negative.');
+ }
+ if (index >
+ max(parsedTestCode.positions.length, parsedTestCode.ranges.length)) {
+ throw ArgumentError('Index exceeds the number of positions and ranges.');
+ }
+ if (parsedTestCode.positions.isNotEmpty) {
+ _offset = parsedTestCode.positions[index].offset;
+ _length = 0;
+ } else if (parsedTestCode.ranges.isNotEmpty) {
+ var range = parsedTestCode.ranges[index].sourceRange;
+ _offset = range.offset;
+ _length = range.length;
+ } else {
+ throw ArgumentError('Test code must contain a position or range marker.');
+ }
+ }
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart
index 22f7454..4eb904e 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart
@@ -21,7 +21,7 @@
Future<void> test_documentationComments_mix() async {
await resolveTestCode('''
-class E {
+class ^E {
/// AAA
static const E a = E._('a');
static const E b = E._('b');
@@ -34,7 +34,7 @@
const E._(this.name);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
/// AAA
a._('a'),
@@ -52,7 +52,7 @@
Future<void> test_documentationComments_multiple() async {
await resolveTestCode('''
-class E {
+class ^E {
/// AAA
static const E a = E._('a');
@@ -66,7 +66,7 @@
const E._(this.name);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
/// AAA
a._('a'),
@@ -85,7 +85,7 @@
Future<void> test_documentationComments_single() async {
await resolveTestCode('''
-class E {
+class ^E {
/// AAA
static const E a = E._('a');
@@ -95,7 +95,7 @@
const E._(this.name);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
/// AAA
a._('a');
@@ -110,13 +110,13 @@
Future<void> test_extends_object_privateClass() async {
await resolveTestCode('''
-class _E extends Object {
+class _^E extends Object {
static const _E c = _E();
const _E();
}
''');
- await assertHasAssistAt('E extends', '''
+ await assertHasAssist('''
enum _E {
c
}
@@ -125,13 +125,13 @@
Future<void> test_extends_object_publicClass() async {
await resolveTestCode('''
-class E extends Object {
+class ^E extends Object {
static const E c = E._();
const E._();
}
''');
- await assertHasAssistAt('E extends', '''
+ await assertHasAssist('''
enum E {
c._();
@@ -142,7 +142,7 @@
Future<void> test_index_namedIndex_first_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E(0, 'a');
static const _E c1 = _E(1, 'b');
@@ -153,7 +153,7 @@
const _E(this.index, this.code);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0('a'),
c1('b');
@@ -167,7 +167,7 @@
Future<void> test_index_namedIndex_last_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E('a', 0);
static const _E c1 = _E('b', 1);
@@ -178,7 +178,7 @@
const _E(this.code, this.index);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0('a'),
c1('b');
@@ -192,7 +192,7 @@
Future<void> test_index_namedIndex_middle_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E('a', 0, 'b');
static const _E c1 = _E('c', 1, 'd');
@@ -205,7 +205,7 @@
const _E(this.first, this.index, this.last);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0('a', 'b'),
c1('c', 'd');
@@ -221,7 +221,7 @@
Future<void> test_index_namedIndex_only_outOfOrder() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E(1);
static const _E c1 = _E(0);
@@ -230,7 +230,7 @@
const _E(this.index);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c1,
c0
@@ -240,7 +240,7 @@
Future<void> test_index_namedIndex_only_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E(0);
static const _E c1 = _E(1);
@@ -249,7 +249,7 @@
const _E(this.index);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0,
c1
@@ -259,7 +259,7 @@
Future<void> test_index_namedIndex_only_publicClass() async {
await resolveTestCode('''
-class E {
+class ^E {
static const E c0 = E._(0);
static const E c1 = E._(1);
@@ -268,7 +268,7 @@
const E._(this.index);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
c0._(),
c1._();
@@ -280,7 +280,7 @@
Future<void> test_index_notNamedIndex_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E(0);
static const _E c1 = _E(1);
@@ -289,7 +289,7 @@
const _E(this.value);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0(0),
c1(1);
@@ -303,7 +303,7 @@
Future<void> test_index_notNamedIndex_publicClass() async {
await resolveTestCode('''
-class E {
+class ^E {
static const E c0 = E._(0);
static const E c1 = E._(1);
@@ -312,7 +312,7 @@
const E._(this.value);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
c0._(0),
c1._(1);
@@ -326,62 +326,62 @@
Future<void> test_invalid_abstractClass() async {
await resolveTestCode('''
-abstract class E {}
+abstract class ^E {}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_base() async {
await resolveTestCode('''
-base class E {
+base class ^E {
final int index;
static const E c0 = E(0);
const E(this.index);
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_constructorUsedInConstructor() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
// ignore: unused_element_parameter, recursive_constant_constructor
const _E({_E e = const _E()});
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_constructorUsedOutsideClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
}
_E get e => _E();
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_extended() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
}
class F extends _E {}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_extends_notObject() async {
await resolveTestCode('''
-class E extends C {
+class ^E extends C {
static const E c = E._();
const E._();
@@ -390,25 +390,25 @@
const C();
}
''');
- await assertNoAssistAt('E extends');
+ await assertNoAssist();
}
Future<void> test_invalid_factoryConstructor_all() async {
await resolveTestCode('''
-class _E {
+class _^E {
static _E c = _E();
factory _E() => c;
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_factoryConstructor_some() async {
// We could arguably support this case by only converting the static fields
// that are initialized by a generative constructor.
await resolveTestCode('''
-class _E {
+class _^E {
static _E c0 = _E._();
static _E c1 = _E();
@@ -416,18 +416,18 @@
const _E._();
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_final() async {
await resolveTestCode('''
-final class E {
+final class ^E {
static const E c = E();
const E();
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_hasPart() async {
@@ -439,30 +439,30 @@
await resolveTestCode('''
part 'a.dart';
-class E {
+class ^E {
static const E c = E._();
const E._();
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_implemented() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
}
class F implements _E {}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_indexFieldNotSequential() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E(0);
static const _E c1 = _E(3);
@@ -471,14 +471,14 @@
const _E(this.index);
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_multipleConstantsInSameFieldDeclaration() async {
// Change this test if support is added to cover cases where multiple
// constants are defined in a single field declaration.
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E('a'), c1 = _E('b');
final String s;
@@ -486,23 +486,23 @@
const _E(this.s);
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_nonConstConstructor() async {
await resolveTestCode('''
-class _E {
+class _^E {
static _E c = _E();
_E();
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_overrides_equal() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
@@ -511,12 +511,12 @@
int get hashCode => 0;
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_overrides_hashCode() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
@@ -525,29 +525,29 @@
bool operator ==(Object other) => true;
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_invalid_sealed() async {
await resolveTestCode('''
-sealed class E {
+sealed class ^E {
final int index;
const E._(this.index);
}
''');
- await assertNoAssistAt('E {');
+ await assertNoAssist();
}
Future<void> test_minimal_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c
}
@@ -556,13 +556,13 @@
Future<void> test_minimal_publicClass() async {
await resolveTestCode('''
-class E {
+class ^E {
static const E c = E._();
const E._();
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
c._();
@@ -573,7 +573,7 @@
Future<void> test_noIndex_int_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E(2);
static const _E c1 = _E(4);
@@ -582,7 +582,7 @@
const _E(this.count);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0(2),
c1(4);
@@ -596,7 +596,7 @@
Future<void> test_noIndex_int_publicClass() async {
await resolveTestCode('''
-class E {
+class ^E {
static const E c0 = E._(2);
static const E c1 = E._(4);
@@ -605,7 +605,7 @@
const E._(this.count);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
c0._(2),
c1._(4);
@@ -619,7 +619,7 @@
Future<void> test_noIndex_notInt_privateClass() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c0 = _E('c0');
static const _E c1 = _E('c1');
@@ -628,7 +628,7 @@
const _E(this.name);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c0('c0'),
c1('c1');
@@ -642,7 +642,7 @@
Future<void> test_noIndex_notInt_publicClass() async {
await resolveTestCode('''
-class E {
+class ^E {
static const E c0 = E._('c0');
static const E c1 = E._('c1');
@@ -651,7 +651,7 @@
const E._(this.name);
}
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum E {
c0._('c0'),
c1._('c1');
@@ -665,7 +665,7 @@
Future<void> test_withReferencedFactoryConstructor() async {
await resolveTestCode('''
-class _E {
+class _^E {
static const _E c = _E();
const _E();
@@ -675,7 +675,7 @@
_E e = _E.withValue(0);
''');
- await assertHasAssistAt('E {', '''
+ await assertHasAssist('''
enum _E {
c;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart
index 9693592..6f8a2dc 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart
@@ -21,9 +21,9 @@
Future<void> test_abstract() async {
await resolveTestCode('''
-abstract class A {}
+abstract class ^A {}
''');
- await assertHasAssistAt('A', '''
+ await assertHasAssist('''
mixin A {}
''');
}
@@ -37,14 +37,14 @@
b() {}
}
class C {}
-base class D extends A with B implements C {
+base class ^D extends A with B implements C {
d() {
super.a();
super.b();
}
}
''');
- await assertHasAssistAt('D', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -64,9 +64,9 @@
Future<void> test_extends_noSuper() async {
await resolveTestCode('''
class A {}
-class B extends A {}
+class ^B extends A {}
''');
- await assertHasAssistAt('B', '''
+ await assertHasAssist('''
class A {}
mixin B implements A {}
''');
@@ -77,13 +77,13 @@
class A {
a() {}
}
-class B extends A {
+class ^B extends A {
b() {
super.a();
}
}
''');
- await assertHasAssistAt('B', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -101,13 +101,13 @@
a() {}
}
class B extends A {}
-class C extends B {
+class ^C extends B {
c() {
super.a();
}
}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -124,9 +124,9 @@
await resolveTestCode('''
class A {}
class B {}
-class C extends A implements B {}
+class ^C extends A implements B {}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {}
class B {}
mixin C implements A, B {}
@@ -139,13 +139,13 @@
a() {}
}
class B {}
-class C extends A implements B {
+class ^C extends A implements B {
c() {
super.a();
}
}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -162,9 +162,9 @@
await resolveTestCode('''
class A {}
mixin B {}
-class C extends A with B {}
+class ^C extends A with B {}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {}
mixin B {}
mixin C implements A, B {}
@@ -179,14 +179,14 @@
mixin class B {
b() {}
}
-class C extends A with B {
+class ^C extends A with B {
c() {
super.a();
super.b();
}
}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -210,13 +210,13 @@
mixin class B {
b() {}
}
-class C extends A with B {
+class ^C extends A with B {
c() {
super.a();
}
}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -239,13 +239,13 @@
mixin class B {
b() {}
}
-class C extends A with B {
+class ^C extends A with B {
c() {
super.b();
}
}
''');
- await assertHasAssistAt('C', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -265,9 +265,9 @@
class A {}
mixin B {}
class C {}
-class D extends A with B implements C {}
+class ^D extends A with B implements C {}
''');
- await assertHasAssistAt('D', '''
+ await assertHasAssist('''
class A {}
mixin B {}
class C {}
@@ -284,14 +284,14 @@
b() {}
}
class C {}
-class D extends A with B implements C {
+class ^D extends A with B implements C {
d() {
super.a();
super.b();
}
}
''');
- await assertHasAssistAt('D', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -317,13 +317,13 @@
b() {}
}
class C {}
-class D extends A with B implements C {
+class ^D extends A with B implements C {
d() {
super.a();
}
}
''');
- await assertHasAssistAt('D', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -348,13 +348,13 @@
b() {}
}
class C {}
-class D extends A with B implements C {
+class ^D extends A with B implements C {
d() {
super.b();
}
}
''');
- await assertHasAssistAt('D', '''
+ await assertHasAssist('''
class A {
a() {}
}
@@ -373,17 +373,17 @@
Future<void> test_final_implements() async {
await resolveTestCode('''
class A {}
-final class B implements A {}
+final class ^B implements A {}
''');
- await assertNoAssistAt('B');
+ await assertNoAssist();
}
Future<void> test_implements() async {
await resolveTestCode('''
class A {}
-class B implements A {}
+class ^B implements A {}
''');
- await assertHasAssistAt('B', '''
+ await assertHasAssist('''
class A {}
mixin B implements A {}
''');
@@ -391,25 +391,25 @@
Future<void> test_noClauses_invalidSelection() async {
await resolveTestCode('''
-class A {}
+class A ^{}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_noClauses_selectKeyword() async {
await resolveTestCode('''
-class A {}
+^class A {}
''');
- await assertHasAssistAt('class', '''
+ await assertHasAssist('''
mixin A {}
''');
}
Future<void> test_noClauses_selectName() async {
await resolveTestCode('''
-class A {}
+class ^A {}
''');
- await assertHasAssistAt('A', '''
+ await assertHasAssist('''
mixin A {}
''');
}
@@ -417,9 +417,9 @@
Future<void> test_sealed_extends_noSuper() async {
await resolveTestCode('''
class A {}
-sealed class B extends A {}
+sealed class ^B extends A {}
''');
- await assertNoAssistAt('B');
+ await assertNoAssist();
}
Future<void> test_sealed_extendsWith_super_extends() async {
@@ -430,20 +430,20 @@
mixin class B {
b() {}
}
-sealed class C extends A with B {
+sealed class ^C extends A with B {
c() {
super.a();
}
}
''');
- await assertNoAssistAt('C');
+ await assertNoAssist();
}
Future<void> test_typeParameters() async {
await resolveTestCode('''
-class A<T> {}
+class ^A<T> {}
''');
- await assertHasAssistAt('A', '''
+ await assertHasAssist('''
mixin A<T> {}
''');
}
@@ -451,9 +451,9 @@
Future<void> test_with_noSuper() async {
await resolveTestCode('''
mixin class A {}
-class B with A {}
+class ^B with A {}
''');
- await assertHasAssistAt('B', '''
+ await assertHasAssist('''
mixin class A {}
mixin B implements A {}
''');
@@ -464,13 +464,13 @@
mixin class A {
a() {}
}
-class B with A {
+class ^B with A {
b() {
super.a();
}
}
''');
- await assertHasAssistAt('B', '''
+ await assertHasAssist('''
mixin class A {
a() {}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_block_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_block_test.dart
index 9fe4f87..47e2147 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_block_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_block_test.dart
@@ -22,24 +22,24 @@
Future<void> test_alreadyBlock() async {
await resolveTestCode('''
/**
- * AAAAAAA
+ * A^AAAAAA
*/
class A {}
''');
- await assertNoAssistAt('AAA');
+ await assertNoAssist();
}
Future<void> test_noSpaceBeforeText() async {
await resolveTestCode('''
class A {
- /// AAAAA
+ /// ^AAAAA
///BBBBB
///
/// CCCCC
mmm() {}
}
''');
- await assertHasAssistAt('AAAAA', '''
+ await assertHasAssist('''
class A {
/**
* AAAAA
@@ -54,18 +54,18 @@
Future<void> test_notDocumentation() async {
await resolveTestCode('''
-// AAAA
+// ^AAAA
class A {}
''');
- await assertNoAssistAt('AAA');
+ await assertNoAssist();
}
Future<void> test_onReference() async {
await resolveTestCode('''
-/// AAAAAAA [int] AAAAAAA
+/// AAAAAAA [i^nt] AAAAAAA
class A {}
''');
- await assertHasAssistAt('nt]', '''
+ await assertHasAssist('''
/**
* AAAAAAA [int] AAAAAAA
*/
@@ -76,13 +76,13 @@
Future<void> test_onText() async {
await resolveTestCode('''
class A {
- /// AAAAAAA [int] AAAAAAA
+ /// AAAA^AAA [int] AAAAAAA
/// BBBBBBBB BBBB BBBB
/// CCC [A] CCCCCCCCCCC
mmm() {}
}
''');
- await assertHasAssistAt('AAA [', '''
+ await assertHasAssist('''
class A {
/**
* AAAAAAA [int] AAAAAAA
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart
index 129fbd5..aafb8b7 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart
@@ -22,24 +22,24 @@
Future<void> test_alreadyLine() async {
await resolveTestCode('''
-/// AAAAAAA
+/// ^AAAAAAA
class A {}
''');
- await assertNoAssistAt('AAA');
+ await assertNoAssist();
}
Future<void> test_hasEmptyLine() async {
await resolveTestCode('''
class A {
/**
- * AAAAAAA [int] AAAAAAA
+ * AAAA^AAA [int] AAAAAAA
*
* BBBBBBBB BBBB BBBB
*/
mmm() {}
}
''');
- await assertHasAssistAt('AAA [', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA [int] AAAAAAA
///
@@ -52,11 +52,11 @@
Future<void> test_indentation_last() async {
await resolveTestCode('''
/**
- * AAAAAAA
+ * ^AAAAAAA
*/
class A {}
''');
- await assertHasAssistAt('AAAAAAA', '''
+ await assertHasAssist('''
/// AAAAAAA
class A {}
''');
@@ -65,11 +65,11 @@
Future<void> test_indentation_middle() async {
await resolveTestCode('''
/**
- * AAAAAAA
+ * ^AAAAAAA
*/
class A {}
''');
- await assertHasAssistAt('AAAAAAA', '''
+ await assertHasAssist('''
/// AAAAAAA
class A {}
''');
@@ -79,7 +79,7 @@
await resolveTestCode('''
class A {
/**
- * AAAAAAA
+ * ^AAAAAAA
*
* while (i < 100) {
* i++;
@@ -88,7 +88,7 @@
mmm() {}
}
''');
- await assertHasAssistAt('AAA', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA
///
@@ -104,7 +104,7 @@
await resolveTestCode('''
class A {
/**
- * AAAAAAA
+ * ^AAAAAAA
*
* while (i < 100) {
* i++;
@@ -112,7 +112,7 @@
mmm() {}
}
''');
- await assertHasAssistAt('AAA', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA
///
@@ -128,11 +128,11 @@
await resolveTestCode('''
class A {
/**
- * AAAAAAA */
+ * ^AAAAAAA */
mmm() {}
}
''');
- await assertHasAssistAt('AAA', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA
mmm() {}
@@ -142,20 +142,20 @@
Future<void> test_notDocumentation() async {
await resolveTestCode('''
-/* AAAA */
+/* ^AAAA */
class A {}
''');
- await assertNoAssistAt('AAA');
+ await assertNoAssist();
}
Future<void> test_onReference() async {
await resolveTestCode('''
/**
- * AAAAAAA [int] AAAAAAA
+ * AAAAAAA [i^nt] AAAAAAA
*/
class A {}
''');
- await assertHasAssistAt('nt]', '''
+ await assertHasAssist('''
/// AAAAAAA [int] AAAAAAA
class A {}
''');
@@ -165,14 +165,14 @@
await resolveTestCode('''
class A {
/**
- * AAAAAAA [int] AAAAAAA
+ * AAAA^AAA [int] AAAAAAA
* BBBBBBBB BBBB BBBB
* CCC [A] CCCCCCCCCCC
*/
mmm() {}
}
''');
- await assertHasAssistAt('AAA [', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA [int] AAAAAAA
/// BBBBBBBB BBBB BBBB
@@ -185,14 +185,14 @@
Future<void> test_onText_hasFirstLine() async {
await resolveTestCode('''
class A {
- /** AAAAAAA [int] AAAAAAA
+ /** AAAA^AAA [int] AAAAAAA
* BBBBBBBB BBBB BBBB
* CCC [A] CCCCCCCCCCC
*/
mmm() {}
}
''');
- await assertHasAssistAt('AAA [', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA [int] AAAAAAA
/// BBBBBBBB BBBB BBBB
@@ -208,7 +208,7 @@
await resolveTestCode('''
class A {
/**
- * AAAAAAA [int] AAAAAAA
+ * ^AAAAAAA [int] AAAAAAA
* BBBBBBBB BBBB BBBB
* CCC [A] CCCCCCCCCCC
*/
@@ -223,13 +223,13 @@
class A {
/**
* First line.
- * Indented line.
+ * ^Indented line.
* Last line.
*/
m() {}
}
''');
- await assertHasAssistAt('Indented', '''
+ await assertHasAssist('''
class A {
/// First line.
/// Indented line.
@@ -242,11 +242,11 @@
Future<void> test_singleLine() async {
await resolveTestCode('''
class A {
- /** AAAAAAA */
+ /** ^AAAAAAA */
mmm() {}
}
''');
- await assertHasAssistAt('AAA', '''
+ await assertHasAssist('''
class A {
/// AAAAAAA
mmm() {}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_async_body_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_async_body_test.dart
index 226818c..9e3fd5e 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_async_body_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_async_body_test.dart
@@ -22,36 +22,36 @@
Future<void> test_async() async {
await resolveTestCode('''
import 'dart:async';
-Future<String> f() async => '';
+Future<String> f() async ^=> '';
''');
- await assertNoAssistAt('=>');
+ await assertNoAssist();
}
Future<void> test_asyncStar() async {
await resolveTestCode('''
import 'dart:async';
-Stream<String> f() async* {}
+Stream<String> f() async* ^{}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_closure() async {
await resolveTestCode('''
void h() {
- f(() => 123);
+ f(() ^=> 123);
}
f(g) {}
''');
- await assertNoAssistAt('=>');
+ await assertNoAssist();
}
Future<void> test_closure_assignment() async {
await resolveTestCode('''
void f() {
- var c = () {};
+ var c = () ^{};
}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_closure_future() async {
@@ -61,10 +61,10 @@
void g(Future<int> Function() fun) {}
void f() {
- g(() => Future.value(1));
+ g(() ^=> Future.value(1));
}
''');
- await assertNoAssistAt('=>');
+ await assertNoAssist();
}
Future<void> test_closure_futureOr() async {
@@ -74,10 +74,10 @@
void g(FutureOr<int> Function() fun) {}
void f() {
- g(() => 1);
+ g(() ^=> 1);
}
''');
- await assertNoAssistAt('=>');
+ await assertNoAssist();
}
Future<void> test_closure_int() async {
@@ -85,10 +85,10 @@
void g(int Function() fun) {}
void f() {
- g(() => 1);
+ g(() ^=> 1);
}
''');
- await assertNoAssistAt('=>');
+ await assertNoAssist();
}
Future<void> test_closure_void() async {
@@ -97,26 +97,26 @@
}
void f() {
- g(() {});
+ g(() ^{});
}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_constructor() async {
await resolveTestCode('''
class C {
- C() {}
+ C() ^{}
}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_function() async {
await resolveTestCode('''
-String f() => '';
+String f() ^=> '';
''');
- await assertHasAssistAt('=>', '''
+ await assertHasAssist('''
Future<String> f() async => '';
''');
}
@@ -124,10 +124,10 @@
Future<void> test_function_local() async {
await resolveTestCode('''
void g() {
- String f() => '';
+ String f() ^=> '';
}
''');
- await assertHasAssistAt('=>', '''
+ await assertHasAssist('''
void g() {
Future<String> f() async => '';
}
@@ -136,10 +136,10 @@
Future<void> test_function_returnType_future() async {
await resolveTestCode(r'''
-Future<int> f() => Future.value(0);
+Future<int> f() ^=> Future.value(0);
''');
- await assertHasAssistAt('=>', r'''
+ await assertHasAssist(r'''
Future<int> f() async => Future.value(0);
''');
}
@@ -148,10 +148,10 @@
await resolveTestCode(r'''
import 'dart:async';
-FutureOr<int> f() => 0;
+FutureOr<int> f() ^=> 0;
''');
- await assertHasAssistAt('=>', r'''
+ await assertHasAssist(r'''
import 'dart:async';
Future<int> f() async => 0;
@@ -161,10 +161,10 @@
Future<void> test_getter_expression_noSpace() async {
await resolveTestCode('''
class C {
- int get g=>0;
+ int ^get g=>0;
}
''');
- await assertHasAssistAt('get g', '''
+ await assertHasAssist('''
class C {
Future<int> get g async =>0;
}
@@ -175,29 +175,29 @@
await resolveTestCode('''
class C {
void foo() {
- print(42);
+ ^print(42);
}
}
''');
- await assertNoAssistAt('print');
+ await assertNoAssist();
}
Future<void> test_inBody_expression() async {
await resolveTestCode('''
class C {
- void foo() => print(42);
+ void foo() => ^print(42);
}
''');
- await assertNoAssistAt('print');
+ await assertNoAssist();
}
Future<void> test_method() async {
await resolveTestCode('''
class C {
- int m() { return 0; }
+ int m() ^{ return 0; }
}
''');
- await assertHasAssistAt('{ return', '''
+ await assertHasAssist('''
class C {
Future<int> m() async { return 0; }
}
@@ -207,7 +207,7 @@
Future<void> test_method_abstract() async {
await resolveTestCode('''
abstract class C {
- int m();
+ int ^m();
}
''');
await assertNoAssist();
@@ -216,10 +216,10 @@
Future<void> test_method_noReturnType() async {
await resolveTestCode('''
class C {
- m() { return 0; }
+ m() ^{ return 0; }
}
''');
- await assertHasAssistAt('{ return', '''
+ await assertHasAssist('''
class C {
m() async { return 0; }
}
@@ -231,15 +231,15 @@
// computing assists.
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-Iterable<String> f() sync {}
+Iterable<String> f() sync ^{}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
Future<void> test_syncStar() async {
await resolveTestCode('''
-Iterable<String> f() sync* {}
+Iterable<String> f() sync* ^{}
''');
- await assertNoAssistAt('{}');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_block_body_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_block_body_test.dart
index fb714b5..c6372e7 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_block_body_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_block_body_test.dart
@@ -22,10 +22,10 @@
Future<void> test_async() async {
await resolveTestCode('''
class A {
- mmm() async => 123;
+ ^mmm() async => 123;
}
''');
- await assertHasAssistAt('mmm()', '''
+ await assertHasAssist('''
class A {
mmm() async {
return 123;
@@ -38,10 +38,10 @@
await resolveTestCode('''
setup(x) {}
void f() {
- setup(() => 42);
+ setup(^() => 42);
}
''');
- await assertHasAssistAt('() => 42', '''
+ await assertHasAssist('''
setup(x) {}
void f() {
setup(() {
@@ -56,10 +56,10 @@
await resolveTestCode('''
setup(x) {}
void f() {
- setup(() => print('done'));
+ setup(^() => print('done'));
}
''');
- await assertHasAssistAt('() => print', '''
+ await assertHasAssist('''
setup(x) {}
void f() {
setup(() {
@@ -75,10 +75,10 @@
class A {
A.named();
- factory A() => A.named();
+ factory ^A() => A.named();
}
''');
- await assertHasAssistAt('A()', '''
+ await assertHasAssist('''
class A {
A.named();
@@ -91,18 +91,18 @@
Future<void> test_inExpression() async {
await resolveTestCode('''
-void f() => 123;
+void f() => ^123;
''');
- await assertNoAssistAt('123;');
+ await assertNoAssist();
}
Future<void> test_method() async {
await resolveTestCode('''
class A {
- mmm() => 123;
+ ^mmm() => 123;
}
''');
- await assertHasAssistAt('mmm()', '''
+ await assertHasAssist('''
class A {
mmm() {
return 123;
@@ -113,25 +113,25 @@
Future<void> test_noEnclosingFunction() async {
await resolveTestCode('''
-var v = 123;
+var ^v = 123;
''');
- await assertNoAssistAt('v =');
+ await assertNoAssist();
}
Future<void> test_notExpressionBlock() async {
await resolveTestCode('''
-fff() {
+^fff() {
return 123;
}
''');
- await assertNoAssistAt('fff() {');
+ await assertNoAssist();
}
Future<void> test_onArrow() async {
await resolveTestCode('''
-fff() => 123;
+fff() ^=> 123;
''');
- await assertHasAssistAt('=>', '''
+ await assertHasAssist('''
fff() {
return 123;
}
@@ -140,9 +140,9 @@
Future<void> test_onName() async {
await resolveTestCode('''
-fff() => 123;
+^fff() => 123;
''');
- await assertHasAssistAt('fff()', '''
+ await assertHasAssist('''
fff() {
return 123;
}
@@ -152,10 +152,10 @@
Future<void> test_throw() async {
await resolveTestCode('''
class A {
- mmm() => throw 'error';
+ ^mmm() => throw 'error';
}
''');
- await assertHasAssistAt('mmm()', '''
+ await assertHasAssist('''
class A {
mmm() {
throw 'error';
@@ -169,10 +169,10 @@
class C {
String? _s;
- set s(String s) => _s = s;
+ set s(String s) ^=> _s = s;
}
''');
- await assertHasAssistAt('=>', '''
+ await assertHasAssist('''
class C {
String? _s;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart
index 14fded4..94072e4 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_expression_body_test.dart
@@ -22,20 +22,20 @@
Future<void> test_already() async {
await resolveTestCode('''
-fff() => 42;
+^fff() => 42;
''');
- await assertNoAssistAt('fff()');
+ await assertNoAssist();
}
Future<void> test_async() async {
await resolveTestCode('''
class A {
- mmm() async {
+ ^mmm() async {
return 42;
}
}
''');
- await assertHasAssistAt('mmm', '''
+ await assertHasAssist('''
class A {
mmm() async => 42;
}
@@ -50,7 +50,7 @@
await resolveTestCode('''
class A {
mmm() async {
- return 42;
+ ^return 42;
}
}
''');
@@ -62,11 +62,11 @@
setup(x) {}
void f() {
setup(() {
- return 42;
+ ^return 42;
});
}
''');
- await assertHasAssistAt('return', '''
+ await assertHasAssist('''
setup(x) {}
void f() {
setup(() => 42);
@@ -79,12 +79,12 @@
setup(x) {}
void f() {
setup(() {
- return 42;
+ ^return 42;
// Comment.
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_hasBlockComment_beforeReturnKeyword() async {
@@ -93,11 +93,11 @@
void f() {
setup(() {
// Comment.
- return 42;
+ ^return 42;
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_hasBlockComment_multiple() async {
@@ -108,11 +108,11 @@
// Comment.
// Comment 2.
- return 42;
+ ^return 42;
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_hasInlineComment_beforeBodyKeyword() async {
@@ -120,11 +120,11 @@
setup(x) {}
void f() {
setup(() /* Comment. */ async {
- return 42;
+ ^return 42;
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_hasInlineComment_beforeOpenBrace() async {
@@ -132,11 +132,11 @@
setup(x) {}
void f() {
setup(() /* Comment. */ {
- return 42;
+ ^return 42;
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_hasInlineComment_beforeReturn() async {
@@ -145,11 +145,11 @@
void f() {
setup(() {
/* Comment. */
- return 42;
+ ^return 42;
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_hasInlineComment_beforeReturnSemicolon() async {
@@ -157,23 +157,23 @@
setup(x) {}
void f() {
setup(() {
- return 42 /* Comment. */;
+ ^return 42 /* Comment. */;
});
}
''');
- await assertNoAssistAt('return');
+ await assertNoAssist();
}
Future<void> test_closure_voidExpression() async {
await resolveTestCode('''
setup(x) {}
void f() {
- setup((_) {
+ setup(^(_) {
print('test');
});
}
''');
- await assertHasAssistAt('(_) {', '''
+ await assertHasAssist('''
setup(x) {}
void f() {
setup((_) => print('test'));
@@ -186,12 +186,12 @@
class A {
A.named();
- factory A() {
+ factory ^A() {
return A.named();
}
}
''');
- await assertHasAssistAt('A()', '''
+ await assertHasAssist('''
class A {
A.named();
@@ -205,32 +205,32 @@
class A {
int x = 0;
- A() {
+ ^A() {
x = 3;
}
}
''');
- await assertNoAssistAt('A()');
+ await assertNoAssist();
}
Future<void> test_function_onBlock() async {
await resolveTestCode('''
-fff() {
+fff() ^{
return 42;
}
''');
- await assertHasAssistAt('{', '''
+ await assertHasAssist('''
fff() => 42;
''');
}
Future<void> test_function_onName() async {
await resolveTestCode('''
-fff() {
+f^ff() {
return 42;
}
''');
- await assertHasAssistAt('ff()', '''
+ await assertHasAssist('''
fff() => 42;
''');
}
@@ -238,21 +238,21 @@
Future<void> test_inExpression() async {
await resolveTestCode('''
int f() {
- return 42;
+ return ^42;
}
''');
- await assertNoAssistAt('42;');
+ await assertNoAssist();
}
Future<void> test_method_onBlock() async {
await resolveTestCode('''
class A {
- m() {
+ ^m() {
return 42;
}
}
''');
- await assertHasAssistAt('m() {', '''
+ await assertHasAssist('''
class A {
m() => 42;
}
@@ -261,46 +261,46 @@
Future<void> test_moreThanOneStatement() async {
await resolveTestCode('''
-fff() {
+^fff() {
var v = 42;
return v;
}
''');
- await assertNoAssistAt('fff()');
+ await assertNoAssist();
}
Future<void> test_noEnclosingFunction() async {
await resolveTestCode('''
-var V = 42;
+var ^V = 42;
''');
- await assertNoAssistAt('V = ');
+ await assertNoAssist();
}
Future<void> test_noReturn() async {
await resolveTestCode('''
-fff() {
+^fff() {
var v = 42;
}
''');
- await assertNoAssistAt('fff()');
+ await assertNoAssist();
}
Future<void> test_noReturnValue() async {
await resolveTestCode('''
-fff() {
+^fff() {
return;
}
''');
- await assertNoAssistAt('fff()');
+ await assertNoAssist();
}
Future<void> test_topFunction_onReturnStatement() async {
await resolveTestCode('''
fff() {
- return 42;
+ ^return 42;
}
''');
- await assertHasAssistAt('return', '''
+ await assertHasAssist('''
fff() => 42;
''');
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_final_field_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_final_field_test.dart
index bb94ead..f8e3ba0 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_final_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_final_field_test.dart
@@ -22,12 +22,12 @@
Future<void> test_blockBody_onlyReturnStatement() async {
await resolveTestCode('''
class A {
- int get foo {
+ int ^get foo {
return 1 + 2;
}
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
class A {
final int foo = 1 + 2;
}
@@ -37,19 +37,19 @@
Future<void> test_extension_instance() async {
await resolveTestCode('''
extension E on int {
- int get foo => 0;
+ int ^get foo => 0;
}
''');
- await assertNoAssistAt('get foo');
+ await assertNoAssist();
}
Future<void> test_extension_static() async {
await resolveTestCode('''
extension E on int {
- static int get foo => 0;
+ static int ^get foo => 0;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
extension E on int {
static final int foo = 0;
}
@@ -59,19 +59,19 @@
Future<void> test_extensionType_instance() async {
await resolveTestCode('''
extension type E(int v) {
- int get foo => 0;
+ int ^get foo => 0;
}
''');
- await assertNoAssistAt('get foo');
+ await assertNoAssist();
}
Future<void> test_extensionType_static() async {
await resolveTestCode('''
extension type E(int v) {
- static int get foo => 0;
+ static int ^get foo => 0;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
extension type E(int v) {
static final int foo = 0;
}
@@ -83,10 +83,10 @@
const myAnnotation = const Object();
class A {
@myAnnotation
- int get foo => 42;
+ int ^get foo => 42;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
const myAnnotation = const Object();
class A {
@myAnnotation
@@ -101,10 +101,10 @@
void set foo(_) {}
}
class B extends A {
- int get foo => 3;
+ int ^get foo => 3;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
class A {
void set foo(_) {}
}
@@ -117,20 +117,20 @@
Future<void> test_hasSetter_inThisClass() async {
await resolveTestCode('''
class A {
- int get foo => 0;
+ int ^get foo => 0;
void set foo(_) {}
}
''');
- await assertNoAssistAt('get foo');
+ await assertNoAssist();
}
Future<void> test_noReturnType() async {
await resolveTestCode('''
class A {
- get foo => 42;
+ ^get foo => 42;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
class A {
final foo = 42;
}
@@ -140,10 +140,10 @@
Future<void> test_noReturnType_static() async {
await resolveTestCode('''
class A {
- static get foo => 42;
+ static ^get foo => 42;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
class A {
static final foo = 42;
}
@@ -153,31 +153,31 @@
Future<void> test_notExpressionBody() async {
await resolveTestCode('''
class A {
- int get foo {
+ int ^get foo {
int v = 1 + 2;
return v + 3;
}
}
''');
- await assertNoAssistAt('get foo');
+ await assertNoAssist();
}
Future<void> test_notGetter() async {
await resolveTestCode('''
class A {
- int foo() => 42;
+ int ^foo() => 42;
}
''');
- await assertNoAssistAt('foo');
+ await assertNoAssist();
}
Future<void> test_notNull() async {
await resolveTestCode('''
class A {
- int get foo => 1 + 2;
+ int ^get foo => 1 + 2;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
class A {
final int foo = 1 + 2;
}
@@ -187,10 +187,10 @@
Future<void> test_null() async {
await resolveTestCode('''
class A {
- int? get foo => null;
+ int? ^get foo => null;
}
''');
- await assertHasAssistAt('get foo', '''
+ await assertHasAssist('''
class A {
final int? foo;
}
@@ -200,10 +200,10 @@
Future<void> test_onName() async {
await resolveTestCode('''
class A {
- int get foo => 42;
+ int get ^foo => 42;
}
''');
- await assertHasAssistAt('foo', '''
+ await assertHasAssist('''
class A {
final int foo = 42;
}
@@ -213,10 +213,10 @@
Future<void> test_onReturnType_parameterized() async {
await resolveTestCode('''
class A {
- List<int>? get foo => null;
+ List<i^nt>? get foo => null;
}
''');
- await assertHasAssistAt('nt>? get', '''
+ await assertHasAssist('''
class A {
final List<int>? foo;
}
@@ -226,10 +226,10 @@
Future<void> test_onReturnType_simple() async {
await resolveTestCode('''
class A {
- int get foo => 42;
+ ^int get foo => 42;
}
''');
- await assertHasAssistAt('int get', '''
+ await assertHasAssist('''
class A {
final int foo = 42;
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_for_index_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_for_index_test.dart
index 9f5043b..5ab7a48 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_for_index_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_for_index_test.dart
@@ -22,55 +22,55 @@
Future<void> test_bodyNotBlock() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) print(item);
+ f^or (String item in items) print(item);
}
''');
- await assertNoAssistAt('for (String');
+ await assertNoAssist();
}
Future<void> test_doesNotDeclareVariable() async {
await resolveTestCode('''
void f(List<String> items) {
String item;
- for (item in items) {
+ ^for (item in items) {
print(item);
}
}
''');
- await assertNoAssistAt('for (item');
+ await assertNoAssist();
}
Future<void> test_iterableIsNotVariable() async {
await resolveTestCode('''
void f() {
- for (String item in ['a', 'b', 'c']) {
+ fo^r (String item in ['a', 'b', 'c']) {
print(item);
}
}
''');
- await assertNoAssistAt('for (String');
+ await assertNoAssist();
}
Future<void> test_iterableNotList() async {
await resolveTestCode('''
void f(Iterable<String> items) {
- for (String item in items) {
+ ^for (String item in items) {
print(item);
}
}
''');
- await assertNoAssistAt('for (String');
+ await assertNoAssist();
}
Future<void> test_onDeclaredIdentifier_name() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ for (String ^item in items) {
print(item);
}
}
''');
- await assertHasAssistAt('item in', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (int i = 0; i < items.length; i++) {
String item = items[i];
@@ -83,12 +83,12 @@
Future<void> test_onDeclaredIdentifier_type() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ for (S^tring item in items) {
print(item);
}
}
''');
- await assertHasAssistAt('tring item', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (int i = 0; i < items.length; i++) {
String item = items[i];
@@ -101,12 +101,12 @@
Future<void> test_onFor() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ f^or (String item in items) {
print(item);
}
}
''');
- await assertHasAssistAt('for (String', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (int i = 0; i < items.length; i++) {
String item = items[i];
@@ -119,12 +119,12 @@
Future<void> test_usesI() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ fo^r (String item in items) {
int i = 0;
}
}
''');
- await assertHasAssistAt('for (String', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (int j = 0; j < items.length; j++) {
String item = items[j];
@@ -137,13 +137,13 @@
Future<void> test_usesIJ() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ fo^r (String item in items) {
print(item);
int i = 0, j = 1;
}
}
''');
- await assertHasAssistAt('for (String', '''
+ await assertHasAssist('''
void f(List<String> items) {
for (int k = 0; k < items.length; k++) {
String item = items[k];
@@ -157,12 +157,12 @@
Future<void> test_usesIJK() async {
await resolveTestCode('''
void f(List<String> items) {
- for (String item in items) {
+ ^for (String item in items) {
print(item);
int i, j, k;
}
}
''');
- await assertNoAssistAt('for (String');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_generic_function_syntax_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_generic_function_syntax_test.dart
index 23db9d3..a38870d 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_generic_function_syntax_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_generic_function_syntax_test.dart
@@ -21,83 +21,83 @@
Future<void> test_functionTypeAlias_insideParameterList() async {
await resolveTestCode('''
-typedef String F(int x, int y);
+typedef String F(int ^x, int y);
''');
- await assertNoAssistAt('x,');
+ await assertNoAssist();
}
Future<void> test_functionTypeAlias_noParameterTypes() async {
await resolveTestCode('''
-typedef String F(x);
+type^def String F(x);
''');
- await assertNoAssistAt('def');
+ await assertNoAssist();
}
Future<void> test_functionTypeAlias_noReturnType_noTypeParameters() async {
await resolveTestCode('''
-typedef String F(int x);
+type^def String F(int x);
''');
- await assertHasAssistAt('def', '''
+ await assertHasAssist('''
typedef F = String Function(int x);
''');
}
Future<void> test_functionTypeAlias_noReturnType_typeParameters() async {
await resolveTestCode('''
-typedef F<P, R>(P x);
+type^def F<P, R>(P x);
''');
- await assertHasAssistAt('def', '''
+ await assertHasAssist('''
typedef F<P, R> = Function(P x);
''');
}
Future<void> test_functionTypeAlias_returnType_noTypeParameters() async {
await resolveTestCode('''
-typedef String F(int x);
+type^def String F(int x);
''');
- await assertHasAssistAt('def', '''
+ await assertHasAssist('''
typedef F = String Function(int x);
''');
}
Future<void> test_functionTypeAlias_returnType_typeParameters() async {
await resolveTestCode('''
-typedef R F<P, R>(P x);
+type^def R F<P, R>(P x);
''');
- await assertHasAssistAt('def', '''
+ await assertHasAssist('''
typedef F<P, R> = R Function(P x);
''');
}
Future<void> test_functionTypedParameter_insideParameterList() async {
await resolveTestCode('''
-g(String f(int x, int y)) {}
+g(String f(int ^x, int y)) {}
''');
- await assertNoAssistAt('x,');
+ await assertNoAssist();
}
Future<void> test_functionTypedParameter_noParameterTypes() async {
await resolveTestCode('''
-g(String f(x)) {}
+g(String ^f(x)) {}
''');
- await assertNoAssistAt('f(');
+ await assertNoAssist();
}
Future<void>
test_functionTypedParameter_noReturnType_noTypeParameters() async {
await resolveTestCode('''
-g(f(int x)) {}
+g(^f(int x)) {}
''');
- await assertHasAssistAt('f(', '''
+ await assertHasAssist('''
g(Function(int x) f) {}
''');
}
Future<void> test_functionTypedParameter_returnType() async {
await resolveTestCode('''
-g(String f(int x)) {}
+g(String ^f(int x)) {}
''');
- await assertHasAssistAt('f(', '''
+ await assertHasAssist('''
g(String Function(int x) f) {}
''');
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_getter_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_getter_test.dart
index c70607c..2ce476c 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_getter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_getter_test.dart
@@ -171,10 +171,10 @@
Future<void> test_extension_static() async {
await resolveTestCode('''
extension E on int {
- static int a = 0;
+ static int ^a = 0;
}
''');
- await assertHasAssistAt('a =', '''
+ await assertHasAssist('''
extension E on int {
static int get a => 0;
}
@@ -184,10 +184,10 @@
Future<void> test_extensionType_static() async {
await resolveTestCode('''
extension type A(int i) {
- static int a = 0;
+ static int ^a = 0;
}
''');
- await assertHasAssistAt('a =', '''
+ await assertHasAssist('''
extension type A(int i) {
static int get a => 0;
}
@@ -197,10 +197,10 @@
Future<void> test_late() async {
await resolveTestCode('''
class A {
- late final int f = 1 + 2;
+ late final int ^f = 1 + 2;
}
''');
- await assertHasAssistAt('f =', '''
+ await assertHasAssist('''
class A {
int get f => 1 + 2;
}
@@ -210,10 +210,10 @@
Future<void> test_mixin() async {
await resolveTestCode('''
mixin M {
- final int v = 1;
+ final int ^v = 1;
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
mixin M {
int get v => 1;
}
@@ -223,10 +223,10 @@
Future<void> test_mixin_static() async {
await resolveTestCode('''
mixin M {
- static int a = 0;
+ static int ^a = 0;
}
''');
- await assertHasAssistAt('a =', '''
+ await assertHasAssist('''
mixin M {
static int get a => 0;
}
@@ -237,10 +237,10 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
class A {
- final int foo;
+ final int ^foo;
}
''');
- await assertHasAssistAt('foo', '''
+ await assertHasAssist('''
class A {
int get foo => null;
}
@@ -250,10 +250,10 @@
Future<void> test_notFinal() async {
await resolveTestCode('''
class A {
- int foo = 1;
+ int ^foo = 1;
}
''');
- await assertHasAssistAt('foo', '''
+ await assertHasAssist('''
class A {
int get foo => 1;
}
@@ -263,19 +263,19 @@
Future<void> test_notSingleField() async {
await resolveTestCode('''
class A {
- final int foo = 1, bar = 2;
+ final int ^foo = 1, bar = 2;
}
''');
- await assertNoAssistAt('foo');
+ await assertNoAssist();
}
Future<void> test_noType() async {
await resolveTestCode('''
class A {
- final foo = 42;
+ final ^foo = 42;
}
''');
- await assertHasAssistAt('foo =', '''
+ await assertHasAssist('''
class A {
get foo => 42;
}
@@ -285,10 +285,10 @@
Future<void> test_static() async {
await resolveTestCode('''
class A {
- static int foo = 1;
+ static int ^foo = 1;
}
''');
- await assertHasAssistAt('foo', '''
+ await assertHasAssist('''
class A {
static int get foo => 1;
}
@@ -300,10 +300,10 @@
const myAnnotation = const Object();
class A {
@myAnnotation
- final int foo = 1 + 2;
+ final int ^foo = 1 + 2;
}
''');
- await assertHasAssistAt('foo =', '''
+ await assertHasAssist('''
const myAnnotation = const Object();
class A {
@myAnnotation
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_empty_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_empty_test.dart
index e8650da..168ebe2 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_empty_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_empty_test.dart
@@ -23,10 +23,10 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(String str) {
- ~str.isEmpty;
+ ~str.^isEmpty;
}
''');
- await assertNoAssistAt('isEmpty;');
+ await assertNoAssist();
}
Future<void> test_noIsNotEmpty() async {
@@ -35,37 +35,37 @@
bool get isEmpty => false;
}
void f(A a) {
- !a.isEmpty;
+ !a.^isEmpty;
}
''');
- await assertNoAssistAt('isEmpty;');
+ await assertNoAssist();
}
Future<void> test_notInPrefixExpression() async {
await resolveTestCode('''
void f(String str) {
- str.isEmpty;
+ str.^isEmpty;
}
''');
- await assertNoAssistAt('isEmpty;');
+ await assertNoAssist();
}
Future<void> test_notIsEmpty() async {
await resolveTestCode('''
void f(int p) {
- !p.isEven;
+ !p.^isEven;
}
''');
- await assertNoAssistAt('isEven;');
+ await assertNoAssist();
}
Future<void> test_on_isEmpty() async {
await resolveTestCode('''
void f(String str) {
- !str.isEmpty;
+ !str.^isEmpty;
}
''');
- await assertHasAssistAt('isEmpty', '''
+ await assertHasAssist('''
void f(String str) {
str.isNotEmpty;
}
@@ -75,10 +75,10 @@
Future<void> test_on_str() async {
await resolveTestCode('''
void f(String str) {
- !str.isEmpty;
+ !^str.isEmpty;
}
''');
- await assertHasAssistAt('str.', '''
+ await assertHasAssist('''
void f(String str) {
str.isNotEmpty;
}
@@ -88,10 +88,10 @@
Future<void> test_propertyAccess() async {
await resolveTestCode('''
void f(String str) {
- !'text'.isEmpty;
+ !'text'.^isEmpty;
}
''');
- await assertHasAssistAt('isEmpty', '''
+ await assertHasAssist('''
void f(String str) {
'text'.isNotEmpty;
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_test.dart
index 9c3260d..7c45585 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_into_is_not_test.dart
@@ -22,10 +22,10 @@
Future<void> test_childOfIs_left() async {
await resolveTestCode('''
void f(p) {
- !(p is String);
+ !(^p is String);
}
''');
- await assertHasAssistAt('p is', '''
+ await assertHasAssist('''
void f(p) {
p is! String;
}
@@ -35,10 +35,10 @@
Future<void> test_childOfIs_right() async {
await resolveTestCode('''
void f(p) {
- !(p is String);
+ !(p is ^String);
}
''');
- await assertHasAssistAt('String)', '''
+ await assertHasAssist('''
void f(p) {
p is! String;
}
@@ -48,10 +48,10 @@
Future<void> test_is() async {
await resolveTestCode('''
void f(p) {
- !(p is String);
+ !(p ^is String);
}
''');
- await assertHasAssistAt('is String', '''
+ await assertHasAssist('''
void f(p) {
p is! String;
}
@@ -61,19 +61,19 @@
Future<void> test_is_alreadyIsNot() async {
await resolveTestCode('''
void f(p) {
- p is! String;
+ p ^is! String;
}
''');
- await assertNoAssistAt('is!');
+ await assertNoAssist();
}
Future<void> test_is_higherPrecedencePrefix() async {
await resolveTestCode('''
void f(p) {
- !!(p is String);
+ !!(p ^is String);
}
''');
- await assertHasAssistAt('is String', '''
+ await assertHasAssist('''
void f(p) {
!(p is! String);
}
@@ -83,28 +83,28 @@
Future<void> test_is_noEnclosingParenthesis() async {
await resolveTestCode('''
void f(p) {
- p is String;
+ p ^is String;
}
''');
- await assertNoAssistAt('is String');
+ await assertNoAssist();
}
Future<void> test_is_noPrefix() async {
await resolveTestCode('''
void f(p) {
- (p is String);
+ (p ^is String);
}
''');
- await assertNoAssistAt('is String');
+ await assertNoAssist();
}
Future<void> test_is_not_higherPrecedencePrefix() async {
await resolveTestCode('''
void f(p) {
- !!(p is String);
+ !^!(p is String);
}
''');
- await assertHasAssistAt('!(p', '''
+ await assertHasAssist('''
void f(p) {
!(p is! String);
}
@@ -114,29 +114,29 @@
Future<void> test_is_notIsExpression() async {
await resolveTestCode('''
void f(p) {
- 123 + 456;
+ ^123 + 456;
}
''');
- await assertNoAssistAt('123 +');
+ await assertNoAssist();
}
Future<void> test_is_notTheNotOperator() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(p) {
- ++(p is String);
+ ++(p ^is String);
}
''');
- await assertNoAssistAt('is String');
+ await assertNoAssist();
}
Future<void> test_not() async {
await resolveTestCode('''
void f(p) {
- !(p is String);
+ ^!(p is String);
}
''');
- await assertHasAssistAt('!(p', '''
+ await assertHasAssist('''
void f(p) {
p is! String;
}
@@ -146,47 +146,47 @@
Future<void> test_not_alreadyIsNot() async {
await resolveTestCode('''
void f(p) {
- !(p is! String);
+ ^!(p is! String);
}
''');
- await assertNoAssistAt('!(p');
+ await assertNoAssist();
}
Future<void> test_not_noEnclosingParenthesis() async {
await resolveTestCode('''
void f(p) {
- !p;
+ ^!p;
}
''');
- await assertNoAssistAt('!p');
+ await assertNoAssist();
}
Future<void> test_not_notIsExpression() async {
await resolveTestCode('''
void f(p) {
- !(p == null);
+ ^!(p == null);
}
''');
- await assertNoAssistAt('!(p');
+ await assertNoAssist();
}
Future<void> test_not_notTheNotOperator() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(p) {
- ++(p is String);
+ ^++(p is String);
}
''');
- await assertNoAssistAt('++(');
+ await assertNoAssist();
}
Future<void> test_parentheses() async {
await resolveTestCode('''
void f(p) {
- !(p is String);
+ !^(p is String);
}
''');
- await assertHasAssistAt('(p is', '''
+ await assertHasAssist('''
void f(p) {
p is! String;
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart
index 51f2df6..fd8a247 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_part_of_to_uri_test.dart
@@ -31,12 +31,12 @@
addTestSource('''
// @dart = 3.4
// preEnhancedParts
-part of foo;
+part of f^oo;
''');
await analyzeTestPackageFiles();
await resolveTestFile();
- await assertHasAssistAt('foo', '''
+ await assertHasAssist('''
// @dart = 3.4
// preEnhancedParts
part of '../foo.dart';
@@ -55,12 +55,12 @@
addTestSource('''
// @dart = 3.4
// preEnhancedParts
-part of foo;
+part of f^oo;
''');
await analyzeTestPackageFiles();
await resolveTestFile();
- await assertHasAssistAt('foo', '''
+ await assertHasAssist('''
// @dart = 3.4
// preEnhancedParts
part of 'foo.dart';
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_double_quoted_string_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_double_quoted_string_test.dart
index 128c078..4554f73 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_double_quoted_string_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_double_quoted_string_test.dart
@@ -22,10 +22,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote() async {
await resolveTestCode(r'''
void f(int b) {
- print('a \'$b\'');
+ print(^'a \'$b\'');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print("a '$b'");
}
@@ -35,10 +35,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote2() async {
await resolveTestCode(r'''
void f(int b) {
- print('a \"$b\"');
+ print(^'a \"$b\"');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print("a \"$b\"");
}
@@ -48,10 +48,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote2_left() async {
await resolveTestCode(r'''
void f(int b) {
- print('a \"$b"');
+ print(^'a \"$b"');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print("a \"$b\"");
}
@@ -61,10 +61,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote2_right() async {
await resolveTestCode(r'''
void f(int b) {
- print('a "$b\"');
+ print(^'a "$b\"');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print("a \"$b\"");
}
@@ -74,10 +74,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote3() async {
await resolveTestCode(r'''
void f(int b) {
- print(' \\"$b\\"');
+ print(^' \\"$b\\"');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print(" \\\"$b\\\"");
}
@@ -87,10 +87,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote4() async {
await resolveTestCode(r'''
void f(int b) {
- print(' \\\'$b\\\'');
+ print(^' \\\'$b\\\'');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print(" \\'$b\\'");
}
@@ -100,10 +100,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote5() async {
await resolveTestCode(r'''
void f(int b) {
- print(' \\\\"$b\\\\"');
+ print(^' \\\\"$b\\\\"');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print(" \\\\\"$b\\\\\"");
}
@@ -113,10 +113,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote6() async {
await resolveTestCode(r'''
void f(int b) {
- print(' \\\\\'$b\\\\\'');
+ print(^' \\\\\'$b\\\\\'');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print(" \\\\'$b\\\\'");
}
@@ -126,10 +126,10 @@
Future<void> test_interpolation_surroundedByQuotes() async {
await resolveTestCode(r'''
void f(int b) {
- print('a "$b"');
+ print(^'a "$b"');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f(int b) {
print("a \"$b\"");
}
@@ -139,10 +139,10 @@
Future<void> test_one_backslash() async {
await resolveTestCode(r'''
void f() {
- print('a\'b\'c');
+ print(^'a\'b\'c');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f() {
print("a'b'c");
}
@@ -152,10 +152,10 @@
Future<void> test_one_embeddedTarget() async {
await resolveTestCode('''
void f() {
- print('a"b"c');
+ print(^'a"b"c');
}
''');
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f() {
print("a\"b\"c");
}
@@ -165,10 +165,10 @@
Future<void> test_one_enclosingTarget() async {
await resolveTestCode('''
void f() {
- print("abc");
+ print(^"abc");
}
''');
- await assertNoAssistAt('"');
+ await assertNoAssist();
}
Future<void> test_one_interpolation() async {
@@ -176,10 +176,10 @@
void f() {
var b = "b";
var c = "c";
- print('a $b-${c} d');
+ print(^'a $b-${c} d');
}
''');
- await assertHasAssistAt(r"'", r'''
+ await assertHasAssist(r'''
void f() {
var b = "b";
var c = "c";
@@ -192,19 +192,19 @@
verifyNoTestUnitErrors = false;
await resolveTestCode(r'''
void f(int a) {
- '$a
+ ^'$a
}
''');
- await assertNoAssistAt("'");
+ await assertNoAssist();
}
Future<void> test_one_raw() async {
await resolveTestCode('''
void f() {
- print(r'abc');
+ print(r^'abc');
}
''');
- await assertHasAssistAt("'", '''
+ await assertHasAssist('''
void f() {
print(r"abc");
}
@@ -214,10 +214,10 @@
Future<void> test_one_simple() async {
await resolveTestCode('''
void f() {
- print('abc');
+ print(^'abc');
}
''');
- await assertHasAssistAt("'", '''
+ await assertHasAssist('''
void f() {
print("abc");
}
@@ -228,21 +228,21 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- '
+ ^'
}
''');
- await assertNoAssistAt("'");
+ await assertNoAssist();
}
Future<void> test_raw_multiLine_manyQuotes() async {
await resolveTestCode("""
void f() {
- print(r'''
+ print(^r'''
""\"""\"""\"""
''');
}
""");
- await assertHasAssistAt("r'", r'''
+ await assertHasAssist(r'''
void f() {
print("""
""\"""\"""\"""
@@ -254,11 +254,11 @@
Future<void> test_raw_multiLine_threeQuotes() async {
await resolveTestCode("""
void f() {
- print(r'''
+ print(^r'''
""\"''');
}
""");
- await assertHasAssistAt("r'", r'''
+ await assertHasAssist(r'''
void f() {
print("""
""\"""");
@@ -269,13 +269,13 @@
Future<void> test_raw_multiLine_twoQuotes() async {
await resolveTestCode(r"""
void f() {
- print(r'''
+ print(^r'''
''\''\'
""
''');
}
""");
- await assertHasAssistAt("r'", '''
+ await assertHasAssist('''
void f() {
print(r"""
''\''\'
@@ -288,11 +288,11 @@
Future<void> test_raw_multiLine_twoQuotesAtEnd() async {
await resolveTestCode("""
void f() {
- print(r'''
+ print(^r'''
""''');
}
""");
- await assertHasAssistAt("r'", r'''
+ await assertHasAssist(r'''
void f() {
print("""
"\"""");
@@ -303,10 +303,10 @@
Future<void> test_raw_nonEscapedChars() async {
await resolveTestCode(r'''
void f() {
- print(r'\$"');
+ print(^r'\$"');
}
''');
- await assertHasAssistAt("r'", r'''
+ await assertHasAssist(r'''
void f() {
print("\\\$\"");
}
@@ -316,10 +316,10 @@
Future<void> test_three_embeddedTarget() async {
await resolveTestCode("""
void f() {
- print('''a""\"c''');
+ print(^'''a""\"c''');
}
""");
- await assertHasAssistAt("'", r'''
+ await assertHasAssist(r'''
void f() {
print("""a""\"c""");
}
@@ -329,10 +329,10 @@
Future<void> test_three_enclosingTarget() async {
await resolveTestCode('''
void f() {
- print("""abc""");
+ print(^"""abc""");
}
''');
- await assertNoAssistAt('"');
+ await assertNoAssist();
}
Future<void> test_three_interpolation() async {
@@ -340,10 +340,10 @@
void f() {
var b = "b";
var c = "c";
- print('''a $b-${c} d''');
+ print(^'''a $b-${c} d''');
}
""");
- await assertHasAssistAt(r"'", r'''
+ await assertHasAssist(r'''
void f() {
var b = "b";
var c = "c";
@@ -355,10 +355,10 @@
Future<void> test_three_raw() async {
await resolveTestCode("""
void f() {
- print(r'''abc''');
+ print(r^'''abc''');
}
""");
- await assertHasAssistAt("'", '''
+ await assertHasAssist('''
void f() {
print(r"""abc""");
}
@@ -368,10 +368,10 @@
Future<void> test_three_simple() async {
await resolveTestCode("""
void f() {
- print('''abc''');
+ print(^'''abc''');
}
""");
- await assertHasAssistAt("'", '''
+ await assertHasAssist('''
void f() {
print("""abc""");
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_field_parameter_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_field_parameter_test.dart
index f616eab..e3b9e80 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_field_parameter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_field_parameter_test.dart
@@ -24,10 +24,10 @@
class A {
int aaa2;
int bbb2;
- A(int aaa) : aaa2 = aaa, bbb2 = aaa;
+ A(int ^aaa) : aaa2 = aaa, bbb2 = aaa;
}
''');
- await assertNoAssistAt('aaa)');
+ await assertNoAssist();
}
Future<void> test_firstInitializer() async {
@@ -35,10 +35,10 @@
class A {
int aaa2;
int bbb2;
- A(int aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
+ A(int ^aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
}
''');
- await assertHasAssistAt('aaa, ', '''
+ await assertHasAssist('''
class A {
int aaa2;
int bbb2;
@@ -51,21 +51,21 @@
await resolveTestCode('''
class A {
int aaa2;
- A(int aaa) : aaa2 = aaa * 2;
+ A(int ^aaa) : aaa2 = aaa * 2;
}
''');
- await assertNoAssistAt('aaa)');
+ await assertNoAssist();
}
Future<void> test_onParameterName_inInitializer() async {
await resolveTestCode('''
class A {
int test2;
- A(int test) : test2 = test {
+ A(int test) : test2 = ^test {
}
}
''');
- await assertHasAssistAt('test {', '''
+ await assertHasAssist('''
class A {
int test2;
A(this.test2) {
@@ -78,11 +78,11 @@
await resolveTestCode('''
class A {
int test;
- A(int test) : test = test {
+ A(int ^test) : test = test {
}
}
''');
- await assertHasAssistAt('test)', '''
+ await assertHasAssist('''
class A {
int test;
A(this.test) {
@@ -96,10 +96,10 @@
class A {
int aaa2;
int bbb2;
- A(int aaa, int bbb) : aaa2 = aaa, bbb2 = bbb;
+ A(int aaa, int ^bbb) : aaa2 = aaa, bbb2 = bbb;
}
''');
- await assertHasAssistAt('bbb)', '''
+ await assertHasAssist('''
class A {
int aaa2;
int bbb2;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_chain_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_chain_test.dart
index 5547ceb..5ef6a76 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_chain_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_chain_test.dart
@@ -22,7 +22,7 @@
Future<void> test_hasBreak() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ ^switch (x) {
case int():
0;
break;
@@ -31,7 +31,7 @@
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(Object? x) {
if (x case int()) {
0;
@@ -45,17 +45,17 @@
Future<void> test_noBody() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ ^switch (x) {
}
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_noDefault() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ swi^tch (x) {
case int():
0;
case double():
@@ -63,7 +63,7 @@
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(Object? x) {
if (x case int()) {
0;
@@ -77,7 +77,7 @@
Future<void> test_noDefault_hasWhen() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ swi^tch (x) {
case int() when x > 0:
0;
case double():
@@ -85,7 +85,7 @@
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(Object? x) {
if (x case int() when x > 0) {
0;
@@ -99,14 +99,14 @@
Future<void> test_noStatements() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ swit^ch (x) {
case int():
0;
case double():
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(Object? x) {
if (x case int()) {
0;
@@ -119,14 +119,14 @@
Future<void> test_sharedBody() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ ^switch (x) {
case int():
case double():
0;
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(Object? x) {
if (x case int() || double()) {
0;
@@ -138,20 +138,20 @@
Future<void> test_sharedBody_hasWhen() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ sw^itch (x) {
case int() when x > 0:
case double():
0;
}
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_withDefault() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ ^switch (x) {
case int():
0;
case double():
@@ -161,7 +161,7 @@
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(Object? x) {
if (x case int()) {
0;
@@ -177,7 +177,7 @@
Future<void> test_withDefault_shared() async {
await resolveTestCode('''
void f(Object? x) {
- switch (x) {
+ swi^tch (x) {
case int():
0;
case double():
@@ -186,6 +186,6 @@
}
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_test.dart
index 02d1607..f78eddf 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_if_case_statement_test.dart
@@ -23,14 +23,14 @@
await resolveTestCode('''
void f(A a) {
var y = a.x;
- if (y is List<int>) {}
+ ^if (y is List<int>) {}
}
class A {
Object? x;
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(A a) {
if (a.x case List<int> y) {}
}
@@ -45,14 +45,14 @@
await resolveTestCode('''
void f(A a) {
final y = a.x;
- if (y is int) {}
+ ^if (y is int) {}
}
class A {
Object? x;
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(A a) {
if (a.x case final int y) {}
}
@@ -67,7 +67,7 @@
await resolveTestCode('''
void f(A a) {
var y = a.x;
- if (y is int) {}
+ ^if (y is int) {}
y;
}
@@ -75,14 +75,14 @@
Object? x;
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_isType_hasReference_inElse() async {
await resolveTestCode('''
void f(A a) {
var y = a.x;
- if (y is int) {} else {
+ ^if (y is int) {} else {
y;
}
}
@@ -91,7 +91,7 @@
Object? x;
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_isType_language219() async {
@@ -99,37 +99,37 @@
// @dart = 2.19
void f(A a) {
var y = a.x;
- if (y is List<int>) {}
+ ^if (y is List<int>) {}
}
class A {
Object? x;
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_isType_previousStatement_absent() async {
await resolveTestCode('''
void f(Object? x) {
- if (x is int) {}
+ ^if (x is int) {}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_notEqNull() async {
await resolveTestCode('''
void f(A a) {
var y = a.x;
- if (y != null) {}
+ ^if (y != null) {}
}
class A {
int? x;
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(A a) {
if (a.x case var y?) {}
}
@@ -144,14 +144,14 @@
await resolveTestCode('''
void f(A a) {
final y = a.x;
- if (y != null) {}
+ ^if (y != null) {}
}
class A {
int? x;
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(A a) {
if (a.x case final y?) {}
}
@@ -166,7 +166,7 @@
await resolveTestCode('''
void f(A a) {
final y = a.x;
- if (y != null) {}
+ ^if (y != null) {}
y;
}
@@ -174,14 +174,14 @@
int? x;
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_notEqNull_hasReference_inElse() async {
await resolveTestCode('''
void f(A a) {
final y = a.x;
- if (y != null) {} else {
+ i^f (y != null) {} else {
y;
}
}
@@ -190,39 +190,39 @@
int? x;
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_notEqNull_previousStatement_absent() async {
await resolveTestCode('''
void f(int? x) {
- if (x != null) {}
+ i^f (x != null) {}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_notEqNull_previousStatement_multipleDeclarations() async {
await resolveTestCode('''
void f(A a) {
final x = a.x, x2 = 0;
- if (x != null) {}
+ ^if (x != null) {}
}
class A {
int? x;
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_notEqNull_previousStatement_notDeclaration() async {
await resolveTestCode('''
void f(int? x) {
x;
- if (x != null) {}
+ i^f (x != null) {}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_multiline_string_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_multiline_string_test.dart
index e18bece..d5ff364 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_multiline_string_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_multiline_string_test.dart
@@ -22,10 +22,10 @@
Future<void> test_doubleQuoted() async {
await resolveTestCode('''
void f() {
- print("abc");
+ print("^abc");
}
''');
- await assertHasAssistAt('abc', '''
+ await assertHasAssist('''
void f() {
print("""
abc""");
@@ -36,10 +36,10 @@
Future<void> test_doubleQuoted_alreadyMultiline() async {
await resolveTestCode('''
void f() {
- print("""abc""");
+ print("""^abc""");
}
''');
- await assertNoAssistAt('abc');
+ await assertNoAssist();
}
Future<void> test_doubleQuoted_interpolation_expressionElement() async {
@@ -47,10 +47,10 @@
void f() {
var b = 'b';
var c = 'c';
- print("a $b - ${c} d");
+ print("a $b - ${^c} d");
}
""");
- await assertNoAssistAt(r'c}');
+ await assertNoAssist();
}
Future<void> test_doubleQuoted_interpolation_stringElement_begin() async {
@@ -58,10 +58,10 @@
void f() {
var b = 'b';
var c = 'c';
- print("a $b - ${c} d");
+ print(^"a $b - ${c} d");
}
""");
- await assertHasAssistAt('"a ', r'''
+ await assertHasAssist(r'''
void f() {
var b = 'b';
var c = 'c';
@@ -76,10 +76,10 @@
void f() {
var b = 'b';
var c = 'c';
- print("a $b - ${c} d");
+ print("a $b ^- ${c} d");
}
""");
- await assertHasAssistAt('- ', r'''
+ await assertHasAssist(r'''
void f() {
var b = 'b';
var c = 'c';
@@ -92,10 +92,10 @@
Future<void> test_doubleQuoted_raw() async {
await resolveTestCode('''
void f() {
- print(r"abc");
+ print(r"^abc");
}
''');
- await assertHasAssistAt('abc', '''
+ await assertHasAssist('''
void f() {
print(r"""
abc""");
@@ -107,29 +107,29 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- "abc
+ ^"abc
}
''');
- await assertNoAssistAt('"');
+ await assertNoAssist();
}
Future<void> test_doubleQuoted_unterminated_empty() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- "
+ ^"
}
''');
- await assertNoAssistAt('"');
+ await assertNoAssist();
}
Future<void> test_singleQuoted() async {
await resolveTestCode('''
void f() {
- print('abc');
+ print('^abc');
}
''');
- await assertHasAssistAt('abc', """
+ await assertHasAssist("""
void f() {
print('''
abc''');
@@ -142,10 +142,10 @@
void f() {
var b = 'b';
var c = 'c';
- print('a $b - ${c} d');
+ print('a $b - ${^c} d');
}
""");
- await assertNoAssistAt(r'c}');
+ await assertNoAssist();
}
Future<void> test_singleQuoted_interpolation_stringElement_begin() async {
@@ -153,10 +153,10 @@
void f() {
var b = 'b';
var c = 'c';
- print('a $b - ${c} d');
+ print(^'a $b - ${c} d');
}
""");
- await assertHasAssistAt("'a ", r"""
+ await assertHasAssist(r"""
void f() {
var b = 'b';
var c = 'c';
@@ -171,10 +171,10 @@
void f() {
var b = 'b';
var c = 'c';
- print('a $b - ${c} d');
+ print('a $b ^- ${c} d');
}
""");
- await assertHasAssistAt('- ', r"""
+ await assertHasAssist(r"""
void f() {
var b = 'b';
var c = 'c';
@@ -187,10 +187,10 @@
Future<void> test_singleQuoted_raw() async {
await resolveTestCode('''
void f() {
- print(r'abc');
+ print(r'^abc');
}
''');
- await assertHasAssistAt('abc', """
+ await assertHasAssist("""
void f() {
print(r'''
abc''');
@@ -202,19 +202,19 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- 'abc
+ ^'abc
}
''');
- await assertNoAssistAt("'");
+ await assertNoAssist();
}
Future<void> test_singleQuoted_unterminated_empty() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- '
+ ^'
}
''');
- await assertNoAssistAt("'");
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_normal_parameter_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_normal_parameter_test.dart
index 90973a6..ac40750 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_normal_parameter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_normal_parameter_test.dart
@@ -23,11 +23,11 @@
await resolveTestCode('''
class A {
var test;
- A(this.test) {
+ A(this.t^est) {
}
}
''');
- await assertHasAssistAt('test)', '''
+ await assertHasAssist('''
class A {
var test;
A(test) : test = test {
@@ -40,11 +40,11 @@
await resolveTestCode('''
class A {
int test;
- A(this.test) {
+ A(this.te^st) {
}
}
''');
- await assertHasAssistAt('test)', '''
+ await assertHasAssist('''
class A {
int test;
A(int test) : test = test {
@@ -58,10 +58,10 @@
class A {
double aaa;
int bbb;
- A(this.bbb) : aaa = 1.0;
+ A(this.bb^b) : aaa = 1.0;
}
''');
- await assertHasAssistAt('bbb)', '''
+ await assertHasAssist('''
class A {
double aaa;
int bbb;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_null_aware_test.dart
index 03ca0af..42c5e7a 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_null_aware_test.dart
@@ -25,9 +25,9 @@
abstract class A {
int m();
}
-int? f(A? a1, A a2) => a1 == null ? null : a2.m();
+int? f(A? a1, A a2) => a1 == null ^? null : a2.m();
''');
- await assertNoAssistAt('? n');
+ await assertNoAssist();
}
Future<void> test_equal_notComparedToNull() async {
@@ -35,9 +35,9 @@
abstract class A {
int m();
}
-int f(A a1, A a2) => a1 == a2 ? a2.m() : a1.m();
+int f(A a1, A a2) => a1 == a2 ^? a2.m() : a1.m();
''');
- await assertNoAssistAt('?');
+ await assertNoAssist();
}
Future<void> test_equal_notIdentifier() async {
@@ -45,9 +45,9 @@
abstract class A {
int? m();
}
-int? f(A a) => a.m() == null ? 0 : a.m();
+int? f(A a) => a.m() == null ^? 0 : a.m();
''');
- await assertNoAssistAt('?');
+ await assertNoAssist();
}
Future<void> test_equal_notInvocation() async {
@@ -55,9 +55,9 @@
abstract class A {
int operator +(A a);
}
-int? f(A? a1) => a1 == null ? null : a1 + a1;
+int? f(A? a1) => a1 == null ^? null : a1 + a1;
''');
- await assertNoAssistAt('?');
+ await assertNoAssist();
}
Future<void> test_equal_notNullPreserving() async {
@@ -65,9 +65,9 @@
abstract class A {
int m();
}
-int f(A? a1, A a2) => a1 == null ? a2.m() : a1.m();
+int f(A? a1, A a2) => a1 == null ^? a2.m() : a1.m();
''');
- await assertNoAssistAt('?');
+ await assertNoAssist();
}
Future<void> test_equal_notPeriod() async {
@@ -76,9 +76,9 @@
abstract class A {
int m();
}
-int? f(A? a1) => a1 == null ? null : a1?.m();
+int? f(A? a1) => a1 == null ^? null : a1?.m();
''');
- await assertHasAssistAt('? n', '''
+ await assertHasAssist('''
abstract class A {
int m();
}
@@ -91,9 +91,9 @@
abstract class A {
int m();
}
-int? f(A? a) => null == a ? null : a.m();
+int? f(A? a) => null == a ^? null : a.m();
''');
- await assertHasAssistAt('? n', '''
+ await assertHasAssist('''
abstract class A {
int m();
}
@@ -108,7 +108,7 @@
abstract class A {
int m();
}
-int? f(A? a) => null == a ? null : a.m();
+int? f(A? a) => null == a ^? null : a.m();
''');
await assertNoAssist();
}
@@ -118,9 +118,9 @@
abstract class A {
int m();
}
-int? f(A? a) => a == null ? null : a.m();
+int? f(A? a) => a == null ^? null : a.m();
''');
- await assertHasAssistAt('? n', '''
+ await assertHasAssist('''
abstract class A {
int m();
}
@@ -133,9 +133,9 @@
class A {
int p = 0;
}
-int? f(A? a) => null == a ? null : a.p;
+int? f(A? a) => null == a ^? null : a.p;
''');
- await assertHasAssistAt('? n', '''
+ await assertHasAssist('''
class A {
int p = 0;
}
@@ -149,10 +149,10 @@
await resolveTestCode('''
foo() {
var range = 1;
- var rangeStart = range != null ? toOffset() : null;
+ var rangeStart = range != null ? toOffset() :^ null;
}
''');
- await assertNoAssistAt(' null;');
+ await assertNoAssist();
}
Future<void> test_notEqual_notNullPreserving() async {
@@ -160,9 +160,9 @@
abstract class A {
int m();
}
-int f(A? a1, A a2) => a1 != null ? a1.m() : a2.m();
+int f(A? a1, A a2) => a1 != null ^? a1.m() : a2.m();
''');
- await assertNoAssistAt('?');
+ await assertNoAssist();
}
Future<void> test_notEqual_nullOnLeft() async {
@@ -170,9 +170,9 @@
abstract class A {
int m();
}
-int? f(A? a) => null != a ? a.m() : null;
+int? f(A? a) => null != a ^? a.m() : null;
''');
- await assertHasAssistAt('? a.', '''
+ await assertHasAssist('''
abstract class A {
int m();
}
@@ -185,9 +185,9 @@
abstract class A {
int m();
}
-int? f(A? a) => a != null ? a.m() : null;
+int? f(A? a) => a != null ^? a.m() : null;
''');
- await assertHasAssistAt('? a.', '''
+ await assertHasAssist('''
abstract class A {
int m();
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_package_import_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_package_import_test.dart
index f3e007b..02853e5 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_package_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_package_import_test.dart
@@ -23,10 +23,10 @@
newFile('$testPackageLibPath/foo.dart', '');
await resolveTestCode('''
-import 'foo.dart';
+^import 'foo.dart';
''');
// Validate assist is on import keyword too.
- await assertHasAssistAt('import', '''
+ await assertHasAssist('''
import 'package:test/foo.dart';
''');
}
@@ -35,9 +35,9 @@
newFile('$testPackageLibPath/foo.dart', '');
await resolveTestCode('''
-import 'foo.dart';
+import '^foo.dart';
''');
- await assertHasAssistAt('foo.dart', '''
+ await assertHasAssist('''
import 'package:test/foo.dart';
''');
}
@@ -45,30 +45,30 @@
Future<void> test_invalidUri() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-import ':[invalidUri]';
+import ':[^invalidUri]';
''');
- await assertNoAssistAt('invalid');
+ await assertNoAssist();
}
Future<void> test_nonPackage_Uri() async {
newFile('$testPackageLibPath/foo.dart', '');
testFilePath = convertPath('$testPackageLibPath/src/test.dart');
await resolveTestCode('''
-import 'dart:core';
+/*0*/import '/*1*/dart:core';
''');
- await assertNoAssistAt('dart:core');
- await assertNoAssistAt('import');
+ await assertNoAssist();
+ await assertNoAssist(1);
}
Future<void> test_packageUri() async {
newFile('$testPackageLibPath/foo.dart', '');
await resolveTestCode('''
-import 'package:test/foo.dart';
+/*0*/import 'package:test//*1*/foo.dart';
''');
- await assertNoAssistAt('foo.dart');
- await assertNoAssistAt('import');
+ await assertNoAssist();
+ await assertNoAssist(1);
}
Future<void> test_path() async {
@@ -77,9 +77,9 @@
testFilePath = convertPath('$testPackageLibPath/src/test.dart');
await resolveTestCode('''
-import '../foo/bar.dart';
+import '../foo/^bar.dart';
''');
- await assertHasAssistAt('bar.dart', '''
+ await assertHasAssist('''
import 'package:test/foo/bar.dart';
''');
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_single_quoted_string_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_single_quoted_string_test.dart
index 9fc7738..43e22ac 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_single_quoted_string_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_single_quoted_string_test.dart
@@ -23,10 +23,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote() async {
await resolveTestCode(r'''
void f(int b) {
- print("a \'$b\'");
+ print(^"a \'$b\'");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print('a \'$b\'');
}
@@ -36,10 +36,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote2() async {
await resolveTestCode(r'''
void f(int b) {
- print("a \"$b\"");
+ print(^"a \"$b\"");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print('a "$b"');
}
@@ -49,10 +49,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote2_left() async {
await resolveTestCode(r'''
void f(int b) {
- print("a \'$b'");
+ print(^"a \'$b'");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print('a \'$b\'');
}
@@ -62,10 +62,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote2_right() async {
await resolveTestCode(r'''
void f(int b) {
- print("a '$b\'");
+ print(^"a '$b\'");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print('a \'$b\'');
}
@@ -75,10 +75,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote3() async {
await resolveTestCode(r'''
void f(int b) {
- print(" \\'$b\\'");
+ print(^" \\'$b\\'");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print(' \\\'$b\\\'');
}
@@ -88,10 +88,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote4() async {
await resolveTestCode(r'''
void f(int b) {
- print(" \\\"$b\\\"");
+ print(^" \\\"$b\\\"");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print(' \\"$b\\"');
}
@@ -101,10 +101,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote5() async {
await resolveTestCode(r'''
void f(int b) {
- print(" \\\\'$b\\\\'");
+ print(^" \\\\'$b\\\\'");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print(' \\\\\'$b\\\\\'');
}
@@ -114,10 +114,10 @@
Future<void> test_interpolation_surroundedByEscapedQuote6() async {
await resolveTestCode(r'''
void f(int b) {
- print(" \\\\\"$b\\\\\"");
+ print(^" \\\\\"$b\\\\\"");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print(' \\\\"$b\\\\"');
}
@@ -127,10 +127,10 @@
Future<void> test_interpolation_surroundedByQuotes() async {
await resolveTestCode(r'''
void f(int b) {
- print("a '$b'");
+ print(^"a '$b'");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f(int b) {
print('a \'$b\'');
}
@@ -140,10 +140,10 @@
Future<void> test_one_backslash() async {
await resolveTestCode(r'''
void f() {
- print("a\"b\"c");
+ print(^"a\"b\"c");
}
''');
- await assertHasAssistAt('"', r"""
+ await assertHasAssist(r"""
void f() {
print('a"b"c');
}
@@ -153,10 +153,10 @@
Future<void> test_one_embeddedTarget() async {
await resolveTestCode('''
void f() {
- print("a'b'c");
+ print(^"a'b'c");
}
''');
- await assertHasAssistAt('"', r'''
+ await assertHasAssist(r'''
void f() {
print('a\'b\'c');
}
@@ -166,10 +166,10 @@
Future<void> test_one_enclosingTarget() async {
await resolveTestCode('''
void f() {
- print('abc');
+ print(^'abc');
}
''');
- await assertNoAssistAt("'");
+ await assertNoAssist();
}
Future<void> test_one_interpolation() async {
@@ -177,10 +177,10 @@
void f() {
var b = 'b';
var c = 'c';
- print("a $b-${c} d");
+ print(^"a $b-${c} d");
}
''');
- await assertHasAssistAt(r'"', r'''
+ await assertHasAssist(r'''
void f() {
var b = 'b';
var c = 'c';
@@ -193,19 +193,19 @@
verifyNoTestUnitErrors = false;
await resolveTestCode(r'''
void f(int a) {
- "$a
+ ^"$a
}
''');
- await assertNoAssistAt('"');
+ await assertNoAssist();
}
Future<void> test_one_raw() async {
await resolveTestCode('''
void f() {
- print(r"abc");
+ print(^r"abc");
}
''');
- await assertHasAssistAt('"', '''
+ await assertHasAssist('''
void f() {
print(r'abc');
}
@@ -215,10 +215,10 @@
Future<void> test_one_simple() async {
await resolveTestCode('''
void f() {
- print("abc");
+ print(^"abc");
}
''');
- await assertHasAssistAt('"', '''
+ await assertHasAssist('''
void f() {
print('abc');
}
@@ -230,7 +230,7 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- print("abc");
+ print(^"abc");
}
''');
await assertNoAssist();
@@ -240,21 +240,21 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f() {
- "
+ ^"
}
''');
- await assertNoAssistAt('"');
+ await assertNoAssist();
}
Future<void> test_raw_multiLine_manyQuotes() async {
await resolveTestCode('''
void f() {
- print(r"""
+ print(^r"""
''\'''\'''\'''
""");
}
''');
- await assertHasAssistAt('r"', r"""
+ await assertHasAssist(r"""
void f() {
print('''
''\'''\'''\'''
@@ -266,11 +266,11 @@
Future<void> test_raw_multiLine_threeQuotes() async {
await resolveTestCode('''
void f() {
- print(r"""
+ print(^r"""
''\'""");
}
''');
- await assertHasAssistAt('r"', r"""
+ await assertHasAssist(r"""
void f() {
print('''
''\'''');
@@ -281,13 +281,13 @@
Future<void> test_raw_multiLine_twoQuotes() async {
await resolveTestCode(r'''
void f() {
- print(r"""
+ print(^r"""
""\""\"
''
""");
}
''');
- await assertHasAssistAt('r"', """
+ await assertHasAssist("""
void f() {
print(r'''
""\""\"
@@ -300,11 +300,11 @@
Future<void> test_raw_multiLine_twoQuotesAtEnd() async {
await resolveTestCode('''
void f() {
- print(r"""
+ print(^r"""
''""");
}
''');
- await assertHasAssistAt('r"', r"""
+ await assertHasAssist(r"""
void f() {
print('''
'\'''');
@@ -315,10 +315,10 @@
Future<void> test_raw_nonEscapedChars() async {
await resolveTestCode(r"""
void f() {
- print(r"\$'");
+ print(^r"\$'");
}
""");
- await assertHasAssistAt('r"', r"""
+ await assertHasAssist(r"""
void f() {
print('\\\$\'');
}
@@ -328,10 +328,10 @@
Future<void> test_three_embeddedTarget() async {
await resolveTestCode('''
void f() {
- print("""a''\'bc""");
+ print(^"""a''\'bc""");
}
''');
- await assertHasAssistAt('"', r"""
+ await assertHasAssist(r"""
void f() {
print('''a''\'bc''');
}
@@ -341,10 +341,10 @@
Future<void> test_three_enclosingTarget() async {
await resolveTestCode("""
void f() {
- print('''abc''');
+ print(^'''abc''');
}
""");
- await assertNoAssistAt("'");
+ await assertNoAssist();
}
Future<void> test_three_interpolation() async {
@@ -352,10 +352,10 @@
void f() {
var b = 'b';
var c = 'c';
- print("""a $b-${c} d""");
+ print(^"""a $b-${c} d""");
}
''');
- await assertHasAssistAt(r'"', r"""
+ await assertHasAssist(r"""
void f() {
var b = 'b';
var c = 'c';
@@ -367,10 +367,10 @@
Future<void> test_three_raw() async {
await resolveTestCode('''
void f() {
- print(r"""abc""");
+ print(^r"""abc""");
}
''');
- await assertHasAssistAt('"', """
+ await assertHasAssist("""
void f() {
print(r'''abc''');
}
@@ -380,10 +380,10 @@
Future<void> test_three_simple() async {
await resolveTestCode('''
void f() {
- print("""abc""");
+ print(^"""abc""");
}
''');
- await assertHasAssistAt('"', """
+ await assertHasAssist("""
void f() {
print('''abc''');
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
index 70b834d..ea4f7af 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_super_parameters_test.dart
@@ -25,10 +25,10 @@
A({int? x});
}
class B extends A {
- B.name({int? x}) : super(x: x);
+ ^B.name({int? x}) : super(x: x);
}
''');
- await assertHasAssistAt('B.name', '''
+ await assertHasAssist('''
class A {
A({int? x});
}
@@ -44,10 +44,10 @@
A({int? x});
}
class B extends A {
- B.name({int? x}) : super(x: x);
+ B.n^ame({int? x}) : super(x: x);
}
''');
- await assertHasAssistAt('ame(', '''
+ await assertHasAssist('''
class A {
A({int? x});
}
@@ -63,10 +63,10 @@
A({int? x});
}
class B extends A {
- B({int? x}) : super(x: x);
+ B({int? x}) : ^super(x: x);
}
''');
- await assertNoAssistAt('super');
+ await assertNoAssist();
}
Future<void> test_cursorLocation_unnamed_onClassName() async {
@@ -75,10 +75,10 @@
A({int? x});
}
class B extends A {
- B({int? x}) : super(x: x);
+ ^B({int? x}) : super(x: x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x});
}
@@ -94,10 +94,10 @@
A({int x = 0});
}
class B extends A {
- B({int x = 2}) : super(x: x);
+ ^B({int x = 2}) : super(x: x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int x = 0});
}
@@ -113,10 +113,10 @@
A([int x = 0]);
}
class B extends A {
- B([int x = 2]) : super(x);
+ ^B([int x = 2]) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A([int x = 0]);
}
@@ -132,10 +132,10 @@
A({int x = 0});
}
class B extends A {
- B({int x = 0}) : super(x: x);
+ ^B({int x = 0}) : super(x: x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int x = 0});
}
@@ -151,10 +151,10 @@
A([int x = 0]);
}
class B extends A {
- B([int x = 0]) : super(x);
+ ^B([int x = 0]) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A([int x = 0]);
}
@@ -170,11 +170,11 @@
A({required int x});
}
class B extends A {
- B({required final x}) : super(x: x);
+ ^B({required final x}) : super(x: x);
}
''');
// `dynamic` is not a subtype of `int`
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_final_named_withType() async {
@@ -183,10 +183,10 @@
A({required int x});
}
class B extends A {
- B({required final int x}) : super(x: x);
+ ^B({required final int x}) : super(x: x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({required int x});
}
@@ -202,11 +202,11 @@
A(int x);
}
class B extends A {
- B(final x) : super(x);
+ ^B(final x) : super(x);
}
''');
// `dynamic` is not a subtype of `int`
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_final_positional_withType() async {
@@ -215,10 +215,10 @@
A(int x);
}
class B extends A {
- B(final int x) : super(x);
+ ^B(final int x) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x);
}
@@ -234,10 +234,10 @@
A(int f(int x));
}
class B extends A {
- B(int f(int x)) : super(f);
+ ^B(int f(int x)) : super(f);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int f(int x));
}
@@ -255,10 +255,10 @@
}
class B extends A {
int y;
- B(this.y) : super(y);
+ ^B(this.y) : super(y);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_namedToPositional() async {
@@ -267,10 +267,10 @@
A(int x);
}
class B extends A {
- B({int x = 0}) : super(x);
+ ^B({int x = 0}) : super(x);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_noSuperInvocation_factory() async {
@@ -280,10 +280,10 @@
}
class B extends A {
static List<B> instances = [];
- factory B({required int x}) => instances[x];
+ factory ^B({required int x}) => instances[x];
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_noSuperInvocation_generative() async {
@@ -292,19 +292,19 @@
A({int x = 0});
}
class B extends A {
- B({int x = 1});
+ ^B({int x = 1});
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_notAConstructor() async {
await resolveTestCode('''
class A {
- void m({required int x}) {}
+ void ^m({required int x}) {}
}
''');
- await assertNoAssistAt('m(');
+ await assertNoAssist();
}
Future<void> test_invalid_notPassed_unreferenced_named() async {
@@ -313,10 +313,10 @@
A({int x = 0});
}
class B extends A {
- B({int x = 0}) : super(x: 0);
+ ^B({int x = 0}) : super(x: 0);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_notPassed_unreferenced_positional() async {
@@ -325,10 +325,10 @@
A(int x);
}
class B extends A {
- B(int x) : super(0);
+ ^B(int x) : super(0);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_notPassed_usedInExpression_named() async {
@@ -337,10 +337,10 @@
A({String x = ''});
}
class B extends A {
- B({required Object x}) : super(x: x.toString());
+ ^B({required Object x}) : super(x: x.toString());
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_notPassed_usedInExpression_positional() async {
@@ -349,10 +349,10 @@
A(String x);
}
class B extends A {
- B(Object x) : super(x.toString());
+ ^B(Object x) : super(x.toString());
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_optedOut() async {
@@ -362,10 +362,10 @@
A({int? x});
}
class B extends A {
- B({int? x}) : super(x: x);
+ ^B({int? x}) : super(x: x);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_positionalToNamed() async {
@@ -374,10 +374,10 @@
A({int? x});
}
class B extends A {
- B(int x) : super(x: x);
+ ^B(int x) : super(x: x);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_referencedInBody_named() async {
@@ -386,12 +386,12 @@
A({int? x});
}
class B extends A {
- B({int? x}) : super(x: x) {
+ ^B({int? x}) : super(x: x) {
print(x);
}
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_invalid_referencedInBody_positional() async {
@@ -400,12 +400,12 @@
A(int x);
}
class B extends A {
- B(int x) : super(x) {
+ ^B(int x) : super(x) {
print(x);
}
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_mixed_first() async {
@@ -414,10 +414,10 @@
A(int x, {int? y});
}
class B extends A {
- B(int x, int y) : super(x, y: y);
+ ^B(int x, int y) : super(x, y: y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x, {int? y});
}
@@ -433,10 +433,10 @@
A(int x, {int? y});
}
class B extends A {
- B(int y, int x) : super(x, y: y);
+ ^B(int y, int x) : super(x, y: y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x, {int? y});
}
@@ -452,10 +452,10 @@
A(int y, {int? z});
}
class B extends A {
- B(int x, int y, int z) : super(y, z: z);
+ ^B(int x, int y, int z) : super(y, z: z);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int y, {int? z});
}
@@ -471,10 +471,10 @@
A({int? x, int? y});
}
class B extends A {
- B({int? y, int? x}) : super(x: x, y: y);
+ ^B({int? y, int? x}) : super(x: x, y: y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x, int? y});
}
@@ -490,10 +490,10 @@
A({int? x, int? y});
}
class B extends A {
- B({int? x, int? y}) : super(x: x, y: y);
+ ^B({int? x, int? y}) : super(x: x, y: y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x, int? y});
}
@@ -509,10 +509,10 @@
A({int? x, int? y});
}
class B extends A {
- B({int? x, required int y}) : super(x: x, y: y + 1);
+ ^B({int? x, required int y}) : super(x: x, y: y + 1);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x, int? y});
}
@@ -528,10 +528,10 @@
A({int? x, int? y});
}
class B extends A {
- B({required int x, int? y}) : super(x: x + 1, y: y);
+ ^B({required int x, int? y}) : super(x: x + 1, y: y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x, int? y});
}
@@ -547,10 +547,10 @@
A({int? x, int? y, int? z});
}
class B extends A {
- B({required int x, int? y, required int z}) : super(x: x + 1, y: y, z: z + 1);
+ ^B({required int x, int? y, required int z}) : super(x: x + 1, y: y, z: z + 1);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x, int? y, int? z});
}
@@ -566,10 +566,10 @@
A({int? x});
}
class B extends A {
- B({int? x}) : super(x: x);
+ ^B({int? x}) : super(x: x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A({int? x});
}
@@ -586,10 +586,10 @@
A({this.x = 0});
}
class B extends A {
- B({required int x}) : super(x: x);
+ ^B({required int x}) : super(x: x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
int x;
A({this.x = 0});
@@ -606,10 +606,10 @@
A.m({int? x});
}
class B extends A {
- B.m({int? x}) : super.m(x: x);
+ ^B.m({int? x}) : super.m(x: x);
}
''');
- await assertHasAssistAt('B.m', '''
+ await assertHasAssist('''
class A {
A.m({int? x});
}
@@ -625,10 +625,10 @@
A(int x);
}
class B extends A {
- B(int x, int y) : super(x);
+ ^B(int x, int y) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x);
}
@@ -644,10 +644,10 @@
A(int x(int));
}
class B extends A {
- B(int x(int)) : super(x);
+ ^B(int x(int)) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x(int));
}
@@ -663,10 +663,10 @@
A(int x);
}
class B extends A {
- B(int x, int y) : super(y);
+ ^B(int x, int y) : super(y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x);
}
@@ -682,10 +682,10 @@
A(int x);
}
class B extends A {
- B(int x, int y, int z) : super(y);
+ ^B(int x, int y, int z) : super(y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x);
}
@@ -701,10 +701,10 @@
A(int x, int y);
}
class B extends A {
- B(int x, int y) : super(y, x);
+ ^B(int x, int y) : super(y, x);
}
''');
- await assertNoAssistAt('B(');
+ await assertNoAssist();
}
Future<void> test_positional_multiple_optional() async {
@@ -713,10 +713,10 @@
A([int? x, int? y]);
}
class B extends A {
- B([int? x, int? y]) : super(x, y);
+ ^B([int? x, int? y]) : super(x, y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A([int? x, int? y]);
}
@@ -732,10 +732,10 @@
A(int x, int y);
}
class B extends A {
- B(int x, int y) : super(x, y);
+ ^B(int x, int y) : super(x, y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x, int y);
}
@@ -751,10 +751,10 @@
A(int x, [int? y]);
}
class B extends A {
- B(int x, [int? y]) : super(x, y);
+ ^B(int x, [int? y]) : super(x, y);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x, [int? y]);
}
@@ -770,10 +770,10 @@
A(int x);
}
class B extends A {
- B(int x) : super(x);
+ ^B(int x) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x);
}
@@ -789,10 +789,10 @@
A(int x);
}
class B extends A {
- B([int x = 0]) : super(x);
+ ^B([int x = 0]) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x);
}
@@ -808,10 +808,10 @@
A(int x, [int y = 0]);
}
class B extends A {
- B(int x) : super(x);
+ ^B(int x) : super(x);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A(int x, [int y = 0]);
}
@@ -827,10 +827,10 @@
A._(int x, int y);
}
class B extends A {
- B(int x, int y) : super._(x, y,);
+ ^B(int x, int y) : super._(x, y,);
}
''');
- await assertHasAssistAt('B(', '''
+ await assertHasAssist('''
class A {
A._(int x, int y);
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_expression_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_expression_test.dart
index c17aae9..0972cb2 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_expression_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_expression_test.dart
@@ -22,7 +22,7 @@
Future<void> test_argument_differentFunctions() async {
await resolveTestCode('''
void f(String s) {
- switch (s) {
+ swit^ch (s) {
case 'foo':
print('foo');
case _:
@@ -32,7 +32,7 @@
void g(String s) {}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_argument_sharedBody() async {
@@ -42,7 +42,7 @@
}
void f(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
case Color.blue:
print(0);
@@ -52,7 +52,7 @@
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, white
}
@@ -73,7 +73,7 @@
}
void f(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
print('red'); // Red.
break;
@@ -90,7 +90,7 @@
}
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, green, yellow
}
@@ -112,7 +112,7 @@
Future<void> test_argument_switchExpression_defaultCase() async {
await resolveTestCode('''
void f(String s) {
- switch (s) {
+ ^switch (s) {
case 'foo':
print('foo');
case 'bar':
@@ -122,7 +122,7 @@
}
}
''');
- await assertHasAssistAt('(s)', '''
+ await assertHasAssist('''
void f(String s) {
print(switch (s) {
'foo' => 'foo',
@@ -140,7 +140,7 @@
}
void f(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
print('red'); // Red.
case Color.blue:
@@ -154,7 +154,7 @@
}
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, green, yellow
}
@@ -176,7 +176,7 @@
Future<void> test_argument_switchExpression_wildcard() async {
await resolveTestCode('''
void f(String s) {
- switch (s) {
+ switch ^(s) {
case 'foo':
print('foo');
case 'bar':
@@ -186,7 +186,7 @@
}
}
''');
- await assertHasAssistAt('(s)', '''
+ await assertHasAssist('''
void f(String s) {
print(switch (s) {
'foo' => 'foo',
@@ -201,7 +201,7 @@
await resolveTestCode('''
int f(int x) {
var value = 0;
- switch (x) {
+ ^switch (x) {
case 1:
value = 3;
case 2:
@@ -212,14 +212,14 @@
return value;
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_assignment_compound_same_addition() async {
await resolveTestCode('''
int f(int x) {
var value = 0;
- switch (x) {
+ s^witch (x) {
case 1:
value += 3;
case 2:
@@ -230,7 +230,7 @@
return value;
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
int f(int x) {
var value = 0;
value += switch (x) {
@@ -247,7 +247,7 @@
await resolveTestCode('''
int f(int x) {
int? value = null;
- switch (x) {
+ sw^itch (x) {
case 1:
value ??= 3;
case 2:
@@ -258,7 +258,7 @@
return value;
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
int f(int x) {
int? value = null;
value ??= switch (x) {
@@ -280,7 +280,7 @@
String f(Color color) {
var name = '';
var favorite = '';
- switch (color) {
+ swi^tch (color) {
case Color.red:
name = 'red';
case Color.blue:
@@ -293,7 +293,7 @@
return name;
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_assignment_sharedBody() async {
@@ -304,7 +304,7 @@
void f(Color color) {
int value;
- switch (color) {
+ switch ^(color) {
case Color.red:
case Color.blue:
value = 0;
@@ -314,7 +314,7 @@
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, white
}
@@ -337,7 +337,7 @@
String f(Color color) {
var name = '';
- switch (color) {
+ switch ^(color) {
case Color.red:
name = 'red';
break;
@@ -355,7 +355,7 @@
return name;
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, green, yellow
}
@@ -380,7 +380,7 @@
await resolveTestCode('''
String f(String s) {
var name = '';
- switch (s) {
+ switch ^(s) {
case 'foo':
name = 'foo';
case 'bar':
@@ -391,7 +391,7 @@
return name;
}
''');
- await assertHasAssistAt('(s)', '''
+ await assertHasAssist('''
String f(String s) {
var name = '';
name = switch (s) {
@@ -412,7 +412,7 @@
String f(Color color) {
var name = '';
- switch (color) {
+ switch ^(color) {
case Color.red:
name = 'red';
case Color.blue:
@@ -427,7 +427,7 @@
return name;
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, green, yellow
}
@@ -452,7 +452,7 @@
await resolveTestCode('''
String f(String s) {
var name = '';
- switch (s) {
+ switch ^(s) {
case 'foo':
name = 'foo';
case 'bar':
@@ -463,7 +463,7 @@
return name;
}
''');
- await assertHasAssistAt('(s)', '''
+ await assertHasAssist('''
String f(String s) {
var name = '';
name = switch (s) {
@@ -479,22 +479,22 @@
Future<void> test_empty() async {
await resolveTestCode('''
void f(int x) {
- switch (x) {}
+ switch ^(x) {}
}
''');
- await assertNoAssistAt('(x)');
+ await assertNoAssist();
}
Future<void> test_return_justDefault_throw() async {
await resolveTestCode('''
String f(int x) {
- switch (x) {
+ s^witch (x) {
default:
throw 'foo';
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
String f(int x) {
return switch (x) {
_ => throw 'foo'
@@ -506,13 +506,13 @@
Future<void> test_return_justDefault_value() async {
await resolveTestCode('''
String f(int x) {
- switch (x) {
+ ^switch (x) {
default:
return 'foo';
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
String f(int x) {
return switch (x) {
_ => 'foo'
@@ -528,7 +528,7 @@
}
String name(Color color) {
- switch (color) {
+ ^switch (color) {
case Color.red:
print('red');
return 'red';
@@ -541,14 +541,13 @@
}
}
''');
-
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_return_notExhaustive() async {
await resolveTestCode('''
String f(int i) {
- switch(i) {
+ swi^tch(i) {
case 1:
return 'one';
case 2:
@@ -557,8 +556,7 @@
return '';
}
''');
-
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_return_sharedBody() async {
@@ -568,7 +566,7 @@
}
int f(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
case Color.blue:
return 0;
@@ -577,8 +575,7 @@
}
}
''');
-
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, blue, white
}
@@ -599,7 +596,7 @@
}
int f(Color color) {
- switch (color) {
+ switc^h (color) {
case Color.red when true:
case Color.blue:
return 0;
@@ -611,7 +608,7 @@
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_return_switchExpression() async {
@@ -621,7 +618,7 @@
}
String name(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
throw 'red!';
case Color.orange:
@@ -633,7 +630,7 @@
}
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, orange, yellow, green
}
@@ -656,7 +653,7 @@
}
String name(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
throw 'red!';
case Color.orange:
@@ -668,7 +665,7 @@
}
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, orange, yellow, green
}
@@ -691,7 +688,7 @@
}
Color fromName(String name) {
- switch (name) {
+ s^witch (name) {
case 'red':
return Color.red;
case 'blue':
@@ -702,7 +699,7 @@
throw name;
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
enum Color {
red, blue, white
}
@@ -725,7 +722,7 @@
}
Color fromName(String name) {
- switch (name) {
+ switc^h (name) {
case 'red':
return Color.red;
}
@@ -734,7 +731,7 @@
' red';
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
enum Color {
red
}
@@ -757,7 +754,7 @@
}
String name(Color color) {
- switch (color) {
+ switch ^(color) {
case Color.red:
throw 'red!';
case Color.orange:
@@ -769,7 +766,7 @@
}
}
''');
- await assertHasAssistAt('(color)', '''
+ await assertHasAssist('''
enum Color {
red, orange, yellow, green
}
@@ -792,7 +789,7 @@
}
String name(Color color) {
- switch (color) {
+ sw^itch (color) {
// Uh-oh.
case Color.red:
throw 'red!';
@@ -807,7 +804,7 @@
}
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
enum Color {
red, orange, yellow, green
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_statement_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_statement_test.dart
index 1fc6fd2..5653e68 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_statement_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/convert_to_switch_statement_test.dart
@@ -23,13 +23,13 @@
Future<void> test_chain_case2_blockEmpty() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
} else if (x case double()) {
1;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -44,13 +44,13 @@
Future<void> test_chain_case2_blockEmpty_last() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else if (x case double()) {
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -64,20 +64,20 @@
Future<void> test_chain_case2_differentIdentifier() async {
await resolveTestCode('''
void f(Object? x, Object? y) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else if (y case double()) {
1;
}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_chain_case2_elseBlock() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else if (x case double()) {
1;
@@ -86,7 +86,7 @@
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -103,14 +103,14 @@
Future<void> test_chain_case2_noElse() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else if (x case double()) {
1;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -125,27 +125,27 @@
Future<void> test_chain_case2_notIdentifier() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else if (x != null case true) {
1;
}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_chain_case_expression() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else if (x is double) {
1;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -160,14 +160,14 @@
Future<void> test_chain_expression2() async {
await resolveTestCode('''
void f(Object? x) {
- if (x is int) {
+ i^f (x is int) {
0;
} else if (x is double) {
1;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -183,25 +183,25 @@
await resolveTestCode('''
// @dart = 2.19
void f(Object? x) {
- if (x is int) {
+ i^f (x is int) {
0;
} else if (x is double) {
1;
}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_single_case_thenBlock() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -214,14 +214,14 @@
Future<void> test_single_case_thenBlock_elseBlock() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else {
1;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -236,12 +236,12 @@
Future<void> test_single_case_thenBlock_elseBlockEmpty() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else {}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -255,13 +255,13 @@
Future<void> test_single_case_thenBlock_elseStatement() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ i^f (x case int()) {
0;
} else
1;
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -276,11 +276,11 @@
Future<void> test_single_case_thenStatement() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int())
+ i^f (x case int())
0;
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case int():
@@ -293,12 +293,12 @@
Future<void> test_single_expression_greaterOrEqualThan() async {
await resolveTestCode('''
void f(int x) {
- if (x >= 100) {
+ i^f (x >= 100) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(int x) {
switch (x) {
case >= 100:
@@ -311,12 +311,12 @@
Future<void> test_single_expression_greaterThan() async {
await resolveTestCode('''
void f(int x) {
- if (x > 100) {
+ i^f (x > 100) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(int x) {
switch (x) {
case > 100:
@@ -329,12 +329,12 @@
Future<void> test_single_expression_isType() async {
await resolveTestCode('''
void f(Object? x) {
- if (x is List<int>) {
+ i^f (x is List<int>) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case List<int>():
@@ -347,12 +347,12 @@
Future<void> test_single_expression_isType_functionType() async {
await resolveTestCode('''
void f(Object? x) {
- if (x is void Function()) {
+ i^f (x is void Function()) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case void Function() _:
@@ -365,12 +365,12 @@
Future<void> test_single_expression_isType_recordType() async {
await resolveTestCode('''
void f(Object? x) {
- if (x is (int, String)) {
+ i^f (x is (int, String)) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case (int, String) _:
@@ -383,12 +383,12 @@
Future<void> test_single_expression_lessOrEqualThan() async {
await resolveTestCode('''
void f(int x) {
- if (x <= 100) {
+ i^f (x <= 100) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(int x) {
switch (x) {
case <= 100:
@@ -401,12 +401,12 @@
Future<void> test_single_expression_lessThan() async {
await resolveTestCode('''
void f(int x) {
- if (x < 100) {
+ i^f (x < 100) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(int x) {
switch (x) {
case < 100:
@@ -419,23 +419,23 @@
Future<void> test_single_expression_lessThan_notLiteral() async {
await resolveTestCode('''
void f(int x, int y) {
- if (x < y) {
+ i^f (x < y) {
0;
}
}
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
Future<void> test_single_expression_notEqNull() async {
await resolveTestCode('''
void f(Object? x) {
- if (x != null) {
+ i^f (x != null) {
0;
}
}
''');
- await assertHasAssistAt('if', '''
+ await assertHasAssist('''
void f(Object? x) {
switch (x) {
case _?:
@@ -448,14 +448,14 @@
Future<void> test_single_expression_notSupported() async {
await resolveTestCode('''
void f(Object? x) {
- if (validate(x)) {
+ i^f (validate(x)) {
0;
}
}
bool validate(Object? x) => false;
''');
- await assertNoAssistAt('if');
+ await assertNoAssist();
}
}
@@ -468,13 +468,13 @@
await resolveTestCode('''
void f(int x) {
int v;
- v = switch (x) {
+ v = swi^tch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(int x) {
int v;
switch (x) {
@@ -491,25 +491,25 @@
await resolveTestCode('''
void f(int x) {
final v = [0];
- v[0] = switch (x) {
+ v[0] = swi^tch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertNoAssistAt('switch');
+ await assertNoAssist();
}
Future<void> test_noTrailingComma() async {
await resolveTestCode('''
int f(int x) {
- return switch (x) {
+ return sw^itch (x) {
0 => 0,
_ => 1
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
int f(int x) {
switch (x) {
case 0:
@@ -525,13 +525,13 @@
await resolveTestCode('''
void f(int x) {
int v = 0;
- v += switch (x) {
+ v += s^witch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(int x) {
int v = 0;
switch (x) {
@@ -547,13 +547,13 @@
Future<void> test_returnStatement() async {
await resolveTestCode('''
int f(int x) {
- return switch (x) {
+ return swi^tch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
int f(int x) {
switch (x) {
case 0:
@@ -568,13 +568,13 @@
Future<void> test_variableDeclarationStatement_typed() async {
await resolveTestCode('''
void f(int x) {
- int v = switch (x) {
+ int v = swi^tch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(int x) {
int v;
switch (x) {
@@ -590,13 +590,13 @@
Future<void> test_variableDeclarationStatement_untyped_final() async {
await resolveTestCode('''
void f(int x) {
- final v = switch (x) {
+ final v = swi^tch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(int x) {
final int v;
switch (x) {
@@ -612,13 +612,13 @@
Future<void> test_variableDeclarationStatement_untyped_var() async {
await resolveTestCode('''
void f(int x) {
- var v = switch (x) {
+ var v = swi^tch (x) {
0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(int x) {
int v;
switch (x) {
@@ -634,13 +634,13 @@
Future<void> test_wildcardPattern_when() async {
await resolveTestCode('''
void f(int x) {
- int v = switch (x) {
+ int v = swi^tch (x) {
_ when x > 0 => 0,
_ => 1,
};
}
''');
- await assertHasAssistAt('switch', '''
+ await assertHasAssist('''
void f(int x) {
int v;
switch (x) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/destructure_local_variable_assignment_test.dart b/pkg/analysis_server/test/src/services/correction/assist/destructure_local_variable_assignment_test.dart
index 2ed2cd1..95ee043 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/destructure_local_variable_assignment_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/destructure_local_variable_assignment_test.dart
@@ -28,10 +28,10 @@
A f() => A();
m() {
- var obj = f();
+ var ^obj = f();
}
''');
- await assertHasAssistAt('obj', r'''
+ await assertHasAssist(r'''
class A { }
A f() => A();
@@ -51,11 +51,11 @@
A f() => A();
m() {
- var obj = f();
+ var ^obj = f();
obj.a = 1;
}
''');
- await assertNoAssistAt('obj');
+ await assertNoAssist();
}
Future<void> test_object_propertyPostIncremented_noAssist() async {
@@ -67,11 +67,11 @@
A f() => A();
m() {
- var obj = f();
+ var ^obj = f();
obj.a++;
}
''');
- await assertNoAssistAt('obj');
+ await assertNoAssist();
}
Future<void> test_object_propertyPreIncremented_noAssist() async {
@@ -83,11 +83,11 @@
A f() => A();
m() {
- var obj = f();
+ var ^obj = f();
++obj.a;
}
''');
- await assertNoAssistAt('obj');
+ await assertNoAssist();
}
Future<void> test_object_reassigned_noAssist() async {
@@ -97,11 +97,11 @@
A f() => A();
m() {
- var obj = f();
+ var ^obj = f();
obj = A();
}
''');
- await assertNoAssistAt('obj');
+ await assertNoAssist();
}
Future<void> test_object_referenced() async {
@@ -115,7 +115,7 @@
A f() => A();
m(var c) {
- var obj = f();
+ var ^obj = f();
var b = 0;
print(obj.a);
print(obj.b);
@@ -123,7 +123,7 @@
print(obj.c);
}
''');
- await assertHasAssistAt('obj', r'''
+ await assertHasAssist(r'''
class A {
String get a => '';
String get b => '';
@@ -150,11 +150,11 @@
A f() => A();
m() {
- var obj = f();
+ var ^obj = f();
print(obj);
}
''');
- await assertNoAssistAt('obj');
+ await assertNoAssist();
}
}
@@ -168,10 +168,10 @@
({int n, String s}) f() => (n: 1, s: '');
m() {
- var rec = f();
+ var ^rec = f();
}
''');
- await assertHasAssistAt('rec', r'''
+ await assertHasAssist(r'''
({int n, String s}) f() => (n: 1, s: '');
m() {
@@ -185,10 +185,10 @@
({int n, String s}) f() => (n: 1, s: '');
m(int n) {
- var rec = f();
+ var ^rec = f();
}
''');
- await assertHasAssistAt('rec', r'''
+ await assertHasAssist(r'''
({int n, String s}) f() => (n: 1, s: '');
m(int n) {
@@ -206,10 +206,10 @@
(bool, {int n, String s}) f() => (false, n: 1, s: '');
m() {
- var rec = f();
+ var ^rec = f();
}
''');
- await assertHasAssistAt('rec', r'''
+ await assertHasAssist(r'''
(bool, {int n, String s}) f() => (false, n: 1, s: '');
m() {
@@ -227,10 +227,10 @@
(int, String name) f() => (1, '');
m() {
- var rec = f();
+ var ^rec = f();
}
''');
- await assertHasAssistAt('rec', r'''
+ await assertHasAssist(r'''
(int, String name) f() => (1, '');
m() {
@@ -247,10 +247,10 @@
(int, String) f() => (1, '');
m(var $1) {
- var rec = f();
+ var ^rec = f();
}
''');
- await assertHasAssistAt('rec', r'''
+ await assertHasAssist(r'''
(int, String) f() => (1, '');
m(var $1) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/encapsulate_field_test.dart b/pkg/analysis_server/test/src/services/correction/assist/encapsulate_field_test.dart
index 7e54abe..6750b60 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/encapsulate_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/encapsulate_field_test.dart
@@ -22,13 +22,13 @@
Future<void> test_alreadyPrivate() async {
await resolveTestCode('''
class A {
- int _test = 42;
+ int ^_test = 42;
}
void f(A a) {
print(a._test);
}
''');
- await assertNoAssistAt('_test =');
+ await assertNoAssist();
}
Future<void> test_annotations_deprecated2() async {
@@ -36,10 +36,10 @@
class A {
@deprecated
@deprecated
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
class A {
int _foo = 0;
@@ -66,10 +66,10 @@
@deprecated
@override
@deprecated
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
abstract class A {
int get foo;
}
@@ -99,10 +99,10 @@
class B extends A {
@deprecated @override @deprecated
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
abstract class A {
int get foo;
}
@@ -132,10 +132,10 @@
class B extends A {
@override
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
abstract class A {
int get foo;
}
@@ -162,10 +162,10 @@
class B extends A {
@override
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
abstract class A {
int get foo;
set foo(int value);
@@ -193,10 +193,10 @@
class B extends A {
@override
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
abstract class A {
set foo(int value);
}
@@ -223,10 +223,10 @@
class B extends A {
@unresolved
- int foo = 0;
+ int ^foo = 0;
}
''');
- await assertHasAssistAt('foo = 0', '''
+ await assertHasAssist('''
abstract class A {
int get foo;
}
@@ -250,10 +250,10 @@
class A {
/// AAA
/// BBB
- int test = 0;
+ int ^test = 0;
}
''');
- await assertHasAssistAt('test', '''
+ await assertHasAssist('''
class A {
/// AAA
/// BBB
@@ -276,30 +276,30 @@
await resolveTestCode('''
enum E {
v;
- final int test = 42;
+ final int ^test = 42;
}
''');
// Enums can have only final fields.
- await assertNoAssistAt('test = 42');
+ await assertNoAssist();
}
Future<void> test_extension_hasType() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
extension E on int {
- int test = 42;
+ int ^test = 42;
}
''');
- await assertNoAssistAt('test = 42');
+ await assertNoAssist();
}
Future<void> test_final() async {
await resolveTestCode('''
class A {
- final int test = 42;
+ final int ^test = 42;
}
''');
- await assertHasAssistAt('test =', '''
+ await assertHasAssist('''
class A {
int _test = 42;
@@ -311,14 +311,14 @@
Future<void> test_hasType() async {
await resolveTestCode('''
class A {
- int test = 42;
+ int ^test = 42;
A(this.test);
}
void f(A a) {
print(a.test);
}
''');
- await assertHasAssistAt('test = 42', '''
+ await assertHasAssist('''
class A {
int _test = 42;
@@ -338,10 +338,10 @@
Future<void> test_mixin_hasType() async {
await resolveTestCode('''
mixin M {
- int test = 42;
+ int ^test = 42;
}
''');
- await assertHasAssistAt('test = 42', '''
+ await assertHasAssist('''
mixin M {
int _test = 42;
@@ -357,23 +357,23 @@
Future<void> test_multipleFields() async {
await resolveTestCode('''
class A {
- int aaa = 0, bbb = 0, ccc = 0;
+ int aaa = 0, ^bbb = 0, ccc = 0;
}
void f(A a) {
print(a.bbb);
}
''');
- await assertNoAssistAt('bbb ');
+ await assertNoAssist();
}
Future<void> test_named() async {
await resolveTestCode('''
class A {
- int? field;
+ int? ^field;
A({int? field}) : field = field;
}
''');
- await assertHasAssistAt('field', '''
+ await assertHasAssist('''
class A {
int? _field;
@@ -390,11 +390,11 @@
Future<void> test_named_formalParameter() async {
await resolveTestCode('''
class A {
- int? field;
+ int? ^field;
A({this.field});
}
''');
- await assertHasAssistAt('field', '''
+ await assertHasAssist('''
class A {
int? _field;
@@ -411,12 +411,12 @@
Future<void> test_named_formalParameter_noType() async {
await resolveTestCode('''
class C {
- var foo;
+ var ^foo;
C({required this.foo});
}
''');
- await assertHasAssistAt('foo;', '''
+ await assertHasAssist('''
class C {
var _foo;
@@ -436,12 +436,12 @@
import 'dart:math' as math;
class C {
- math.Random foo;
+ math.Random ^foo;
C({required this.foo});
}
''');
- await assertHasAssistAt('foo;', '''
+ await assertHasAssist('''
import 'dart:math' as math;
class C {
@@ -462,11 +462,11 @@
await resolveTestCode('''
class A {}
class B extends A {
- int? field;
+ int? ^field;
B({this.field}) : super();
}
''');
- await assertHasAssistAt('field', '''
+ await assertHasAssist('''
class A {}
class B extends A {
int? _field;
@@ -484,22 +484,22 @@
Future<void> test_notOnName() async {
await resolveTestCode('''
class A {
- int test = 1 + 2 + 3;
+ int test = 1 ^+ 2 + 3;
}
''');
- await assertNoAssistAt('+ 2');
+ await assertNoAssist();
}
Future<void> test_noType() async {
await resolveTestCode('''
class A {
- var test = 42;
+ var ^test = 42;
}
void f(A a) {
print(a.test);
}
''');
- await assertHasAssistAt('test = 42', '''
+ await assertHasAssist('''
class A {
var _test = 42;
@@ -519,23 +519,23 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
class A {
- int; // marker
+ int^; // marker
}
void f(A a) {
print(a.test);
}
''');
- await assertNoAssistAt('; // marker');
+ await assertNoAssist();
}
Future<void> test_positional() async {
await resolveTestCode('''
class A {
- int? field;
+ int? ^field;
A([this.field]);
}
''');
- await assertHasAssistAt('field', '''
+ await assertHasAssist('''
class A {
int? _field;
@@ -552,9 +552,9 @@
Future<void> test_static() async {
await resolveTestCode('''
class A {
- static int test = 42;
+ static int ^test = 42;
}
''');
- await assertNoAssistAt('test =');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/exchange_operands_test.dart b/pkg/analysis_server/test/src/services/correction/assist/exchange_operands_test.dart
index 94a069c..599ecd0 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/exchange_operands_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/exchange_operands_test.dart
@@ -27,10 +27,10 @@
var resultOperator = resultOperators[i];
await resolveTestCode('''
bool f(int a, int b) {
- return a $initialOperator b;
+ return a ^$initialOperator b;
}
''');
- await assertHasAssistAt(initialOperator, '''
+ await assertHasAssist('''
bool f(int a, int b) {
return b $resultOperator a;
}
@@ -41,10 +41,10 @@
Future<void> test_extended_mixOperator_1() async {
await resolveTestCode('''
void f() {
- 1 * 2 * 3 + 4;
+ 1 ^* 2 * 3 + 4;
}
''');
- await assertHasAssistAt('* 2', '''
+ await assertHasAssist('''
void f() {
2 * 3 * 1 + 4;
}
@@ -54,10 +54,10 @@
Future<void> test_extended_mixOperator_2() async {
await resolveTestCode('''
void f() {
- 1 + 2 - 3 + 4;
+ 1 ^+ 2 - 3 + 4;
}
''');
- await assertHasAssistAt('+ 2', '''
+ await assertHasAssist('''
void f() {
2 + 1 - 3 + 4;
}
@@ -67,10 +67,10 @@
Future<void> test_extended_sameOperator_afterFirst() async {
await resolveTestCode('''
void f() {
- 1 + 2 + 3;
+ 1 ^+ 2 + 3;
}
''');
- await assertHasAssistAt('+ 2', '''
+ await assertHasAssist('''
void f() {
2 + 3 + 1;
}
@@ -80,10 +80,10 @@
Future<void> test_extended_sameOperator_afterSecond() async {
await resolveTestCode('''
void f() {
- 1 + 2 + 3;
+ 1 + 2 ^+ 3;
}
''');
- await assertHasAssistAt('+ 3', '''
+ await assertHasAssist('''
void f() {
3 + 1 + 2;
}
@@ -93,37 +93,37 @@
Future<void> test_extraLength() async {
await resolveTestCode('''
void f() {
- 111 + 222;
+ 111 /*[0*/+ 2/*0]*/22;
}
''');
- await assertNoAssistAt('+ 222', length: 3);
+ await assertNoAssist();
}
Future<void> test_onOperand() async {
await resolveTestCode('''
void f() {
- 111 + 222;
+ 1/*[0*/11 +/*0]*/ 222;
}
''');
- await assertNoAssistAt('11 +', length: 3);
+ await assertNoAssist();
}
Future<void> test_selectionWithBinary() async {
await resolveTestCode('''
void f() {
- 1 + 2 + 3;
+ /*[0*/1 + 2 + 3/*0]*/;
}
''');
- await assertNoAssistAt('1 + 2 + 3', length: '1 + 2 + 3'.length);
+ await assertNoAssist();
}
Future<void> test_simple_afterOperator() async {
await resolveTestCode('''
void f() {
- 1 + 2;
+ 1 +^ 2;
}
''');
- await assertHasAssistAt(' 2', '''
+ await assertHasAssist('''
void f() {
2 + 1;
}
@@ -133,10 +133,10 @@
Future<void> test_simple_beforeOperator() async {
await resolveTestCode('''
void f() {
- 1 + 2;
+ 1 ^+ 2;
}
''');
- await assertHasAssistAt('+ 2', '''
+ await assertHasAssist('''
void f() {
2 + 1;
}
@@ -146,26 +146,26 @@
Future<void> test_simple_fullSelection() async {
await resolveTestCode('''
void f() {
- 1 + 2;
+ /*[0*/1 + 2/*0]*/;
}
''');
- await assertHasAssistAt('1 + 2', '''
+ await assertHasAssist('''
void f() {
2 + 1;
}
-''', length: '1 + 2'.length);
+''');
}
Future<void> test_simple_withLength() async {
await resolveTestCode('''
void f() {
- 1 + 2;
+ 1 /*[0*/+ /*0]*/2;
}
''');
- await assertHasAssistAt('+ 2', '''
+ await assertHasAssist('''
void f() {
2 + 1;
}
-''', length: 2);
+''');
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart
index c747182..de325dd 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_column_test.dart
@@ -158,12 +158,12 @@
class FakeFlutter {
Widget f() {
return Container(
- child: Text('aaa'),
+ child: /*[0*/Text/*0]*/('aaa'),
);
}
}
''');
- await assertHasAssistAt('Text(', '''
+ await assertHasAssist('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
@@ -177,6 +177,6 @@
);
}
}
-''', length: 4);
+''');
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart
index cea9cad..f8f11c3 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_padding_test.dart
@@ -74,7 +74,7 @@
import 'package:flutter/widgets.dart';
void f() {
- Padding(
+ Padd^ing(
padding: const EdgeInsets.all(8.0),
child: Container(),
);
diff --git a/pkg/analysis_server/test/src/services/correction/assist/import_add_show_test.dart b/pkg/analysis_server/test/src/services/correction/assist/import_add_show_test.dart
index 8538f45..1217056 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/import_add_show_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/import_add_show_test.dart
@@ -28,11 +28,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart' as l;
+^import 'lib.dart' as l;
void f(l.C c) => c + c;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' as l show C, E;
void f(l.C c) => c + c;
@@ -48,11 +48,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c + c;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c + c;
@@ -68,11 +68,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c();
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c();
@@ -88,11 +88,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c.f;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c.f;
@@ -110,11 +110,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c.c.f;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c.c.f;
@@ -130,13 +130,13 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
int f(C c) => switch (c) {
C(:var f) => f,
};
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
int f(C c) => switch (c) {
@@ -154,14 +154,14 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
int f(C c) {
var C(:f) = c;
return f;
}
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
int f(C c) {
@@ -180,11 +180,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c[7];
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c[7];
@@ -200,11 +200,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c[7] = 6;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c[7] = 6;
@@ -220,11 +220,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c.m();
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c.m();
@@ -242,11 +242,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c..m()..n();
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c..m()..n();
@@ -263,11 +263,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c.f += 7;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c.f += 7;
@@ -284,11 +284,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c.f ??= 7;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c.f ??= 7;
@@ -304,11 +304,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => c.f = 7;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => c.f = 7;
@@ -324,11 +324,11 @@
}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(C c) => ~c;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show C, E;
void f(C c) => ~c;
@@ -337,23 +337,23 @@
Future<void> test_hasShow() async {
await resolveTestCode('''
-import 'dart:math' show pi;
+^import 'dart:math' show pi;
void f() {
pi;
}
''');
- await assertNoAssistAt('import ');
+ await assertNoAssist();
}
Future<void> test_hasUnresolvedIdentifier() async {
await resolveTestCode('''
-import 'dart:math';
+^import 'dart:math';
void f(x) {
pi;
return x.foo();
}
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'dart:math' show pi;
void f(x) {
pi;
@@ -367,10 +367,10 @@
mixin M {}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(M m) {}
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show M;
void f(M m) {}
''');
@@ -378,14 +378,14 @@
Future<void> test_onDirective() async {
await resolveTestCode('''
-import 'dart:math';
+^import 'dart:math';
void f() {
pi;
e;
max(1, 2);
}
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'dart:math' show e, max, pi;
void f() {
pi;
@@ -397,14 +397,14 @@
Future<void> test_onUri() async {
await resolveTestCode('''
-import 'dart:math';
+import 'd^art:math';
void f() {
pi;
e;
max(1, 2);
}
''');
- await assertHasAssistAt('art:math', '''
+ await assertHasAssist('''
import 'dart:math' show e, max, pi;
void f() {
pi;
@@ -419,11 +419,11 @@
set s(int value) {}
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f() => s = 7;
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show s;
void f() => s = 7;
@@ -435,13 +435,13 @@
void set setter(int i) {}
''');
await resolveTestCode('''
-import 'a.dart';
+^import 'a.dart';
void f() {
setter = 42;
}
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'a.dart' show setter;
void f() {
@@ -455,10 +455,10 @@
typedef Cb = void Function();
''');
await resolveTestCode('''
-import 'lib.dart';
+^import 'lib.dart';
void f(Cb cb) {}
''');
- await assertHasAssistAt('import ', '''
+ await assertHasAssist('''
import 'lib.dart' show Cb;
void f(Cb cb) {}
''');
@@ -467,15 +467,15 @@
Future<void> test_unresolvedUri() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-import '/no/such/lib.dart';
+^import '/no/such/lib.dart';
''');
- await assertNoAssistAt('import ');
+ await assertNoAssist();
}
Future<void> test_unused() async {
await resolveTestCode('''
-import 'dart:math';
+^import 'dart:math';
''');
- await assertNoAssistAt('import ');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/invert_if_statement_test.dart b/pkg/analysis_server/test/src/services/correction/assist/invert_if_statement_test.dart
index 838eacc..d7b58d5 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/invert_if_statement_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/invert_if_statement_test.dart
@@ -22,27 +22,27 @@
Future<void> test_ifCase() async {
await resolveTestCode('''
void f(Object? x) {
- if (x case int()) {
+ ^if (x case int()) {
0;
} else {
1;
}
}
''');
- await assertNoAssistAt('if (');
+ await assertNoAssist();
}
Future<void> test_thenBlock_elseBlock() async {
await resolveTestCode('''
void f() {
- if (true) {
+ ^if (true) {
0;
} else {
1;
}
}
''');
- await assertHasAssistAt('if (', '''
+ await assertHasAssist('''
void f() {
if (false) {
1;
@@ -56,38 +56,38 @@
Future<void> test_thenBlock_elseIf() async {
await resolveTestCode('''
void f(bool c1, bool c2) {
- if (c1) {
+ ^if (c1) {
0;
} else if (c2) {
1;
}
}
''');
- await assertNoAssistAt('if (');
+ await assertNoAssist();
}
Future<void> test_thenBlock_elseStatement() async {
await resolveTestCode('''
void f() {
- if (true) {
+ i^f (true) {
0;
} else
1;
}
''');
- await assertNoAssistAt('if (');
+ await assertNoAssist();
}
Future<void> test_thenStatement_elseBlock() async {
await resolveTestCode('''
void f() {
- if (true)
+ i^f (true)
0;
else {
1;
}
}
''');
- await assertNoAssistAt('if (');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/join_else_with_if_test.dart b/pkg/analysis_server/test/src/services/correction/assist/join_else_with_if_test.dart
index 848082f..1f6bb87 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/join_else_with_if_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/join_else_with_if_test.dart
@@ -24,14 +24,14 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- } else {
+ } el^se {
if (1 case double value) {
print(value);
}
}
}
''');
- await assertHasAssistAt('else', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (1 case double value) {
@@ -46,38 +46,38 @@
void f() {
if (1 == 1) {
print(0);
- } else {
+ } el^se {
print(1);
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
Future<void> test_blockComment_after_else_keyword() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- } else /* comment here */ {
+ } el^se /* comment here */ {
if (2 == 2)
print(0);
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
Future<void> test_comment_before_else_keyword() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- } /* comment here */ else {
+ } /* comment here */ e^lse {
if (2 == 2)
print(0);
}
}
''');
- await assertHasAssistAt('else', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} /* comment here */ else if (2 == 2) {
@@ -88,19 +88,19 @@
}
Future<void> test_enclosing_if_statement() async {
- /// Should make no difference because the enclosing `if` thenStatement is
- /// not considered for anything in this assist.
+ // Should make no difference because the enclosing `if` thenStatement is
+ // not considered for anything in this assist.
await resolveTestCode('''
void f() {
if (1 == 1) print(0);
- else {
+ el^se {
if (2 == 2) {
print(1);
}
}
}
''');
- await assertHasAssistAt('else', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) print(0);
else if (2 == 2) {
@@ -114,20 +114,20 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- } else // comment here
+ } els^e // comment here
{
if (2 == 2)
print(0);
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
Future<void> test_noAssistOnOuterIf() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
} else {
if (1 case double value) {
print(value);
@@ -135,28 +135,28 @@
}
}
''');
- await assertNoAssistAt('if (1 == ');
+ await assertNoAssist();
}
Future<void> test_notBlock() async {
- /// No assist because this is a bad formatted `if else` statement.
+ // No assist because this is a bad formatted `if else` statement.
await resolveTestCode('''
void f() {
if (1 == 1) print(0);
- else
+ el^se
if (2 == 2) {
print(1);
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
Future<void> test_statementAfterInner() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- } else {
+ } e^lse {
if (2 == 2) {
print(2);
}
@@ -164,14 +164,14 @@
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
Future<void> test_statementBeforeInner() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- } else {
+ } ^else {
print(1);
if (2 == 2) {
print(2);
@@ -179,7 +179,7 @@
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
}
@@ -193,12 +193,12 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2)
+ i^f (2 == 2)
print(0);
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -213,13 +213,13 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) /* comment here */ {
+ ^if (2 == 2) /* comment here */ {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -235,7 +235,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(1);
print(2);
print(3);
@@ -243,7 +243,7 @@
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -260,13 +260,13 @@
void f() {
if (1 == 1) {
} else {
- if (1 case double value) {
+ i^f (1 case double value) {
print(value);
}
}
}
''');
- await assertHasAssistAt('if (1 case', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (1 case double value) {
@@ -281,12 +281,12 @@
void f() {
if (1 == 1) {
} else {
- if /* comment here */ (2 == 2)
+ i^f /* comment here */ (2 == 2)
print(0);
}
}
''');
- await assertHasAssistAt('if /*', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -304,12 +304,12 @@
} else {
// comment here
/* comment here */
- if (2 == 2)
+ i^f (2 == 2)
print(0);
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -322,19 +322,19 @@
}
Future<void> test_enclosing_if_statement() async {
- /// Should make no difference because the enclosing `if` thenStatement is
- /// not considered for anything in this assist.
+ // Should make no difference because the enclosing `if` thenStatement is
+ // not considered for anything in this assist.
await resolveTestCode('''
void f() {
if (1 == 1) print(0);
else {
- if (2 == 2) {
+ ^if (2 == 2) {
print(1);
}
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) print(0);
else if (2 == 2) {
@@ -349,7 +349,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else {
print(1);
@@ -358,7 +358,7 @@
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -376,14 +376,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2)
+ ^if (2 == 2)
print(0);
else if (3 == 3) // comment here
print(1);
}
}
''');
- await assertHasAssistAt('if (2 == ', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -401,14 +401,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2)
+ i^f (2 == 2)
print(0);
else // comment here
print(1);
}
}
''');
- await assertHasAssistAt('if (2 == ', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -426,14 +426,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else print(1);
// comment here
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -451,7 +451,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ ^if (2 == 2) {
print(0);
} else if (3 == 3) {
print(1);
@@ -460,7 +460,7 @@
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -479,7 +479,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else if (3 == 3) print(1);
// comment here
@@ -487,7 +487,7 @@
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -507,14 +507,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ if^ (2 == 2) {
print(0);
} else if (3 == 3) print(1);
// comment here
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -532,14 +532,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
}
// comment here
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -555,12 +555,12 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) // comment here
+ ^if (2 == 2) // comment here
print(0);
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -577,12 +577,12 @@
if (1 == 1) {
} else {
// comment here
- if (2 == 2) {print(0);}
+ i^f (2 == 2) {print(0);}
// comment here 2
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -599,7 +599,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ ^if (2 == 2) {
print(0);
} else {
// comment here
@@ -607,7 +607,7 @@
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -624,14 +624,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
// comment here
print(0);
}
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -648,40 +648,41 @@
if (1 == 1) {
} else {
if (1 case double value) {
- print(value);
- } else if (2 == 2) {
- } else print(0);
+ /*0*/print(value);
+ } else /*1*/if (2 == 2) {
+ } /*2*/else /*3*/print(0);
}
}
''');
- await assertNoAssistAt('if (2 ==');
- await assertNoAssistAt('else print');
- await assertNoAssistAt('print');
+ await assertNoAssist();
+ await assertNoAssist(1);
+ await assertNoAssist(2);
+ await assertNoAssist(3);
}
Future<void> test_notBlock() async {
- /// No assist because this is a bad formatted `if else` statement.
+ // No assist because this is a bad formatted `if else` statement.
await resolveTestCode('''
void f() {
if (1 == 1) print(0);
else
- if (2 == 2) {
+ i^f (2 == 2) {
print(1);
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
Future<void> test_outerNotIf() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
print(0);
}
}
''');
- await assertNoAssistAt('if (1 == 1');
+ await assertNoAssist();
}
Future<void> test_statementAfterInner() async {
@@ -689,14 +690,14 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(2);
}
print(1);
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
Future<void> test_statementBeforeInner() async {
@@ -705,13 +706,13 @@
if (1 == 1) {
} else {
print(1);
- if (2 == 2) {
+ i^f (2 == 2) {
print(2);
}
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
Future<void> test_targetWithElseBlock() async {
@@ -719,7 +720,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else {
print(1);
@@ -727,7 +728,7 @@
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -744,7 +745,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else if (3 == 3) {
print(1);
@@ -752,7 +753,7 @@
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -769,7 +770,7 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else if (3 == 3) {
print(1);
@@ -779,7 +780,7 @@
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
@@ -798,13 +799,13 @@
void f() {
if (1 == 1) {
} else {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else print(1);
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
} else if (2 == 2) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/join_if_with_inner_test.dart b/pkg/analysis_server/test/src/services/correction/assist/join_if_with_inner_test.dart
index 6081903..eca9df3 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/join_if_with_inner_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/join_if_with_inner_test.dart
@@ -22,27 +22,27 @@
Future<void> test_bothOuterAndInnerAreIfCase() async {
await resolveTestCode('''
void f(Object? p) {
- if (p case final v?) {
+ ^if (p case final v?) {
if (v case final int x) {
print(0);
}
}
}
''');
- await assertNoAssistAt('if (p');
+ await assertNoAssist();
}
Future<void> test_conditionAndOr() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
if (2 == 2 || 3 == 3) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (1 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && (2 == 2 || 3 == 3)) {
print(0);
@@ -54,7 +54,7 @@
Future<void> test_conditionInvocation() async {
await resolveTestCode('''
void f() {
- if (isCheck()) {
+ ^if (isCheck()) {
if (2 == 2) {
print(0);
}
@@ -62,7 +62,7 @@
}
bool isCheck() => false;
''');
- await assertHasAssistAt('if (isCheck', '''
+ await assertHasAssist('''
void f() {
if (isCheck() && 2 == 2) {
print(0);
@@ -75,14 +75,14 @@
Future<void> test_conditionOrAnd() async {
await resolveTestCode('''
void f() {
- if (1 == 1 || 2 == 2) {
+ i^f (1 == 1 || 2 == 2) {
if (3 == 3) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (1 ==', '''
+ await assertHasAssist('''
void f() {
if ((1 == 1 || 2 == 2) && 3 == 3) {
print(0);
@@ -94,14 +94,14 @@
Future<void> test_ifCaseAddWhen() async {
await resolveTestCode('''
void f(Object? p) {
- if (p case final int v) {
+ i^f (p case final int v) {
if (v == 5) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (p', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when v == 5) {
print(0);
@@ -113,14 +113,14 @@
Future<void> test_ifCaseAddWhenUnrelated() async {
await resolveTestCode('''
void f(Object? p, Object? q) {
- if (p case final int v) {
+ ^if (p case final int v) {
if (q != null) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (p', '''
+ await assertHasAssist('''
void f(Object? p, Object? q) {
if (p case final int v when q != null) {
print(0);
@@ -132,14 +132,14 @@
Future<void> test_ifCaseAppendWhen() async {
await resolveTestCode('''
void f(Object? p) {
- if (p case final int v when v.isOdd) {
+ if^ (p case final int v when v.isOdd) {
if (v == 5) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (p', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when v.isOdd && v == 5) {
print(0);
@@ -151,14 +151,14 @@
Future<void> test_ifCaseAppendWhenWithParenthesisBoth() async {
await resolveTestCode('''
void f(Object? p) {
- if (p case final int v when v.isOdd || v > 3) {
+ i^f (p case final int v when v.isOdd || v > 3) {
if (v == 5 || v != 6) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (p', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when (v.isOdd || v > 3) && (v == 5 || v != 6)) {
print(0);
@@ -170,14 +170,14 @@
Future<void> test_ifCaseAppendWhenWithParenthesisInner() async {
await resolveTestCode('''
void f(Object? p) {
- if (p case final int v when v.isOdd) {
+ i^f (p case final int v when v.isOdd) {
if (v == 5 || v != 3) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (p', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when v.isOdd && (v == 5 || v != 3)) {
print(0);
@@ -189,14 +189,14 @@
Future<void> test_ifCaseAppendWhenWithParenthesisOuter() async {
await resolveTestCode('''
void f(Object? p) {
- if (p case final int v when v.isOdd || v != 3) {
+ i^f (p case final int v when v.isOdd || v != 3) {
if (v == 5) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (p', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when (v.isOdd || v != 3) && v == 5) {
print(0);
@@ -208,18 +208,18 @@
Future<void> test_innerNotIf() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
print(0);
}
}
''');
- await assertNoAssistAt('if (1 ==');
+ await assertNoAssist();
}
Future<void> test_innerWithElse() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
if (2 == 2) {
print(0);
} else {
@@ -228,20 +228,20 @@
}
}
''');
- await assertNoAssistAt('if (1 ==');
+ await assertNoAssist();
}
Future<void> test_onCondition() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ if (^1 == 1) {
if (2 == 2) {
print(0);
}
}
}
''');
- await assertHasAssistAt('1 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -253,14 +253,14 @@
Future<void> test_simpleConditions_block_block() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ if^ (1 == 1) {
if (2 == 2) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (1 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -272,13 +272,13 @@
Future<void> test_simpleConditions_block_single() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
if (2 == 2)
print(0);
}
}
''');
- await assertHasAssistAt('if (1 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -290,7 +290,7 @@
Future<void> test_simpleConditions_single_blockMulti() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ if^ (1 == 1) {
if (2 == 2) {
print(1);
print(2);
@@ -299,7 +299,7 @@
}
}
''');
- await assertHasAssistAt('if (1 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(1);
@@ -313,13 +313,13 @@
Future<void> test_simpleConditions_single_blockOne() async {
await resolveTestCode('''
void f() {
- if (1 == 1)
+ i^f (1 == 1)
if (2 == 2) {
print(0);
}
}
''');
- await assertHasAssistAt('if (1 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -331,7 +331,7 @@
Future<void> test_statementAfterInner() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
if (2 == 2) {
print(2);
}
@@ -339,13 +339,13 @@
}
}
''');
- await assertNoAssistAt('if (1 ==');
+ await assertNoAssist();
}
Future<void> test_statementBeforeInner() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
print(1);
if (2 == 2) {
print(2);
@@ -353,22 +353,22 @@
}
}
''');
- await assertNoAssistAt('if (1 ==');
+ await assertNoAssist();
}
Future<void> test_targetNotIf() async {
await resolveTestCode('''
void f() {
- print(0);
+ pri^nt(0);
}
''');
- await assertNoAssistAt('print');
+ await assertNoAssist();
}
Future<void> test_targetWithElse() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ if^ (1 == 1) {
if (2 == 2) {
print(0);
}
@@ -377,6 +377,6 @@
}
}
''');
- await assertNoAssistAt('if (1 ==');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/join_if_with_outer_test.dart b/pkg/analysis_server/test/src/services/correction/assist/join_if_with_outer_test.dart
index 824df47..7385b94 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/join_if_with_outer_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/join_if_with_outer_test.dart
@@ -23,26 +23,26 @@
await resolveTestCode('''
void f(Object? p) {
if (p case final v?) {
- if (v case final int x) {
+ i^f (v case final int x) {
print(x);
}
}
}
''');
- await assertNoAssistAt('if (v');
+ await assertNoAssist();
}
Future<void> test_conditionAndOr() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2 || 3 == 3) {
+ ^if (2 == 2 || 3 == 3) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (2 ==', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && (2 == 2 || 3 == 3)) {
print(0);
@@ -55,14 +55,14 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (isCheck()) {
+ i^f (isCheck()) {
print(0);
}
}
}
bool isCheck() => false;
''');
- await assertHasAssistAt('if (isCheck', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && isCheck()) {
print(0);
@@ -76,13 +76,13 @@
await resolveTestCode('''
void f() {
if (1 == 1 || 2 == 2) {
- if (3 == 3) {
+ if^ (3 == 3) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (3 == 3', '''
+ await assertHasAssist('''
void f() {
if ((1 == 1 || 2 == 2) && 3 == 3) {
print(0);
@@ -95,13 +95,13 @@
await resolveTestCode('''
void f(Object? p) {
if (p case final int v) {
- if (v == 5) {
+ if^ (v == 5) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (v == 5', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when v == 5) {
print(0);
@@ -114,13 +114,13 @@
await resolveTestCode('''
void f(Object? p, Object? q) {
if (p case final int v) {
- if (q != null) {
+ i^f (q != null) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (q != null', '''
+ await assertHasAssist('''
void f(Object? p, Object? q) {
if (p case final int v when q != null) {
print(0);
@@ -133,13 +133,13 @@
await resolveTestCode('''
void f(Object? p) {
if (p case final int v when v.isOdd) {
- if (v == 5) {
+ i^f (v == 5) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (v == 5', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when v.isOdd && v == 5) {
print(0);
@@ -152,13 +152,13 @@
await resolveTestCode('''
void f(Object? p) {
if (p case final int v when v.isOdd || v > 3) {
- if (v == 5 || v != 6) {
+ i^f (v == 5 || v != 6) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (v', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when (v.isOdd || v > 3) && (v == 5 || v != 6)) {
print(0);
@@ -171,13 +171,13 @@
await resolveTestCode('''
void f(Object? p) {
if (p case final int v when v.isOdd) {
- if (v == 5 || v != 3) {
+ ^if (v == 5 || v != 3) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (v', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when v.isOdd && (v == 5 || v != 3)) {
print(0);
@@ -190,13 +190,13 @@
await resolveTestCode('''
void f(Object? p) {
if (p case final int v when v.isOdd || v != 3) {
- if (v == 5) {
+ ^if (v == 5) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (v', '''
+ await assertHasAssist('''
void f(Object? p) {
if (p case final int v when (v.isOdd || v != 3) && v == 5) {
print(0);
@@ -209,13 +209,13 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2) {
+ ^if (2 == 2) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -227,19 +227,19 @@
Future<void> test_outerNotIf() async {
await resolveTestCode('''
void f() {
- if (1 == 1) {
+ i^f (1 == 1) {
print(0);
}
}
''');
- await assertNoAssistAt('if (1 == 1');
+ await assertNoAssist();
}
Future<void> test_outerWithElse() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
}
} else {
@@ -247,20 +247,20 @@
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
Future<void> test_simpleConditions_block_block() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
}
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -273,12 +273,12 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2)
+ ^if (2 == 2)
print(0);
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -291,7 +291,7 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2) {
+ ^if (2 == 2) {
print(1);
print(2);
print(3);
@@ -299,7 +299,7 @@
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(1);
@@ -314,12 +314,12 @@
await resolveTestCode('''
void f() {
if (1 == 1)
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
}
}
''');
- await assertHasAssistAt('if (2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1 && 2 == 2) {
print(0);
@@ -332,14 +332,14 @@
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2) {
+ i^f (2 == 2) {
print(2);
}
print(1);
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
Future<void> test_statementBeforeInner() async {
@@ -347,29 +347,29 @@
void f() {
if (1 == 1) {
print(1);
- if (2 == 2) {
+ i^f (2 == 2) {
print(2);
}
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
Future<void> test_targetNotIf() async {
await resolveTestCode('''
void f() {
- print(0);
+ pri^nt(0);
}
''');
- await assertNoAssistAt('print');
+ await assertNoAssist();
}
Future<void> test_targetWithElse() async {
await resolveTestCode('''
void f() {
if (1 == 1) {
- if (2 == 2) {
+ i^f (2 == 2) {
print(0);
} else {
print(1);
@@ -377,6 +377,6 @@
}
}
''');
- await assertNoAssistAt('if (2 == 2');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/join_variable_declaration_test.dart b/pkg/analysis_server/test/src/services/correction/assist/join_variable_declaration_test.dart
index 54cce7b..a1a6f6f 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/join_variable_declaration_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/join_variable_declaration_test.dart
@@ -23,10 +23,10 @@
await resolveTestCode('''
void f() {
var v;
- v = 1;
+ ^v = 1;
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
var v = 1;
}
@@ -37,10 +37,10 @@
await resolveTestCode('''
void f() {
var v = 1;
- v = 2;
+ ^v = 2;
}
''');
- await assertNoAssistAt('v = 2');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notAdjacent() async {
@@ -48,49 +48,49 @@
void f() {
var v;
var bar;
- v = 1;
+ ^v = 1;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notAssignment() async {
await resolveTestCode('''
void f() {
var v;
- v += 1;
+ ^v += 1;
}
''');
- await assertNoAssistAt('v += 1');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notDeclaration() async {
await resolveTestCode('''
void f(var v) {
- v = 1;
+ ^v = 1;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notLeftArgument() async {
await resolveTestCode('''
void f() {
var v;
- 1 + v; // marker
+ 1 + ^v;
}
''');
- await assertNoAssistAt('v; // marker');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notOneVariable() async {
await resolveTestCode('''
void f() {
var v, v2;
- v = 1;
+ ^v = 1;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notResolved() async {
@@ -98,10 +98,10 @@
await resolveTestCode('''
void f() {
var v;
- x = 1;
+ ^x = 1;
}
''');
- await assertNoAssistAt('x = 1');
+ await assertNoAssist();
}
Future<void> test_onAssignment_notSameBlock() async {
@@ -109,81 +109,81 @@
void f() {
var v;
{
- v = 1;
+ ^v = 1;
}
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_hasInitializer() async {
await resolveTestCode('''
void f() {
- var v = 1;
+ var ^v = 1;
v = 2;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_lastStatement() async {
await resolveTestCode('''
void f() {
if (true)
- var v;
+ var ^v;
}
''');
- await assertNoAssistAt('v;');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_nextNotAssignmentExpression() async {
await resolveTestCode('''
void f() {
- var v;
+ var ^v;
42;
}
''');
- await assertNoAssistAt('v;');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_nextNotExpressionStatement() async {
await resolveTestCode('''
void f() {
- var v;
+ var ^v;
if (true) return;
}
''');
- await assertNoAssistAt('v;');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_nextNotPureAssignment() async {
await resolveTestCode('''
void f() {
- var v;
+ var ^v;
v += 1;
}
''');
- await assertNoAssistAt('v;');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_notOneVariable() async {
await resolveTestCode('''
void f() {
- var v, v2;
+ var ^v, v2;
v = 1;
}
''');
- await assertNoAssistAt('v, ');
+ await assertNoAssist();
}
Future<void> test_onDeclaration_onName() async {
await resolveTestCode('''
void f() {
- var v;
+ var ^v;
v = 1;
}
''');
- await assertHasAssistAt('v;', '''
+ await assertHasAssist('''
void f() {
var v = 1;
}
@@ -193,11 +193,11 @@
Future<void> test_onDeclaration_onType() async {
await resolveTestCode('''
void f() {
- int v;
+ ^int v;
v = 1;
}
''');
- await assertHasAssistAt('int v', '''
+ await assertHasAssist('''
void f() {
int v = 1;
}
@@ -207,11 +207,11 @@
Future<void> test_onDeclaration_onVar() async {
await resolveTestCode('''
void f() {
- var v;
+ ^var v;
v = 1;
}
''');
- await assertHasAssistAt('var v', '''
+ await assertHasAssist('''
void f() {
var v = 1;
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart
index 5199572..ad7551b 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/remove_type_annotation_test.dart
@@ -22,10 +22,10 @@
Future<void> test_classField() async {
await resolveTestCode('''
class A {
- int v = 1;
+ int ^v = 1;
}
''');
- await assertHasAssistAt('v = ', '''
+ await assertHasAssist('''
class A {
var v = 1;
}
@@ -35,10 +35,10 @@
Future<void> test_classField_final() async {
await resolveTestCode('''
class A {
- final int v = 1;
+ final int ^v = 1;
}
''');
- await assertHasAssistAt('v = ', '''
+ await assertHasAssist('''
class A {
final v = 1;
}
@@ -48,18 +48,18 @@
Future<void> test_field_noInitializer() async {
await resolveTestCode('''
class A {
- int? v;
+ int? ^v;
}
''');
- await assertNoAssistAt('v');
+ await assertNoAssist();
}
Future<void> test_generic_instanceCreation_withoutArguments() async {
await resolveTestCode('''
-C<int> c = C();
+C<int> ^c = C();
class C<T> {}
''');
- await assertHasAssistAt('c = ', '''
+ await assertHasAssist('''
var c = C<int>();
class C<T> {}
''');
@@ -67,9 +67,9 @@
Future<void> test_generic_listLiteral() async {
await resolveTestCode('''
-List<int> l = [];
+List<int> ^l = [];
''');
- await assertHasAssistAt('l = ', '''
+ await assertHasAssist('''
var l = <int>[];
''');
}
@@ -86,9 +86,9 @@
Future<void> test_generic_setLiteral_cascade() async {
await resolveTestCode('''
-Set<String> s = {}..addAll([]);
+Set<String> ^s = {}..addAll([]);
''');
- await assertHasAssistAt('s = ', '''
+ await assertHasAssist('''
var s = <String>{}..addAll([]);
''');
}
@@ -98,19 +98,19 @@
class A {}
void f() {
- A();
+ ^A();
}
''');
- await assertNoAssistAt('A();');
+ await assertNoAssist();
}
Future<void> test_localVariable() async {
await resolveTestCode('''
void f() {
- int a = 1, b = 2;
+ ^int a = 1, b = 2;
}
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
void f() {
var a = 1, b = 2;
}
@@ -120,10 +120,10 @@
Future<void> test_localVariable_const() async {
await resolveTestCode('''
void f() {
- const int v = 1;
+ const ^int v = 1;
}
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
void f() {
const v = 1;
}
@@ -133,10 +133,10 @@
Future<void> test_localVariable_final() async {
await resolveTestCode('''
void f() {
- final int v = 1;
+ final ^int v = 1;
}
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
void f() {
final v = 1;
}
@@ -146,28 +146,28 @@
Future<void> test_localVariable_noInitializer() async {
await resolveTestCode('''
void f() {
- int v;
+ int ^v;
}
''');
- await assertNoAssistAt('v;');
+ await assertNoAssist();
}
Future<void> test_localVariable_onInitializer() async {
await resolveTestCode('''
void f() {
- final int v = 1;
+ final int v = ^1;
}
''');
- await assertNoAssistAt('1;');
+ await assertNoAssist();
}
Future<void> test_loopVariable() async {
await resolveTestCode('''
void f() {
- for(int i = 0; i < 3; i++) {}
+ for(^int i = 0; i < 3; i++) {}
}
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
void f() {
for(var i = 0; i < 3; i++) {}
}
@@ -178,11 +178,11 @@
await resolveTestCode('''
void f() {
var v = () {
- for (int x in <int>[]) {}
+ for (^int x in <int>[]) {}
};
}
''');
- await assertHasAssistAt('int x', '''
+ await assertHasAssist('''
void f() {
var v = () {
for (var x in <int>[]) {}
@@ -194,26 +194,26 @@
Future<void> test_loopVariable_noType() async {
await resolveTestCode('''
void f() {
- for(var i = 0; i < 3; i++) {}
+ for(v^ar i = 0; i < 3; i++) {}
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
Future<void> test_topLevelVariable() async {
await resolveTestCode('''
-int V = 1;
+^int V = 1;
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
var V = 1;
''');
}
Future<void> test_topLevelVariable_final() async {
await resolveTestCode('''
-final int V = 1;
+final i^nt V = 1;
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
final V = 1;
''');
}
@@ -221,16 +221,16 @@
Future<void> test_topLevelVariable_noInitializer() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-int v;
+int v^;
''');
- await assertNoAssistAt('v;');
+ await assertNoAssist();
}
Future<void> test_topLevelVariable_syntheticName() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-MyType
+MyType^
''');
- await assertNoAssistAt('MyType');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/replace_conditional_with_if_else_test.dart b/pkg/analysis_server/test/src/services/correction/assist/replace_conditional_with_if_else_test.dart
index e5f1923..a6e360d 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/replace_conditional_with_if_else_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/replace_conditional_with_if_else_test.dart
@@ -23,22 +23,11 @@
await resolveTestCode('''
void f(bool c) {
var v;
- v = c ? 111 : 222;
-}
-''');
- // on conditional
- await assertHasAssistAt('11 :', '''
-void f(bool c) {
- var v;
- if (c) {
- v = 111;
- } else {
- v = 222;
- }
+ /*0*/v = c ? 1/*1*/11 : 222;
}
''');
// on variable
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f(bool c) {
var v;
if (c) {
@@ -48,31 +37,42 @@
}
}
''');
+ // on conditional
+ await assertHasAssist('''
+void f(bool c) {
+ var v;
+ if (c) {
+ v = 111;
+ } else {
+ v = 222;
+ }
+}
+''', index: 1);
}
Future<void> test_noEnclosingStatement() async {
await resolveTestCode('''
-var v = true ? 111 : 222;
+var v = true ^? 111 : 222;
''');
- await assertNoAssistAt('? 111');
+ await assertNoAssist();
}
Future<void> test_notConditional() async {
await resolveTestCode('''
void f() {
- var v = 42;
+ var ^v = 42;
}
''');
- await assertNoAssistAt('v = 42');
+ await assertNoAssist();
}
Future<void> test_return() async {
await resolveTestCode('''
int f(bool c) {
- return c ? 111 : 222;
+ ^return c ? 111 : 222;
}
''');
- await assertHasAssistAt('return ', '''
+ await assertHasAssist('''
int f(bool c) {
if (c) {
return 111;
@@ -86,10 +86,10 @@
Future<void> test_variableDeclaration_final() async {
await resolveTestCode('''
void f(bool c) {
- final a = c ? 111 : 222;
+ final a = c ? 1^11 : 222;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
final int a;
if (c) {
@@ -104,10 +104,10 @@
Future<void> test_variableDeclaration_oneOfMany() async {
await resolveTestCode('''
void f(bool c) {
- int a = 1, vvv = c ? 111 : 222, b = 2;
+ int a = 1, vvv = c ? 1^11 : 222, b = 2;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
int a = 1, vvv, b = 2;
if (c) {
@@ -122,10 +122,10 @@
Future<void> test_variableDeclaration_type() async {
await resolveTestCode('''
void f(bool c) {
- num a = c ? 111 : 222;
+ num a = c ? 1^11 : 222;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
num a;
if (c) {
@@ -140,10 +140,10 @@
Future<void> test_variableDeclaration_type_final() async {
await resolveTestCode('''
void f(bool c) {
- final num a = c ? 111 : 222;
+ final num a = c ? 1^11 : 222;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
final num a;
if (c) {
@@ -159,10 +159,10 @@
writeTestPackageConfig(languageVersion: '2.12.0');
await resolveTestCode('''
void f(bool c) {
- late num a = c ? 111 : 222;
+ late num a = c ? 1^11 : 222;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
late num a;
if (c) {
@@ -177,10 +177,10 @@
Future<void> test_variableDeclaration_var() async {
await resolveTestCode('''
void f(bool c) {
- var a = c ? 111 : 222;
+ var a = c ? 1^11 : 222;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
int a;
if (c) {
@@ -196,10 +196,10 @@
writeTestPackageConfig(languageVersion: '2.12.0');
await resolveTestCode('''
void f(bool c) {
- late var a = c ? 111 : 222;
+ late var a = c ? 1^11 : 222;
}
''');
- await assertHasAssistAt('11 :', '''
+ await assertHasAssist('''
void f(bool c) {
late int a;
if (c) {
diff --git a/pkg/analysis_server/test/src/services/correction/assist/replace_if_else_with_conditional_test.dart b/pkg/analysis_server/test/src/services/correction/assist/replace_if_else_with_conditional_test.dart
index 530422c..a7e516d 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/replace_if_else_with_conditional_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/replace_if_else_with_conditional_test.dart
@@ -23,14 +23,14 @@
await resolveTestCode('''
void f() {
int vvv;
- if (true) {
+ i^f (true) {
vvv = 111;
} else {
vvv = 222;
}
}
''');
- await assertHasAssistAt('if (true)', '''
+ await assertHasAssist('''
void f() {
int vvv;
vvv = true ? 111 : 222;
@@ -43,12 +43,12 @@
void f() {
if (true) {
print(42);
- } else {
+ } el^se {
return;
}
}
''');
- await assertNoAssistAt('else');
+ await assertNoAssist();
}
Future<void> test_ifCasePattern() async {
@@ -56,30 +56,30 @@
f() {
var json = [1, 2, 3];
int vvv;
- if (json case [3, 4]) {
+ i^f (json case [3, 4]) {
vvv = 111;
} else {
vvv = 222;
}
}
''');
- await assertNoAssistAt('if (json case [3, 4])');
+ await assertNoAssist();
}
Future<void> test_notIfStatement() async {
await resolveTestCode('''
void f() {
- print(0);
+ p^rint(0);
}
''');
- await assertNoAssistAt('print');
+ await assertNoAssist();
}
Future<void> test_notSingleStatement() async {
await resolveTestCode('''
void f() {
int vvv;
- if (true) {
+ i^f (true) {
print(0);
vvv = 111;
} else {
@@ -88,20 +88,20 @@
}
}
''');
- await assertNoAssistAt('if (true)');
+ await assertNoAssist();
}
Future<void> test_return_expression_expression() async {
await resolveTestCode('''
int f() {
- if (true) {
+ i^f (true) {
return 111;
} else {
return 222;
}
}
''');
- await assertHasAssistAt('if (true)', '''
+ await assertHasAssist('''
int f() {
return true ? 111 : 222;
}
@@ -112,27 +112,27 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(bool c) {
- if (c) {
+ i^f (c) {
return 111;
} else {
return;
}
}
''');
- await assertNoAssistAt('if (c)');
+ await assertNoAssist();
}
Future<void> test_return_nothing_expression() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
void f(bool c) {
- if (c) {
+ ^if (c) {
return;
} else {
return 222;
}
}
''');
- await assertNoAssistAt('if (c)');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart b/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
index b40d609..05459e9 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/shadow_field_test.dart
@@ -25,7 +25,7 @@
num f = 0;
void m() {
- if (f is int) {
+ if (^f is int) {
print(f.abs());
}
f = 0;
@@ -33,7 +33,7 @@
}
}
''');
- await assertNoAssistAt('f is');
+ await assertNoAssist();
}
Future<void> test_is_noBlock_while() async {
@@ -43,13 +43,13 @@
void m() {
while (true)
- if (f is int) {
+ if (^f is int) {
print((f as int).abs());
}
}
}
''');
- await assertNoAssistAt('f is');
+ await assertNoAssist();
}
Future<void> test_is_referencedViaThis() async {
@@ -58,13 +58,13 @@
num f = 0;
void m() {
- if (f is int) {
+ if (^f is int) {
print(this.f);
}
}
}
''');
- await assertHasAssistAt('f is', '''
+ await assertHasAssist('''
class C {
num f = 0;
@@ -84,13 +84,13 @@
num f = 0;
void m() {
- if (f is int) {
+ if (^f is int) {
print((f as int).abs());
}
}
}
''');
- await assertHasAssistAt('f is', '''
+ await assertHasAssist('''
class C {
num f = 0;
@@ -110,13 +110,13 @@
int? f;
void m() {
- if (f != null) {
+ if (^f != null) {
print(f!.abs());
}
}
}
''');
- await assertHasAssistAt('f !=', '''
+ await assertHasAssist('''
class C {
int? f;
@@ -136,7 +136,7 @@
int? f;
void m() {
- if (f != null) {
+ if (^f != null) {
print(f!.abs());
}
f = 0;
@@ -144,7 +144,7 @@
}
}
''');
- await assertNoAssistAt('f != ');
+ await assertNoAssist();
}
Future<void> test_notNull_referencedViaThis() async {
@@ -153,13 +153,13 @@
int? f;
void m() {
- if (f != null) {
+ if (^f != null) {
print(this.f!);
}
}
}
''');
- await assertHasAssistAt('f != ', '''
+ await assertHasAssist('''
class C {
int? f;
diff --git a/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart b/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart
index 067bdd6..7e4181d 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/sort_child_property_last_test.dart
@@ -32,7 +32,7 @@
void f() {
Column(
crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
+ c^hildren: <Widget>[
Text('aaa'),
Text('bbbbbb'),
Text('ccccccccc'),
@@ -48,7 +48,7 @@
import 'package:flutter/material.dart';
void f() {
Column(
- children: <Widget>[
+ childr^en: <Widget>[
Text('aaa'),
Text('bbbbbb'),
Text('ccccccccc'),
@@ -64,7 +64,7 @@
import 'package:flutter/material.dart';
void f() {
Column(
- crossAxisAlignment: CrossAxisAlignment.center,
+ cro^ssAxisAlignment: CrossAxisAlignment.center,
);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/assist/split_and_condition_test.dart b/pkg/analysis_server/test/src/services/correction/assist/split_and_condition_test.dart
index 7cd898c..a55e0ac 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/split_and_condition_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/split_and_condition_test.dart
@@ -22,25 +22,25 @@
Future<void> test_hasElse() async {
await resolveTestCode('''
void f() {
- if (1 == 1 && 2 == 2) {
+ if (1 == 1 ^&& 2 == 2) {
print(1);
} else {
print(2);
}
}
''');
- await assertNoAssistAt('&& 2');
+ await assertNoAssist();
}
Future<void> test_innerAndExpression() async {
await resolveTestCode('''
void f() {
- if (1 == 1 && 2 == 2 && 3 == 3) {
+ if (1 == 1 ^&& 2 == 2 && 3 == 3) {
print(0);
}
}
''');
- await assertHasAssistAt('&& 2 == 2', '''
+ await assertHasAssist('''
void f() {
if (1 == 1) {
if (2 == 2 && 3 == 3) {
@@ -54,48 +54,48 @@
Future<void> test_notAnd() async {
await resolveTestCode('''
void f() {
- if (1 == 1 || 2 == 2) {
+ if (1 == 1 ^|| 2 == 2) {
print(0);
}
}
''');
- await assertNoAssistAt('|| 2');
+ await assertNoAssist();
}
Future<void> test_notOnOperator() async {
await resolveTestCode('''
-void f() {
+void ^f() {
if (1 == 1 && 2 == 2) {
print(0);
}
print(3 == 3 && 4 == 4);
}
''');
- await assertNoAssistAt('f() {');
+ await assertNoAssist();
}
Future<void> test_notPartOfIf() async {
await resolveTestCode('''
void f() {
- print(1 == 1 && 2 == 2);
+ print(1 == 1 ^&& 2 == 2);
}
''');
- await assertNoAssistAt('&& 2');
+ await assertNoAssist();
}
Future<void> test_notTopLevelAnd() async {
await resolveTestCode('''
void f() {
- if (true || (1 == 1 && 2 == 2)) {
+ if (true || (1 == 1 /*0*/&& 2 == 2)) {
print(0);
}
- if (true && (3 == 3 && 4 == 4)) {
+ if (true && (3 == 3 /*1*/&& 4 == 4)) {
print(0);
}
}
''');
- await assertNoAssistAt('&& 2');
- await assertNoAssistAt('&& 4');
+ await assertNoAssist();
+ await assertNoAssist(1);
}
Future<void> test_selectionTooLarge() async {
@@ -113,7 +113,7 @@
Future<void> test_thenBlock() async {
await resolveTestCode('''
void f() {
- if (true && false) {
+ if (true ^&& false) {
print(0);
if (3 == 3) {
print(1);
@@ -121,7 +121,7 @@
}
}
''');
- await assertHasAssistAt('&& false', '''
+ await assertHasAssist('''
void f() {
if (true) {
if (false) {
@@ -138,11 +138,11 @@
Future<void> test_thenStatement() async {
await resolveTestCode('''
void f() {
- if (true && false)
+ if (true ^&& false)
print(0);
}
''');
- await assertHasAssistAt('&& false', '''
+ await assertHasAssist('''
void f() {
if (true)
if (false)
diff --git a/pkg/analysis_server/test/src/services/correction/assist/split_variable_declaration_test.dart b/pkg/analysis_server/test/src/services/correction/assist/split_variable_declaration_test.dart
index 3281946..986f899 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/split_variable_declaration_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/split_variable_declaration_test.dart
@@ -22,37 +22,37 @@
Future<void> test_const() async {
await resolveTestCode('''
void f() {
- const v = 1;
+ const ^v = 1;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_final() async {
await resolveTestCode('''
void f() {
- final v = 1;
+ final ^v = 1;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_notOneVariable() async {
await resolveTestCode('''
void f() {
- var v = 1, v2;
+ var ^v = 1, v2;
}
''');
- await assertNoAssistAt('v = 1');
+ await assertNoAssist();
}
Future<void> test_onName() async {
await resolveTestCode('''
void f() {
- var v = 1;
+ var ^v = 1;
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
int v;
v = 1;
@@ -64,10 +64,10 @@
await resolveTestCode('''
f() => 1;
void g() {
- var v = f();
+ var ^v = f();
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
f() => 1;
void g() {
var v;
@@ -79,10 +79,10 @@
Future<void> test_onName_recordType() async {
await resolveTestCode('''
void f() {
- (int, int) v = (1, 2);
+ (int, int) ^v = (1, 2);
}
''');
- await assertHasAssistAt('v =', '''
+ await assertHasAssist('''
void f() {
(int, int) v;
v = (1, 2);
@@ -93,10 +93,10 @@
Future<void> test_onType() async {
await resolveTestCode('''
void f() {
- int v = 1;
+ ^int v = 1;
}
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
void f() {
int v;
v = 1;
@@ -108,10 +108,10 @@
Future<void> test_onType_prefixedByComment() async {
await resolveTestCode('''
void f() {
- /*comment*/int v = 1;
+ /*comment*/^int v = 1;
}
''');
- await assertHasAssistAt('int ', '''
+ await assertHasAssist('''
void f() {
/*comment*/int v;
v = 1;
@@ -122,10 +122,10 @@
Future<void> test_onType_recordType() async {
await resolveTestCode('''
void f() {
- (int, int) v = (1, 2);
+ (int, ^int) v = (1, 2);
}
''');
- await assertHasAssistAt('int)', '''
+ await assertHasAssist('''
void f() {
(int, int) v;
v = (1, 2);
@@ -136,10 +136,10 @@
Future<void> test_onVar() async {
await resolveTestCode('''
void f() {
- var v = 1;
+ ^var v = 1;
}
''');
- await assertHasAssistAt('var ', '''
+ await assertHasAssist('''
void f() {
int v;
v = 1;
@@ -150,10 +150,10 @@
Future<void> test_onVar_recordLiteral() async {
await resolveTestCode('''
void f() {
- var v = (1, 2);
+ ^var v = (1, 2);
}
''');
- await assertHasAssistAt('var', '''
+ await assertHasAssist('''
void f() {
(int, int) v;
v = (1, 2);
@@ -173,9 +173,9 @@
import 'package:test/a.dart';
f(A a) {
- var x = a.b();
+ ^var x = a.b();
}
''');
- await assertNoAssistAt('var ');
+ await assertNoAssist();
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_super_parameter_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_super_parameter_test.dart
index a02e6c7..62e0c67 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_super_parameter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_super_parameter_test.dart
@@ -43,6 +43,29 @@
Future<void> test_named_first_existingPositional() async {
await resolveTestCode('''
class A {
+ A({required int a, required int b});
+}
+class B extends A {
+ B(this.i);
+
+ final int i;
+}
+''');
+ await assertHasFix('''
+class A {
+ A({required int a, required int b});
+}
+class B extends A {
+ B(this.i, {required super.a, required super.b});
+
+ final int i;
+}
+''');
+ }
+
+ Future<void> test_named_first_existingPositional2() async {
+ await resolveTestCode('''
+class A {
A(int i, {required int a, required int b});
}
class B extends A {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_decorated_box_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_decorated_box_test.dart
index bb9c8b7..7bafb5a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_decorated_box_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_decorated_box_test.dart
@@ -313,11 +313,11 @@
import 'package:flutter/material.dart';
void f() {
- Container(
+ Container( // 1
decoration: BoxDecoration(),
- child: Container(
+ child: Container( // 2
decoration: const BoxDecoration(),
- child: Container(
+ child: Container( // 3
decoration: BoxDecoration(),
child: Text(''),
),
@@ -331,11 +331,11 @@
import 'package:flutter/material.dart';
void f() {
- DecoratedBox(
+ DecoratedBox( // 1
decoration: BoxDecoration(),
- child: Container(
+ child: Container( // 2
decoration: const BoxDecoration(),
- child: Container(
+ child: Container( // 3
decoration: BoxDecoration(),
child: Text(''),
),
@@ -344,7 +344,8 @@
}
''',
allowFixAllFixes: true,
- errorFilter: (error) => error.offset == 54,
+ errorFilter:
+ (error) => error.offset == testCode.indexOf('Container( // 1'),
);
await assertHasFix(
@@ -352,11 +353,11 @@
import 'package:flutter/material.dart';
void f() {
- Container(
+ Container( // 1
decoration: BoxDecoration(),
- child: DecoratedBox(
+ child: DecoratedBox( // 2
decoration: const BoxDecoration(),
- child: Container(
+ child: Container( // 3
decoration: BoxDecoration(),
child: Text(''),
),
@@ -365,7 +366,8 @@
}
''',
allowFixAllFixes: true,
- errorFilter: (error) => error.offset == 109,
+ errorFilter:
+ (error) => error.offset == testCode.indexOf('Container( // 2'),
);
await assertHasFix(
@@ -373,11 +375,11 @@
import 'package:flutter/material.dart';
void f() {
- Container(
+ Container( // 1
decoration: BoxDecoration(),
- child: Container(
+ child: Container( // 2
decoration: const BoxDecoration(),
- child: const DecoratedBox(
+ child: const DecoratedBox( // 3
decoration: BoxDecoration(),
child: Text(''),
),
@@ -386,7 +388,8 @@
}
''',
allowFixAllFixes: true,
- errorFilter: (error) => error.offset == 174,
+ errorFilter:
+ (error) => error.offset == testCode.indexOf('Container( // 3'),
);
}
diff --git a/pkg/analyzer/api.txt b/pkg/analyzer/api.txt
index 2bf6011..2b1ed3b 100644
--- a/pkg/analyzer/api.txt
+++ b/pkg/analyzer/api.txt
@@ -283,7 +283,6 @@
arguments (getter: ArgumentList?)
atSign (getter: Token)
constructorName (getter: SimpleIdentifier?)
- element (getter: Element?, deprecated)
element2 (getter: Element2?, experimental)
elementAnnotation (getter: ElementAnnotation?)
name (getter: Identifier)
@@ -309,7 +308,6 @@
message (getter: Expression?)
rightParenthesis (getter: Token)
AssignedVariablePattern (class extends Object implements VariablePattern):
- element (getter: Element?, deprecated)
element2 (getter: Element2?, experimental)
AssignmentExpression (class extends Object implements NullShortableExpression, MethodReferenceExpression, CompoundAssignmentExpression):
leftHandSide (getter: Expression)
@@ -375,6 +373,7 @@
visitDeclaredVariablePattern (method: R? Function(DeclaredVariablePattern))
visitDefaultFormalParameter (method: R? Function(DefaultFormalParameter))
visitDoStatement (method: R? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: R? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: R? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: R? Function(DotShorthandPropertyAccess))
visitDottedName (method: R? Function(DottedName))
@@ -512,12 +511,10 @@
visitYieldStatement (method: R? Function(YieldStatement))
AugmentedExpression (class extends Object implements Expression):
augmentedKeyword (getter: Token)
- element (getter: Element?, deprecated)
fragment (getter: Fragment?, experimental)
AugmentedInvocation (class extends Object implements Expression):
arguments (getter: ArgumentList)
augmentedKeyword (getter: Token)
- element (getter: ExecutableElement?, deprecated)
fragment (getter: ExecutableFragment?, experimental)
typeArguments (getter: TypeArgumentList?)
AwaitExpression (class extends Object implements Expression):
@@ -564,7 +561,6 @@
rightParenthesis (getter: Token?)
stackTraceParameter (getter: CatchClauseParameter?)
CatchClauseParameter (class extends AstNode):
- declaredElement (getter: LocalVariableElement?, deprecated)
declaredElement2 (getter: LocalVariableElement2?, experimental)
declaredFragment (getter: LocalVariableFragment?, experimental)
name (getter: Token)
@@ -573,7 +569,6 @@
augmentKeyword (getter: Token?, experimental)
baseKeyword (getter: Token?)
classKeyword (getter: Token)
- declaredElement (getter: ClassElement?, deprecated)
declaredFragment (getter: ClassFragment?, experimental)
extendsClause (getter: ExtendsClause?)
finalKeyword (getter: Token?)
@@ -592,7 +587,6 @@
ClassTypeAlias (class extends Object implements TypeAlias):
abstractKeyword (getter: Token?)
baseKeyword (getter: Token?)
- declaredElement (getter: ClassElement?, deprecated)
declaredFragment (getter: ClassFragment?, experimental)
equals (getter: Token)
finalKeyword (getter: Token?)
@@ -620,7 +614,6 @@
CompilationUnit (class extends Object implements AstNode):
beginToken (getter: Token)
declarations (getter: NodeList<CompilationUnitMember>)
- declaredElement (getter: CompilationUnitElement?, deprecated)
declaredFragment (getter: LibraryFragment?, experimental)
directives (getter: NodeList<Directive>)
endToken (getter: Token)
@@ -632,10 +625,8 @@
sortedDirectivesAndDeclarations (getter: List<AstNode>)
CompilationUnitMember (class extends Object implements Declaration)
CompoundAssignmentExpression (class extends Object implements Expression):
- readElement (getter: Element?, deprecated)
readElement2 (getter: Element2?, experimental)
readType (getter: DartType?)
- writeElement (getter: Element?, deprecated)
writeElement2 (getter: Element2?, experimental)
writeType (getter: DartType?)
ConditionalExpression (class extends Object implements Expression):
@@ -660,7 +651,6 @@
augmentKeyword (getter: Token?)
body (getter: FunctionBody)
constKeyword (getter: Token?)
- declaredElement (getter: ConstructorElement?, deprecated)
declaredFragment (getter: ConstructorFragment?, experimental)
externalKeyword (getter: Token?)
factoryKeyword (getter: Token?)
@@ -686,7 +676,6 @@
constructorName (getter: ConstructorName)
ConstructorReferenceNode (class extends Object implements AstNode):
element (getter: ConstructorElement2?, experimental)
- staticElement (getter: ConstructorElement?, deprecated)
ConstructorSelector (class extends Object implements AstNode):
name (getter: SimpleIdentifier)
period (getter: Token)
@@ -700,10 +689,8 @@
precedence (getter: PatternPrecedence)
unParenthesized (getter: DartPattern)
Declaration (class extends Object implements AnnotatedNode):
- declaredElement (getter: Element?, deprecated)
declaredFragment (getter: Fragment?, experimental)
DeclaredIdentifier (class extends Object implements Declaration):
- declaredElement (getter: LocalVariableElement?, deprecated)
declaredElement2 (getter: LocalVariableElement2?, experimental)
declaredFragment (getter: LocalVariableFragment?)
isConst (getter: bool)
@@ -712,7 +699,6 @@
name (getter: Token)
type (getter: TypeAnnotation?)
DeclaredVariablePattern (class extends Object implements VariablePattern, sealed (immediate subtypes: DeclaredVariablePatternImpl)):
- declaredElement (getter: BindPatternVariableElement?, deprecated)
declaredElement2 (getter: BindPatternVariableElement2?, experimental)
declaredFragment (getter: BindPatternVariableFragment?)
keyword (getter: Token?)
@@ -721,8 +707,7 @@
defaultValue (getter: Expression?)
parameter (getter: NormalFormalParameter)
separator (getter: Token?)
- Directive (class extends Object implements AnnotatedNode, sealed (immediate subtypes: DirectiveImpl, LibraryDirective, PartOfDirective, UriBasedDirective)):
- element (getter: Element?, deprecated)
+ Directive (class extends Object implements AnnotatedNode, sealed (immediate subtypes: DirectiveImpl, LibraryDirective, PartOfDirective, UriBasedDirective))
DoStatement (class extends Object implements Statement):
body (getter: Statement)
condition (getter: Expression)
@@ -731,6 +716,9 @@
rightParenthesis (getter: Token)
semicolon (getter: Token)
whileKeyword (getter: Token)
+ DotShorthandConstructorInvocation (class extends InvocationExpression implements ConstructorReferenceNode, experimental):
+ constructorName (getter: SimpleIdentifier)
+ period (getter: Token)
DotShorthandInvocation (class extends InvocationExpression, experimental):
memberName (getter: SimpleIdentifier)
period (getter: Token)
@@ -753,15 +741,12 @@
EnumConstantDeclaration (class extends Object implements Declaration):
arguments (getter: EnumConstantArguments?)
augmentKeyword (getter: Token?, experimental)
- constructorElement (getter: ConstructorElement?, deprecated)
constructorElement2 (getter: ConstructorElement2?, experimental)
- declaredElement (getter: FieldElement?, deprecated)
declaredFragment (getter: FieldFragment?, experimental)
name (getter: Token)
EnumDeclaration (class extends Object implements NamedCompilationUnitMember):
augmentKeyword (getter: Token?, experimental)
constants (getter: NodeList<EnumConstantDeclaration>)
- declaredElement (getter: EnumElement?, deprecated)
declaredFragment (getter: EnumFragment?, experimental)
enumKeyword (getter: Token)
implementsClause (getter: ImplementsClause?)
@@ -772,7 +757,6 @@
typeParameters (getter: TypeParameterList?)
withClause (getter: WithClause?)
ExportDirective (class extends Object implements NamespaceDirective):
- element (getter: LibraryExportElement?, deprecated)
exportKeyword (getter: Token)
libraryExport (getter: LibraryExport?, experimental)
Expression (class extends Object implements CollectionElement):
@@ -780,7 +764,6 @@
inConstantContext (getter: bool)
isAssignable (getter: bool)
precedence (getter: Precedence)
- staticParameterElement (getter: ParameterElement?, deprecated)
staticType (getter: DartType?)
unParenthesized (getter: Expression)
ExpressionFunctionBody (class extends Object implements FunctionBody):
@@ -797,7 +780,6 @@
superclass (getter: NamedType)
ExtensionDeclaration (class extends Object implements CompilationUnitMember):
augmentKeyword (getter: Token?, experimental)
- declaredElement (getter: ExtensionElement?, deprecated)
declaredFragment (getter: ExtensionFragment?, experimental)
extensionKeyword (getter: Token)
leftBracket (getter: Token)
@@ -812,7 +794,6 @@
onKeyword (getter: Token)
ExtensionOverride (class extends Object implements Expression):
argumentList (getter: ArgumentList)
- element (getter: ExtensionElement, deprecated)
element2 (getter: ExtensionElement2, experimental)
extendedType (getter: DartType?)
importPrefix (getter: ImportPrefixReference?)
@@ -823,7 +804,6 @@
ExtensionTypeDeclaration (class extends Object implements NamedCompilationUnitMember, experimental):
augmentKeyword (getter: Token?, experimental)
constKeyword (getter: Token?)
- declaredElement (getter: ExtensionTypeElement?, deprecated)
declaredFragment (getter: ExtensionTypeFragment?, experimental)
extensionKeyword (getter: Token)
implementsClause (getter: ImplementsClause?)
@@ -891,7 +871,6 @@
rightParenthesis (getter: Token)
FormalParameter (class extends Object implements AstNode, sealed (immediate subtypes: DefaultFormalParameter, FormalParameterImpl, NormalFormalParameter)):
covariantKeyword (getter: Token?)
- declaredElement (getter: ParameterElement?, deprecated)
declaredFragment (getter: FormalParameterFragment?, experimental)
isConst (getter: bool)
isExplicitlyTyped (getter: bool)
@@ -910,7 +889,6 @@
FormalParameterList (class extends Object implements AstNode):
leftDelimiter (getter: Token?)
leftParenthesis (getter: Token)
- parameterElements (getter: List<ParameterElement?>, deprecated)
parameterFragments (getter: List<FormalParameterFragment?>, experimental)
parameters (getter: NodeList<FormalParameter>)
rightDelimiter (getter: Token?)
@@ -921,11 +899,9 @@
isSynchronous (getter: bool)
keyword (getter: Token?)
star (getter: Token?)
- isPotentiallyMutatedInScope (method: bool Function(VariableElement), deprecated)
isPotentiallyMutatedInScope2 (method: bool Function(VariableElement2), experimental)
FunctionDeclaration (class extends Object implements NamedCompilationUnitMember):
augmentKeyword (getter: Token?, experimental)
- declaredElement (getter: ExecutableElement?, deprecated)
declaredFragment (getter: ExecutableFragment?, experimental)
externalKeyword (getter: Token?)
functionExpression (getter: FunctionExpression)
@@ -937,20 +913,17 @@
functionDeclaration (getter: FunctionDeclaration)
FunctionExpression (class extends Object implements Expression):
body (getter: FunctionBody)
- declaredElement (getter: ExecutableElement?, deprecated)
declaredFragment (getter: ExecutableFragment?, experimental)
parameters (getter: FormalParameterList?)
typeParameters (getter: TypeParameterList?)
FunctionExpressionInvocation (class extends Object implements NullShortableExpression, InvocationExpression):
element (getter: ExecutableElement2?, experimental)
function (getter: Expression)
- staticElement (getter: ExecutableElement?, deprecated)
FunctionReference (class extends Object implements Expression, CommentReferableExpression):
function (getter: Expression)
typeArgumentTypes (getter: List<DartType>?)
typeArguments (getter: TypeArgumentList?)
FunctionTypeAlias (class extends Object implements TypeAlias):
- declaredElement (getter: TypeAliasElement?, deprecated)
declaredFragment (getter: TypeAliasFragment?, experimental)
parameters (getter: FormalParameterList)
returnType (getter: TypeAnnotation?)
@@ -981,7 +954,6 @@
isPrivateName (static method: bool Function(String))
element (getter: Element2?, experimental)
name (getter: String)
- staticElement (getter: Element?, deprecated)
IfElement (class extends Object implements CollectionElement):
caseClause (getter: CaseClause?)
elseElement (getter: CollectionElement?)
@@ -1005,18 +977,15 @@
interfaces (getter: NodeList<NamedType>)
ImplicitCallReference (class extends Object implements MethodReferenceExpression):
expression (getter: Expression)
- staticElement (getter: MethodElement, deprecated)
typeArgumentTypes (getter: List<DartType>)
typeArguments (getter: TypeArgumentList?)
ImportDirective (class extends Object implements NamespaceDirective):
asKeyword (getter: Token?)
deferredKeyword (getter: Token?)
- element (getter: LibraryImportElement?, deprecated)
importKeyword (getter: Token)
libraryImport (getter: LibraryImport?, experimental)
prefix (getter: SimpleIdentifier?)
ImportPrefixReference (class extends Object implements AstNode):
- element (getter: Element?, deprecated)
element2 (getter: Element2?, experimental)
name (getter: Token)
period (getter: Token)
@@ -1069,7 +1038,6 @@
labels (getter: NodeList<Label>)
statement (getter: Statement)
LibraryDirective (class extends Object implements Directive):
- element (getter: LibraryElement?, deprecated)
element2 (getter: LibraryElement2?, experimental)
libraryKeyword (getter: Token)
name2 (getter: LibraryIdentifier?)
@@ -1116,7 +1084,6 @@
MethodDeclaration (class extends Object implements ClassMember):
augmentKeyword (getter: Token?)
body (getter: FunctionBody)
- declaredElement (getter: ExecutableElement?, deprecated)
declaredFragment (getter: ExecutableFragment?, experimental)
externalKeyword (getter: Token?)
isAbstract (getter: bool)
@@ -1140,11 +1107,9 @@
target (getter: Expression?)
MethodReferenceExpression (class extends Object implements Expression):
element (getter: MethodElement2?, experimental)
- staticElement (getter: MethodElement?, deprecated)
MixinDeclaration (class extends Object implements NamedCompilationUnitMember):
augmentKeyword (getter: Token?)
baseKeyword (getter: Token?)
- declaredElement (getter: MixinElement?, deprecated)
declaredFragment (getter: MixinFragment?, experimental)
implementsClause (getter: ImplementsClause?)
leftBracket (getter: Token)
@@ -1159,12 +1124,10 @@
NamedCompilationUnitMember (class extends Object implements CompilationUnitMember):
name (getter: Token)
NamedExpression (class extends Object implements Expression):
- element (getter: ParameterElement?, deprecated)
element2 (getter: FormalParameterElement?, experimental)
expression (getter: Expression)
name (getter: Label)
NamedType (class extends Object implements TypeAnnotation):
- element (getter: Element?, deprecated)
element2 (getter: Element2?, experimental)
importPrefix (getter: ImportPrefixReference?)
isDeferred (getter: bool)
@@ -1223,7 +1186,6 @@
rightParenthesis (getter: Token)
PartDirective (class extends Object implements UriBasedDirective):
configurations (getter: NodeList<Configuration>)
- element (getter: PartElement?, deprecated)
partInclude (getter: PartInclude?, experimental)
partKeyword (getter: Token)
semicolon (getter: Token)
@@ -1239,7 +1201,6 @@
pattern (getter: DartPattern)
PatternField (class extends Object implements AstNode):
effectiveName (getter: String?)
- element (getter: Element?, deprecated)
element2 (getter: Element2?, experimental)
name (getter: PatternFieldName?)
pattern (getter: DartPattern)
@@ -1258,12 +1219,10 @@
element (getter: MethodElement2?)
operand (getter: Expression)
operator (getter: Token)
- staticElement (getter: MethodElement?, deprecated)
PrefixExpression (class extends Object implements Expression, NullShortableExpression, MethodReferenceExpression, CompoundAssignmentExpression):
element (getter: MethodElement2?)
operand (getter: Expression)
operator (getter: Token)
- staticElement (getter: MethodElement?, deprecated)
PrefixedIdentifier (class extends Object implements Identifier):
identifier (getter: SimpleIdentifier)
isDeferred (getter: bool)
@@ -1308,7 +1267,6 @@
period (getter: Token?)
thisKeyword (getter: Token)
RelationalPattern (class extends Object implements DartPattern):
- element (getter: MethodElement?, deprecated)
element2 (getter: MethodElement2?, experimental)
operand (getter: Expression)
operator (getter: Token)
@@ -1316,10 +1274,8 @@
name (getter: Token)
period (getter: Token)
RepresentationDeclaration (class extends Object implements AstNode, experimental):
- constructorElement (getter: ConstructorElement?, deprecated)
constructorFragment (getter: ConstructorFragment?, experimental)
constructorName (getter: RepresentationConstructorName?)
- fieldElement (getter: FieldElement?, deprecated)
fieldFragment (getter: FieldFragment?, experimental)
fieldMetadata (getter: NodeList<Annotation>)
fieldName (getter: Token)
@@ -1456,7 +1412,6 @@
type (getter: NamedType)
TypeParameter (class extends Object implements Declaration):
bound (getter: TypeAnnotation?)
- declaredElement (getter: TypeParameterElement?, deprecated)
declaredFragment (getter: TypeParameterFragment?, experimental)
extendsKeyword (getter: Token?)
name (getter: Token)
@@ -1471,7 +1426,6 @@
UriBasedDirective (class extends Object implements Directive, sealed (immediate subtypes: NamespaceDirective, PartDirective, UriBasedDirectiveImpl)):
uri (getter: StringLiteral)
VariableDeclaration (class extends Object implements Declaration):
- declaredElement (getter: VariableElement?, deprecated)
declaredElement2 (getter: LocalVariableElement2?, experimental)
declaredFragment (getter: VariableFragment?, experimental)
equals (getter: Token?)
@@ -1947,6 +1901,7 @@
visitDefaultFormalParameter (method: R? Function(DefaultFormalParameter))
visitDirective (method: R? Function(Directive))
visitDoStatement (method: R? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: R? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: R? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: R? Function(DotShorthandPropertyAccess))
visitDottedName (method: R? Function(DottedName))
@@ -2145,6 +2100,7 @@
visitDeclaredVariablePattern (method: R? Function(DeclaredVariablePattern))
visitDefaultFormalParameter (method: R? Function(DefaultFormalParameter))
visitDoStatement (method: R? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: R? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: R? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: R? Function(DotShorthandPropertyAccess))
visitDottedName (method: R? Function(DottedName))
@@ -2321,6 +2277,7 @@
visitDeclaredVariablePattern (method: R? Function(DeclaredVariablePattern))
visitDefaultFormalParameter (method: R? Function(DefaultFormalParameter))
visitDoStatement (method: R? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: R? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: R? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: R? Function(DotShorthandPropertyAccess))
visitDottedName (method: R? Function(DottedName))
@@ -2497,6 +2454,7 @@
visitDeclaredVariablePattern (method: R? Function(DeclaredVariablePattern))
visitDefaultFormalParameter (method: R? Function(DefaultFormalParameter))
visitDoStatement (method: R? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: R? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: R? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: R? Function(DotShorthandPropertyAccess))
visitDottedName (method: R? Function(DottedName))
@@ -2674,6 +2632,7 @@
visitDeclaredVariablePattern (method: T? Function(DeclaredVariablePattern))
visitDefaultFormalParameter (method: T? Function(DefaultFormalParameter))
visitDoStatement (method: T? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: T? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: T? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: T? Function(DotShorthandPropertyAccess))
visitDottedName (method: T? Function(DottedName))
@@ -2850,6 +2809,7 @@
visitDeclaredVariablePattern (method: R? Function(DeclaredVariablePattern))
visitDefaultFormalParameter (method: R? Function(DefaultFormalParameter))
visitDoStatement (method: R? Function(DoStatement))
+ visitDotShorthandConstructorInvocation (method: R? Function(DotShorthandConstructorInvocation))
visitDotShorthandInvocation (method: R? Function(DotShorthandInvocation))
visitDotShorthandPropertyAccess (method: R? Function(DotShorthandPropertyAccess))
visitDottedName (method: R? Function(DottedName))
@@ -3008,22 +2968,6 @@
toSymbolValue (method: String? Function())
toTypeValue (method: DartType? Function())
package:analyzer/dart/element/element.dart:
- AugmentedClassElement (class extends Object implements AugmentedInterfaceElement, deprecated):
- new (constructor: AugmentedClassElement Function())
- firstFragment (getter: ClassElement)
- AugmentedEnumElement (class extends Object implements AugmentedInterfaceElement, deprecated):
- new (constructor: AugmentedEnumElement Function())
- constants (getter: List<FieldElement>)
- firstFragment (getter: EnumElement)
- AugmentedExtensionElement (class extends Object implements AugmentedInstanceElement, deprecated):
- new (constructor: AugmentedExtensionElement Function())
- extendedType (getter: DartType)
- AugmentedExtensionTypeElement (class extends Object implements AugmentedInterfaceElement, deprecated):
- new (constructor: AugmentedExtensionTypeElement Function())
- firstFragment (getter: ExtensionTypeElement)
- primaryConstructor (getter: ConstructorElement)
- representation (getter: FieldElement)
- typeErasure (getter: DartType)
AugmentedInstanceElement (class extends Object, deprecated):
new (constructor: AugmentedInstanceElement Function())
accessors (getter: List<PropertyAccessorElement>)
@@ -3053,51 +2997,24 @@
superclassConstraints (getter: List<InterfaceType>)
BindPatternVariableElement (class extends Object implements PatternVariableElement, deprecated):
new (constructor: BindPatternVariableElement Function())
- ClassElement (class extends Object implements InterfaceElement, deprecated):
- new (constructor: ClassElement Function())
- augmented (getter: AugmentedClassElement, deprecated)
- hasNonFinalField (getter: bool)
- isAbstract (getter: bool)
- isBase (getter: bool)
- isConstructable (getter: bool)
- isDartCoreEnum (getter: bool)
- isDartCoreObject (getter: bool)
- isExhaustive (getter: bool)
- isFinal (getter: bool)
- isInterface (getter: bool)
- isMixinApplication (getter: bool)
- isMixinClass (getter: bool)
- isSealed (getter: bool)
- isValidMixin (getter: bool)
- isExtendableIn (method: bool Function(LibraryElement))
- isImplementableIn (method: bool Function(LibraryElement))
- isMixableIn (method: bool Function(LibraryElement))
ClassMemberElement (class extends Object implements Element, deprecated):
new (constructor: ClassMemberElement Function())
enclosingElement3 (getter: Element)
isStatic (getter: bool)
CompilationUnitElement (class extends Object implements UriReferencedElement, deprecated):
new (constructor: CompilationUnitElement Function())
- accessibleExtensions (getter: List<ExtensionElement>)
accessors (getter: List<PropertyAccessorElement>)
- classes (getter: List<ClassElement>)
enclosingElement3 (getter: CompilationUnitElement?)
- enums (getter: List<EnumElement>)
- extensionTypes (getter: List<ExtensionTypeElement>, experimental)
- extensions (getter: List<ExtensionElement>)
functions (getter: List<FunctionElement>)
libraryExports (getter: List<LibraryExportElement>)
libraryImportPrefixes (getter: List<PrefixElement>)
libraryImports (getter: List<LibraryImportElement>)
lineInfo (getter: LineInfo)
- mixins (getter: List<MixinElement>)
parts (getter: List<PartElement>)
scope (getter: Scope)
session (getter: AnalysisSession)
topLevelVariables (getter: List<TopLevelVariableElement>)
typeAliases (getter: List<TypeAliasElement>)
- getClass (method: ClassElement? Function(String))
- getEnum (method: EnumElement? Function(String))
ConstructorElement (class extends Object implements ClassMemberElement, ExecutableElement, ConstantEvaluationTarget, deprecated):
new (constructor: ConstructorElement Function())
declaration (getter: ConstructorElement)
@@ -3184,7 +3101,6 @@
session (getter: AnalysisSession?)
sinceSdkVersion (getter: Version?)
source (getter: Source?)
- accept (method: T? Function<T>(ElementVisitor<T>), deprecated)
getDisplayString (method: String Function({bool multiline, bool withNullability}))
getExtendedDisplayName (method: String Function(String?))
isAccessibleIn (method: bool Function(LibraryElement), deprecated)
@@ -3192,7 +3108,6 @@
thisOrAncestorMatching3 (method: E? Function<E extends Element>(bool Function(Element)), deprecated)
thisOrAncestorOfType (method: E? Function<E extends Element>(), deprecated)
thisOrAncestorOfType3 (method: E? Function<E extends Element>(), deprecated)
- visitChildren (method: void Function(ElementVisitor<dynamic>), deprecated)
ElementAnnotation (class extends Object implements ConstantEvaluationTarget):
new (constructor: ElementAnnotation Function())
constantEvaluationErrors (getter: List<AnalysisError>?)
@@ -3276,37 +3191,6 @@
new (constructor: ElementLocation Function())
components (getter: List<String>)
encoding (getter: String)
- ElementVisitor (class<R> extends Object, deprecated):
- new (constructor: ElementVisitor<R> Function())
- visitClassElement (method: R? Function(ClassElement))
- visitCompilationUnitElement (method: R? Function(CompilationUnitElement))
- visitConstructorElement (method: R? Function(ConstructorElement))
- visitEnumElement (method: R? Function(EnumElement))
- visitExtensionElement (method: R? Function(ExtensionElement))
- visitExtensionTypeElement (method: R? Function(ExtensionTypeElement))
- visitFieldElement (method: R? Function(FieldElement))
- visitFieldFormalParameterElement (method: R? Function(FieldFormalParameterElement))
- visitFunctionElement (method: R? Function(FunctionElement))
- visitGenericFunctionTypeElement (method: R? Function(GenericFunctionTypeElement))
- visitLabelElement (method: R? Function(LabelElement))
- visitLibraryElement (method: R? Function(LibraryElement))
- visitLibraryExportElement (method: R? Function(LibraryExportElement))
- visitLibraryImportElement (method: R? Function(LibraryImportElement))
- visitLocalVariableElement (method: R? Function(LocalVariableElement))
- visitMethodElement (method: R? Function(MethodElement))
- visitMixinElement (method: R? Function(MixinElement))
- visitMultiplyDefinedElement (method: R? Function(MultiplyDefinedElement))
- visitParameterElement (method: R? Function(ParameterElement))
- visitPartElement (method: R? Function(PartElement))
- visitPrefixElement (method: R? Function(PrefixElement))
- visitPropertyAccessorElement (method: R? Function(PropertyAccessorElement))
- visitSuperFormalParameterElement (method: R? Function(SuperFormalParameterElement))
- visitTopLevelVariableElement (method: R? Function(TopLevelVariableElement))
- visitTypeAliasElement (method: R? Function(TypeAliasElement))
- visitTypeParameterElement (method: R? Function(TypeParameterElement))
- EnumElement (class extends Object implements InterfaceElement, deprecated):
- new (constructor: EnumElement Function())
- augmented (getter: AugmentedEnumElement, deprecated)
ExecutableElement (class extends Object implements FunctionTypedElement, deprecated):
new (constructor: ExecutableElement Function())
declaration (getter: ExecutableElement)
@@ -3323,20 +3207,6 @@
isStatic (getter: bool)
isSynchronous (getter: bool)
name (getter: String)
- ExtensionElement (class extends Object implements InstanceElement, deprecated):
- new (constructor: ExtensionElement Function())
- augmented (getter: AugmentedExtensionElement, deprecated)
- extendedType (getter: DartType)
- getField (method: FieldElement? Function(String))
- getGetter (method: PropertyAccessorElement? Function(String))
- getMethod (method: MethodElement? Function(String))
- getSetter (method: PropertyAccessorElement? Function(String))
- ExtensionTypeElement (class extends Object implements InterfaceElement, deprecated):
- new (constructor: ExtensionTypeElement Function())
- augmented (getter: AugmentedExtensionTypeElement, deprecated)
- primaryConstructor (getter: ConstructorElement, deprecated)
- representation (getter: FieldElement)
- typeErasure (getter: DartType)
FieldElement (class extends Object implements ClassMemberElement, PropertyInducingElement, deprecated):
new (constructor: FieldElement Function())
declaration (getter: FieldElement)
@@ -3435,7 +3305,6 @@
typeProvider (getter: TypeProvider)
typeSystem (getter: TypeSystem)
units (getter: List<CompilationUnitElement>, deprecated)
- getClass (method: ClassElement? Function(String), deprecated)
LibraryExportElement (class extends Object implements _ExistingElement, deprecated):
new (constructor: LibraryExportElement Function())
combinators (getter: List<NamespaceCombinator>)
@@ -3466,12 +3335,6 @@
MethodElement (class extends Object implements ClassMemberElement, ExecutableElement, deprecated):
new (constructor: MethodElement Function())
declaration (getter: MethodElement)
- MixinElement (class extends Object implements InterfaceElement, deprecated):
- new (constructor: MixinElement Function())
- augmented (getter: AugmentedMixinElement, deprecated)
- isBase (getter: bool)
- superclassConstraints (getter: List<InterfaceType>)
- isImplementableIn (method: bool Function(LibraryElement))
MultiplyDefinedElement (class extends Object implements Element, deprecated):
new (constructor: MultiplyDefinedElement Function())
conflictingElements (getter: List<Element>)
@@ -4478,69 +4341,51 @@
package:analyzer/dart/element/type_provider.dart:
TypeProvider (class extends Object):
new (constructor: TypeProvider Function())
- boolElement (getter: ClassElement, deprecated)
boolElement2 (getter: ClassElement2, experimental)
boolType (getter: InterfaceType)
bottomType (getter: DartType)
deprecatedType (getter: InterfaceType)
- doubleElement (getter: ClassElement, deprecated)
doubleElement2 (getter: ClassElement2, experimental)
doubleType (getter: InterfaceType)
dynamicType (getter: DartType)
- enumElement (getter: ClassElement?, deprecated)
enumElement2 (getter: ClassElement2?, experimental)
enumType (getter: InterfaceType?)
functionType (getter: InterfaceType)
futureDynamicType (getter: InterfaceType)
- futureElement (getter: ClassElement, deprecated)
futureElement2 (getter: ClassElement2, experimental)
futureNullType (getter: InterfaceType)
- futureOrElement (getter: ClassElement, deprecated)
futureOrElement2 (getter: ClassElement2, experimental)
futureOrNullType (getter: InterfaceType)
- intElement (getter: ClassElement, deprecated)
intElement2 (getter: ClassElement2, experimental)
intType (getter: InterfaceType)
iterableDynamicType (getter: InterfaceType)
- iterableElement (getter: ClassElement, deprecated)
iterableElement2 (getter: ClassElement2, experimental)
iterableObjectType (getter: InterfaceType)
- listElement (getter: ClassElement, deprecated)
listElement2 (getter: ClassElement2, experimental)
- mapElement (getter: ClassElement, deprecated)
mapElement2 (getter: ClassElement2, experimental)
mapObjectObjectType (getter: InterfaceType)
neverType (getter: NeverType)
- nullElement (getter: ClassElement, deprecated)
nullElement2 (getter: ClassElement2, experimental)
nullType (getter: InterfaceType)
- numElement (getter: ClassElement, deprecated)
numElement2 (getter: ClassElement2, experimental)
numType (getter: InterfaceType)
- objectElement (getter: ClassElement, deprecated)
objectElement2 (getter: ClassElement2, experimental)
objectQuestionType (getter: InterfaceType)
objectType (getter: InterfaceType)
- recordElement (getter: ClassElement, deprecated)
recordElement2 (getter: ClassElement2, experimental)
recordType (getter: InterfaceType)
- setElement (getter: ClassElement, deprecated)
setElement2 (getter: ClassElement2, experimental)
stackTraceType (getter: InterfaceType)
streamDynamicType (getter: InterfaceType)
- streamElement (getter: ClassElement, deprecated)
streamElement2 (getter: ClassElement2, experimental)
- stringElement (getter: ClassElement, deprecated)
stringElement2 (getter: ClassElement2, experimental)
stringType (getter: InterfaceType)
- symbolElement (getter: ClassElement, deprecated)
symbolElement2 (getter: ClassElement2, experimental)
symbolType (getter: InterfaceType)
typeType (getter: InterfaceType)
voidType (getter: VoidType)
futureOrType (method: InterfaceType Function(DartType))
futureType (method: InterfaceType Function(DartType))
- isNonSubtypableClass (method: bool Function(InterfaceElement), deprecated)
isNonSubtypableClass2 (method: bool Function(InterfaceElement2))
isObjectGetter (method: bool Function(String))
isObjectMember (method: bool Function(String))
@@ -4612,124 +4457,6 @@
visitRecordType (method: R Function(RecordType, A))
visitTypeParameterType (method: R Function(TypeParameterType, A))
visitVoidType (method: R Function(VoidType, A))
-package:analyzer/dart/element/visitor.dart:
- GeneralizingElementVisitor (class<R> extends Object implements ElementVisitor<R>, deprecated):
- new (constructor: GeneralizingElementVisitor<R> Function())
- visitClassElement (method: R? Function(ClassElement))
- visitCompilationUnitElement (method: R? Function(CompilationUnitElement))
- visitConstructorElement (method: R? Function(ConstructorElement))
- visitElement (method: R? Function(Element))
- visitEnumElement (method: R? Function(EnumElement))
- visitExecutableElement (method: R? Function(ExecutableElement))
- visitExtensionElement (method: R? Function(ExtensionElement))
- visitExtensionTypeElement (method: R? Function(ExtensionTypeElement))
- visitFieldElement (method: R? Function(FieldElement))
- visitFieldFormalParameterElement (method: R? Function(FieldFormalParameterElement))
- visitFunctionElement (method: R? Function(FunctionElement))
- visitGenericFunctionTypeElement (method: R? Function(GenericFunctionTypeElement))
- visitLabelElement (method: R? Function(LabelElement))
- visitLibraryElement (method: R? Function(LibraryElement))
- visitLibraryExportElement (method: R? Function(LibraryExportElement))
- visitLibraryImportElement (method: R? Function(LibraryImportElement))
- visitLocalElement (method: R? Function(LocalElement))
- visitLocalVariableElement (method: R? Function(LocalVariableElement))
- visitMethodElement (method: R? Function(MethodElement))
- visitMixinElement (method: R? Function(MixinElement))
- visitMultiplyDefinedElement (method: R? Function(MultiplyDefinedElement))
- visitParameterElement (method: R? Function(ParameterElement))
- visitPartElement (method: R? Function(PartElement))
- visitPrefixElement (method: R? Function(PrefixElement))
- visitPropertyAccessorElement (method: R? Function(PropertyAccessorElement))
- visitPropertyInducingElement (method: R? Function(PropertyInducingElement))
- visitSuperFormalParameterElement (method: R? Function(SuperFormalParameterElement))
- visitTopLevelVariableElement (method: R? Function(TopLevelVariableElement))
- visitTypeAliasElement (method: R? Function(TypeAliasElement))
- visitTypeParameterElement (method: R? Function(TypeParameterElement))
- visitVariableElement (method: R? Function(VariableElement))
- RecursiveElementVisitor (class<R> extends Object implements ElementVisitor<R>, deprecated):
- new (constructor: RecursiveElementVisitor<R> Function())
- visitClassElement (method: R? Function(ClassElement))
- visitCompilationUnitElement (method: R? Function(CompilationUnitElement))
- visitConstructorElement (method: R? Function(ConstructorElement))
- visitEnumElement (method: R? Function(EnumElement))
- visitExtensionElement (method: R? Function(ExtensionElement))
- visitExtensionTypeElement (method: R? Function(ExtensionTypeElement))
- visitFieldElement (method: R? Function(FieldElement))
- visitFieldFormalParameterElement (method: R? Function(FieldFormalParameterElement))
- visitFunctionElement (method: R? Function(FunctionElement))
- visitGenericFunctionTypeElement (method: R? Function(GenericFunctionTypeElement))
- visitLabelElement (method: R? Function(LabelElement))
- visitLibraryElement (method: R? Function(LibraryElement))
- visitLibraryExportElement (method: R? Function(LibraryExportElement))
- visitLibraryImportElement (method: R? Function(LibraryImportElement))
- visitLocalVariableElement (method: R? Function(LocalVariableElement))
- visitMethodElement (method: R? Function(MethodElement))
- visitMixinElement (method: R? Function(MixinElement))
- visitMultiplyDefinedElement (method: R? Function(MultiplyDefinedElement))
- visitParameterElement (method: R? Function(ParameterElement))
- visitPartElement (method: R? Function(PartElement))
- visitPrefixElement (method: R? Function(PrefixElement))
- visitPropertyAccessorElement (method: R? Function(PropertyAccessorElement))
- visitSuperFormalParameterElement (method: R? Function(SuperFormalParameterElement))
- visitTopLevelVariableElement (method: R? Function(TopLevelVariableElement))
- visitTypeAliasElement (method: R? Function(TypeAliasElement))
- visitTypeParameterElement (method: R? Function(TypeParameterElement))
- SimpleElementVisitor (class<R> extends Object implements ElementVisitor<R>, deprecated):
- new (constructor: SimpleElementVisitor<R> Function())
- visitClassElement (method: R? Function(ClassElement))
- visitCompilationUnitElement (method: R? Function(CompilationUnitElement))
- visitConstructorElement (method: R? Function(ConstructorElement))
- visitEnumElement (method: R? Function(EnumElement))
- visitExtensionElement (method: R? Function(ExtensionElement))
- visitExtensionTypeElement (method: R? Function(ExtensionTypeElement))
- visitFieldElement (method: R? Function(FieldElement))
- visitFieldFormalParameterElement (method: R? Function(FieldFormalParameterElement))
- visitFunctionElement (method: R? Function(FunctionElement))
- visitGenericFunctionTypeElement (method: R? Function(GenericFunctionTypeElement))
- visitLabelElement (method: R? Function(LabelElement))
- visitLibraryElement (method: R? Function(LibraryElement))
- visitLibraryExportElement (method: R? Function(LibraryExportElement))
- visitLibraryImportElement (method: R? Function(LibraryImportElement))
- visitLocalVariableElement (method: R? Function(LocalVariableElement))
- visitMethodElement (method: R? Function(MethodElement))
- visitMixinElement (method: R? Function(MixinElement))
- visitMultiplyDefinedElement (method: R? Function(MultiplyDefinedElement))
- visitParameterElement (method: R? Function(ParameterElement))
- visitPartElement (method: R? Function(PartElement))
- visitPrefixElement (method: R? Function(PrefixElement))
- visitPropertyAccessorElement (method: R? Function(PropertyAccessorElement))
- visitSuperFormalParameterElement (method: R? Function(SuperFormalParameterElement))
- visitTopLevelVariableElement (method: R? Function(TopLevelVariableElement))
- visitTypeAliasElement (method: R? Function(TypeAliasElement))
- visitTypeParameterElement (method: R? Function(TypeParameterElement))
- ThrowingElementVisitor (class<R> extends Object implements ElementVisitor<R>, deprecated):
- new (constructor: ThrowingElementVisitor<R> Function())
- visitClassElement (method: R? Function(ClassElement))
- visitCompilationUnitElement (method: R? Function(CompilationUnitElement))
- visitConstructorElement (method: R? Function(ConstructorElement))
- visitEnumElement (method: R? Function(EnumElement))
- visitExtensionElement (method: R? Function(ExtensionElement))
- visitExtensionTypeElement (method: R? Function(ExtensionTypeElement))
- visitFieldElement (method: R? Function(FieldElement))
- visitFieldFormalParameterElement (method: R? Function(FieldFormalParameterElement))
- visitFunctionElement (method: R? Function(FunctionElement))
- visitGenericFunctionTypeElement (method: R? Function(GenericFunctionTypeElement))
- visitLabelElement (method: R? Function(LabelElement))
- visitLibraryElement (method: R? Function(LibraryElement))
- visitLibraryExportElement (method: R? Function(LibraryExportElement))
- visitLibraryImportElement (method: R? Function(LibraryImportElement))
- visitLocalVariableElement (method: R? Function(LocalVariableElement))
- visitMethodElement (method: R? Function(MethodElement))
- visitMixinElement (method: R? Function(MixinElement))
- visitMultiplyDefinedElement (method: R? Function(MultiplyDefinedElement))
- visitParameterElement (method: R? Function(ParameterElement))
- visitPartElement (method: R? Function(PartElement))
- visitPrefixElement (method: R? Function(PrefixElement))
- visitPropertyAccessorElement (method: R? Function(PropertyAccessorElement))
- visitSuperFormalParameterElement (method: R? Function(SuperFormalParameterElement))
- visitTopLevelVariableElement (method: R? Function(TopLevelVariableElement))
- visitTypeAliasElement (method: R? Function(TypeAliasElement))
- visitTypeParameterElement (method: R? Function(TypeParameterElement))
package:analyzer/dart/element/visitor2.dart:
GeneralizingElementVisitor2 (class<R> extends Object implements ElementVisitor2<R>):
new (constructor: GeneralizingElementVisitor2<R> Function())
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 4023f85..d888772 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -93,6 +93,7 @@
Directive,
DoStatement,
DotShorthandInvocation,
+ DotShorthandConstructorInvocation,
DotShorthandPropertyAccess,
DottedName,
DoubleLiteral,
diff --git a/pkg/analyzer/lib/dart/ast/visitor.dart b/pkg/analyzer/lib/dart/ast/visitor.dart
index 72bf01e..c2beaff 100644
--- a/pkg/analyzer/lib/dart/ast/visitor.dart
+++ b/pkg/analyzer/lib/dart/ast/visitor.dart
@@ -280,6 +280,11 @@
R? visitDoStatement(DoStatement node) => visitStatement(node);
@override
+ R? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) =>
+ visitExpression(node);
+
+ @override
R? visitDotShorthandInvocation(DotShorthandInvocation node) =>
visitExpression(node);
@@ -1044,6 +1049,13 @@
}
@override
+ R? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) {
+ node.visitChildren(this);
+ return null;
+ }
+
+ @override
R? visitDotShorthandInvocation(DotShorthandInvocation node) {
node.visitChildren(this);
return null;
@@ -1986,6 +1998,11 @@
R? visitDoStatement(DoStatement node) => null;
@override
+ R? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) =>
+ null;
+
+ @override
R? visitDotShorthandInvocation(DotShorthandInvocation node) => null;
@override
@@ -2535,6 +2552,11 @@
R? visitDoStatement(DoStatement node) => _throw(node);
@override
+ R? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) =>
+ _throw(node);
+
+ @override
R? visitDotShorthandInvocation(DotShorthandInvocation node) => _throw(node);
@override
@@ -3300,6 +3322,15 @@
}
@override
+ T? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) {
+ stopwatch.start();
+ T? result = _baseVisitor.visitDotShorthandConstructorInvocation(node);
+ stopwatch.stop();
+ return result;
+ }
+
+ @override
T? visitDotShorthandInvocation(DotShorthandInvocation node) {
stopwatch.start();
T? result = _baseVisitor.visitDotShorthandInvocation(node);
@@ -4522,6 +4553,11 @@
R? visitDoStatement(DoStatement node) => visitNode(node);
@override
+ R? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) =>
+ visitNode(node);
+
+ @override
R? visitDotShorthandInvocation(DotShorthandInvocation node) =>
visitNode(node);
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 58321de..03f3ad6 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -60,57 +60,6 @@
import 'package:meta/meta.dart';
import 'package:pub_semver/pub_semver.dart';
-/// The result of applying augmentations to a [ClassElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated(elementModelDeprecationMsg)
-abstract class AugmentedClassElement implements AugmentedInterfaceElement {
- @override
- ClassElement get firstFragment;
-}
-
-/// The result of applying augmentations to an [EnumElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated(elementModelDeprecationMsg)
-abstract class AugmentedEnumElement implements AugmentedInterfaceElement {
- /// The enum constants declared in this element.
- List<FieldElement> get constants;
-
- @override
- EnumElement get firstFragment;
-}
-
-/// The result of applying augmentations to an [ExtensionElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated(elementModelDeprecationMsg)
-abstract class AugmentedExtensionElement implements AugmentedInstanceElement {
- /// The type that is extended by this extension.
- DartType get extendedType;
-}
-
-/// The result of applying augmentations to an [ExtensionTypeElement].
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated(elementModelDeprecationMsg)
-abstract class AugmentedExtensionTypeElement
- implements AugmentedInterfaceElement {
- @override
- ExtensionTypeElement get firstFragment;
-
- /// The primary constructor of this extension.
- ConstructorElement get primaryConstructor;
-
- /// The representation of this extension.
- FieldElement get representation;
-
- /// The extension type erasure, obtained by recursively replacing every
- /// subterm which is an extension type by the corresponding representation
- /// type.
- DartType get typeErasure;
-}
-
/// The result of applying augmentations to a [InstanceElement].
///
/// Clients may not extend, implement or mix-in this class.
@@ -247,105 +196,6 @@
'Use BindPatternVariableFragment and BindPatternVariableElement2 instead')
abstract class BindPatternVariableElement implements PatternVariableElement {}
-/// An element that represents a class or a mixin. The class can be defined by
-/// either a class declaration (with a class body), a mixin application (without
-/// a class body), a mixin declaration, or an enum declaration.
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated('Use ClassElement2 instead')
-abstract class ClassElement implements InterfaceElement {
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedClassElement get augmented;
-
- /// Whether the class or its superclass declares a non-final instance field.
- bool get hasNonFinalField;
-
- /// Whether the class is abstract. A class is abstract if it has an
- /// explicit `abstract` modifier. Note, that this definition of
- /// <i>abstract</i> is different from <i>has unimplemented members</i>.
- bool get isAbstract;
-
- /// Whether this class is a base class.
- ///
- /// A class is a base class if it has an explicit `base` modifier, or the
- /// class has a `base` induced modifier and [isSealed] is `true` as well.
- /// The base modifier allows the class to be extended but not implemented.
- bool get isBase;
-
- /// Whether the class can be instantiated.
- bool get isConstructable;
-
- /// Whether the class represents the class 'Enum' defined in `dart:core`.
- bool get isDartCoreEnum;
-
- /// Whether the class represents the class 'Object' defined in `dart:core`.
- bool get isDartCoreObject;
-
- /// Whether the class has the property where, in a switch, if you cover all
- /// of the subtypes of this element, then the compiler knows that you have
- /// covered all possible instances of the type.
- bool get isExhaustive;
-
- /// Whether the class is a final class.
- ///
- /// A class is a final class if it has an explicit `final` modifier, or the
- /// class has a `final` induced modifier and [isSealed] is `true` as well.
- /// The final modifier prohibits this class from being extended, implemented,
- /// or mixed in.
- bool get isFinal;
-
- /// Whether the class is an interface class.
- ///
- /// A class is an interface class if it has an explicit `interface` modifier,
- /// or the class has an `interface` induced modifier and [isSealed] is `true`
- /// as well. The interface modifier allows the class to be implemented, but
- /// not extended or mixed in.
- bool get isInterface;
-
- /// Whether the class is a mixin application.
- ///
- /// A class is a mixin application if it was declared using the syntax
- /// `class A = B with C;`.
- bool get isMixinApplication;
-
- /// Whether the class is a mixin class.
- ///
- /// A class is a mixin class if it has an explicit `mixin` modifier.
- bool get isMixinClass;
-
- /// Whether the class is a sealed class.
- ///
- /// A class is a sealed class if it has an explicit `sealed` modifier.
- bool get isSealed;
-
- /// Whether the class can validly be used as a mixin when defining
- /// another class.
- ///
- /// For classes defined by a class declaration or a mixin application, the
- /// behavior of this method is defined by the Dart Language Specification
- /// in section 9:
- /// <blockquote>
- /// It is a compile-time error if a declared or derived mixin refers to super.
- /// It is a compile-time error if a declared or derived mixin explicitly
- /// declares a constructor. It is a compile-time error if a mixin is derived
- /// from a class whose superclass is not Object.
- /// </blockquote>
- bool get isValidMixin;
-
- /// Whether the class, assuming that it is within scope, is extendable to
- /// classes in the given [library].
- bool isExtendableIn(LibraryElement library);
-
- /// Whether the class, assuming that it is within scope, is
- /// implementable to classes, mixins, and enums in the given [library].
- bool isImplementableIn(LibraryElement library);
-
- /// Whether the class, assuming that it is within scope, is able to be
- /// mixed-in by classes and enums in the given [library].
- bool isMixableIn(LibraryElement library);
-}
-
/// An element that is contained within a [ClassElement].
///
/// Clients may not extend, implement or mix-in this class.
@@ -375,31 +225,15 @@
/// Clients may not extend, implement or mix-in this class.
@Deprecated(elementModelDeprecationMsg)
abstract class CompilationUnitElement implements UriReferencedElement {
- /// The extension elements accessible within this unit.
- List<ExtensionElement> get accessibleExtensions;
-
/// The top-level accessors (getters and setters) declared in this
/// compilation unit.
List<PropertyAccessorElement> get accessors;
- /// The classes declared in this compilation unit.
- List<ClassElement> get classes;
-
/// The [CompilationUnitElement] that uses `part` directive to include this
/// element, or `null` if this element is the defining unit of the library.
@override
CompilationUnitElement? get enclosingElement3;
- /// The enums declared in this compilation unit.
- List<EnumElement> get enums;
-
- /// The extensions declared in this compilation unit.
- List<ExtensionElement> get extensions;
-
- /// The extension types declared in this compilation unit.
- @experimental
- List<ExtensionTypeElement> get extensionTypes;
-
/// The top-level functions declared in this compilation unit.
List<FunctionElement> get functions;
@@ -417,9 +251,6 @@
/// The [LineInfo] for the [source].
LineInfo get lineInfo;
- /// The mixins declared in this compilation unit.
- List<MixinElement> get mixins;
-
/// The parts included by this unit.
List<PartElement> get parts;
@@ -437,16 +268,6 @@
/// The type aliases declared in this compilation unit.
List<TypeAliasElement> get typeAliases;
-
- /// Returns the class defined in this compilation unit that has the given
- /// [name], or `null` if this compilation unit does not define a class with
- /// the given name.
- ClassElement? getClass(String name);
-
- /// Returns the enum defined in this compilation unit that has the given
- /// [name], or `null` if this compilation unit does not define an enum with
- /// the given name.
- EnumElement? getEnum(String name);
}
/// An element representing a constructor or a factory method defined within a
@@ -807,13 +628,6 @@
@override
Source? get source;
- /// Uses the given [visitor] to visit this element.
- ///
- /// Returns the value returned by the visitor as a result of visiting this
- /// element.
- @Deprecated('Use Element2 and accept2() instead')
- T? accept<T>(ElementVisitor<T> visitor);
-
/// Returns the presentation of this element as it should appear when
/// presented to users.
///
@@ -879,11 +693,6 @@
/// that has the given type, or `null` if there is no such element.
@Deprecated('Use Element2.thisOrAncestorMatching2() instead')
E? thisOrAncestorOfType3<E extends Element>();
-
- /// Uses the given [visitor] to visit all of the children of this element.
- /// There is no guarantee of the order in which the children will be visited.
- @Deprecated('Use Element2 and visitChildren2() instead')
- void visitChildren(ElementVisitor visitor);
}
/// A single annotation associated with an element.
@@ -1193,82 +1002,6 @@
String get encoding;
}
-/// An object that can be used to visit an element structure.
-///
-/// Clients may not extend, implement or mix-in this class. There are classes
-/// that implement this interface that provide useful default behaviors in
-/// `package:analyzer/dart/element/visitor.dart`. A couple of the most useful
-/// include
-/// * SimpleElementVisitor which implements every visit method by doing nothing,
-/// * RecursiveElementVisitor which will cause every node in a structure to be
-/// visited, and
-/// * ThrowingElementVisitor which implements every visit method by throwing an
-/// exception.
-@Deprecated('Use ElementVisitor2 instead')
-abstract class ElementVisitor<R> {
- R? visitClassElement(ClassElement element);
-
- R? visitCompilationUnitElement(CompilationUnitElement element);
-
- R? visitConstructorElement(ConstructorElement element);
-
- R? visitEnumElement(EnumElement element);
-
- R? visitExtensionElement(ExtensionElement element);
-
- R? visitExtensionTypeElement(ExtensionTypeElement element);
-
- R? visitFieldElement(FieldElement element);
-
- R? visitFieldFormalParameterElement(FieldFormalParameterElement element);
-
- R? visitFunctionElement(FunctionElement element);
-
- R? visitGenericFunctionTypeElement(GenericFunctionTypeElement element);
-
- R? visitLabelElement(LabelElement element);
-
- R? visitLibraryElement(LibraryElement element);
-
- R? visitLibraryExportElement(LibraryExportElement element);
-
- R? visitLibraryImportElement(LibraryImportElement element);
-
- R? visitLocalVariableElement(LocalVariableElement element);
-
- R? visitMethodElement(MethodElement element);
-
- R? visitMixinElement(MixinElement element);
-
- R? visitMultiplyDefinedElement(MultiplyDefinedElement element);
-
- R? visitParameterElement(ParameterElement element);
-
- R? visitPartElement(PartElement element);
-
- R? visitPrefixElement(PrefixElement element);
-
- R? visitPropertyAccessorElement(PropertyAccessorElement element);
-
- R? visitSuperFormalParameterElement(SuperFormalParameterElement element);
-
- R? visitTopLevelVariableElement(TopLevelVariableElement element);
-
- R? visitTypeAliasElement(TypeAliasElement element);
-
- R? visitTypeParameterElement(TypeParameterElement element);
-}
-
-/// An element that represents an enum.
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated('Use EnumElement2 instead')
-abstract class EnumElement implements InterfaceElement {
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedEnumElement get augmented;
-}
-
/// An element representing an executable object, including functions, methods,
/// constructors, getters, and setters.
///
@@ -1333,61 +1066,6 @@
String get name;
}
-/// An element that represents an extension.
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated('Use ExtensionElement2 instead')
-abstract class ExtensionElement implements InstanceElement {
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedExtensionElement get augmented;
-
- /// The type that is extended by this extension.
- DartType get extendedType;
-
- /// Returns the element representing the field with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// field with the given name.
- FieldElement? getField(String name);
-
- /// Returns the element representing the getter with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// getter with the given name.
- PropertyAccessorElement? getGetter(String name);
-
- /// Returns the element representing the method with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// method with the given name.
- MethodElement? getMethod(String name);
-
- /// Returns the element representing the setter with the given [name] that is
- /// declared in this extension, or `null` if this extension does not declare a
- /// setter with the given name.
- PropertyAccessorElement? getSetter(String name);
-}
-
-/// An element that represents an extension type.
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated('Use ExtensionTypeElement2 instead')
-abstract class ExtensionTypeElement implements InterfaceElement {
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedExtensionTypeElement get augmented;
-
- /// The primary constructor of this extension.
- @Deprecated(elementModelDeprecationMsg)
- ConstructorElement get primaryConstructor;
-
- /// The representation of this extension.
- FieldElement get representation;
-
- /// The extension type erasure, obtained by recursively replacing every
- /// subterm which is an extension type by the corresponding representation
- /// type.
- DartType get typeErasure;
-}
-
/// A field defined within a class.
///
/// Clients may not extend, implement or mix-in this class.
@@ -1933,11 +1611,6 @@
/// `part` directive.
@Deprecated(elementModelDeprecationMsg)
List<CompilationUnitElement> get units;
-
- /// The class defined in this library that has the given [name], or
- /// `null` if this library does not define a class with the given name.
- @Deprecated(elementModelDeprecationMsg)
- ClassElement? getClass(String name);
}
/// A single export directive within a library.
@@ -2040,38 +1713,6 @@
MethodElement get declaration;
}
-/// An element that represents a mixin.
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated('Use MixinElement2 instead')
-abstract class MixinElement implements InterfaceElement {
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedMixinElement get augmented;
-
- /// Whether the mixin is a base mixin.
- ///
- /// A mixin is a base mixin if it has an explicit `base` modifier.
- /// The base modifier allows a mixin to be mixed in, but not implemented.
- bool get isBase;
-
- /// The superclass constraints defined for this mixin.
- ///
- /// If the declaration does not have an `on` clause, then the list will
- /// contain the type for the class `Object`.
- ///
- /// <b>Note:</b> Because the element model represents the state of the code,
- /// it is possible for it to be semantically invalid. In particular, it is not
- /// safe to assume that the inheritance structure of a class does not contain
- /// a cycle. Clients that traverse the inheritance structure must explicitly
- /// guard against infinite loops.
- List<InterfaceType> get superclassConstraints;
-
- /// Whether the element, assuming that it is within scope, is
- /// implementable to classes, mixins, and enums in the given [library].
- bool isImplementableIn(LibraryElement library);
-}
-
/// A pseudo-element that represents multiple elements defined within a single
/// scope that have the same name. This situation is not allowed by the
/// language, so objects implementing this interface always represent an error.
diff --git a/pkg/analyzer/lib/dart/element/type_provider.dart b/pkg/analyzer/lib/dart/element/type_provider.dart
index 1b9b852..43f230541 100644
--- a/pkg/analyzer/lib/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/dart/element/type_provider.dart
@@ -2,7 +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/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:meta/meta.dart';
@@ -13,10 +12,6 @@
/// Clients may not extend, implement or mix-in this class.
abstract class TypeProvider {
/// Return the element representing the built-in class `bool`.
- @Deprecated('Use boolElement2 instead')
- ClassElement get boolElement;
-
- /// Return the element representing the built-in class `bool`.
@experimental
ClassElement2 get boolElement2;
@@ -30,10 +25,6 @@
InterfaceType get deprecatedType;
/// Return the element representing the built-in class `double`.
- @Deprecated('Use doubleElement2 instead')
- ClassElement get doubleElement;
-
- /// Return the element representing the built-in class `double`.
@experimental
ClassElement2 get doubleElement2;
@@ -45,11 +36,6 @@
/// Return the element representing the built-in type `Enum`, or `null` if
/// the SDK does not have definition of `Enum`.
- @Deprecated('Use enumElement2 instead')
- ClassElement? get enumElement;
-
- /// Return the element representing the built-in type `Enum`, or `null` if
- /// the SDK does not have definition of `Enum`.
@experimental
ClassElement2? get enumElement2;
@@ -64,10 +50,6 @@
InterfaceType get futureDynamicType;
/// Return the element representing the built-in class `Future`.
- @Deprecated('Use futureElement2 instead')
- ClassElement get futureElement;
-
- /// Return the element representing the built-in class `Future`.
@experimental
ClassElement2 get futureElement2;
@@ -75,10 +57,6 @@
InterfaceType get futureNullType;
/// Return the element representing the built-in class `FutureOr`.
- @Deprecated('Use futureOrElement2 instead')
- ClassElement get futureOrElement;
-
- /// Return the element representing the built-in class `FutureOr`.
@experimental
ClassElement2 get futureOrElement2;
@@ -86,10 +64,6 @@
InterfaceType get futureOrNullType;
/// Return the element representing the built-in class `int`.
- @Deprecated('Use intElement2 instead')
- ClassElement get intElement;
-
- /// Return the element representing the built-in class `int`.
@experimental
ClassElement2 get intElement2;
@@ -100,10 +74,6 @@
InterfaceType get iterableDynamicType;
/// Return the element representing the built-in class `Iterable`.
- @Deprecated('Use iterableElement2 instead')
- ClassElement get iterableElement;
-
- /// Return the element representing the built-in class `Iterable`.
@experimental
ClassElement2 get iterableElement2;
@@ -111,18 +81,10 @@
InterfaceType get iterableObjectType;
/// Return the element representing the built-in class `List`.
- @Deprecated('Use listElement2 instead')
- ClassElement get listElement;
-
- /// Return the element representing the built-in class `List`.
@experimental
ClassElement2 get listElement2;
/// Return the element representing the built-in class `Map`.
- @Deprecated('Use mapElement2 instead')
- ClassElement get mapElement;
-
- /// Return the element representing the built-in class `Map`.
@experimental
ClassElement2 get mapElement2;
@@ -133,10 +95,6 @@
NeverType get neverType;
/// Return the element representing the built-in class `Null`.
- @Deprecated('Use nullElement2 instead')
- ClassElement get nullElement;
-
- /// Return the element representing the built-in class `Null`.
@experimental
ClassElement2 get nullElement2;
@@ -144,10 +102,6 @@
InterfaceType get nullType;
/// Return the element representing the built-in class `num`.
- @Deprecated('Use numElement2 instead')
- ClassElement get numElement;
-
- /// Return the element representing the built-in class `num`.
@experimental
ClassElement2 get numElement2;
@@ -155,10 +109,6 @@
InterfaceType get numType;
/// Return the element representing the built-in class `Object`.
- @Deprecated('Use objectElement2 instead')
- ClassElement get objectElement;
-
- /// Return the element representing the built-in class `Object`.
@experimental
ClassElement2 get objectElement2;
@@ -169,10 +119,6 @@
InterfaceType get objectType;
/// Return the element representing the built-in class `Record`.
- @Deprecated('Use recordElement2 instead')
- ClassElement get recordElement;
-
- /// Return the element representing the built-in class `Record`.
@experimental
ClassElement2 get recordElement2;
@@ -180,10 +126,6 @@
InterfaceType get recordType;
/// Return the element representing the built-in class `Set`.
- @Deprecated('Use setElement2 instead')
- ClassElement get setElement;
-
- /// Return the element representing the built-in class `Set`.
@experimental
ClassElement2 get setElement2;
@@ -194,18 +136,10 @@
InterfaceType get streamDynamicType;
/// Return the element representing the built-in class `Stream`.
- @Deprecated('Use streamElement2 instead')
- ClassElement get streamElement;
-
- /// Return the element representing the built-in class `Stream`.
@experimental
ClassElement2 get streamElement2;
/// Return the element representing the built-in class `String`.
- @Deprecated('Use stringElement2 instead')
- ClassElement get stringElement;
-
- /// Return the element representing the built-in class `String`.
@experimental
ClassElement2 get stringElement2;
@@ -213,10 +147,6 @@
InterfaceType get stringType;
/// Return the element representing the built-in class `Symbol`.
- @Deprecated('Use symbolElement2 instead')
- ClassElement get symbolElement;
-
- /// Return the element representing the built-in class `Symbol`.
@experimental
ClassElement2 get symbolElement2;
@@ -238,10 +168,6 @@
InterfaceType futureType(DartType valueType);
/// Return `true` if [element] cannot be extended, implemented, or mixed in.
- @Deprecated('Use isNonSubtypableClass2() instead')
- bool isNonSubtypableClass(InterfaceElement element);
-
- /// Return `true` if [element] cannot be extended, implemented, or mixed in.
bool isNonSubtypableClass2(InterfaceElement2 element);
/// Return 'true' if [id] is the name of a getter on the `Object` type.
diff --git a/pkg/analyzer/lib/dart/element/visitor.dart b/pkg/analyzer/lib/dart/element/visitor.dart
deleted file mode 100644
index 2aef934..0000000
--- a/pkg/analyzer/lib/dart/element/visitor.dart
+++ /dev/null
@@ -1,573 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// 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.
-
-/// Defines element visitors that support useful patterns for visiting the
-/// elements in an [element model](element.dart).
-///
-/// Dart is an evolving language, and the element model must evolved with it.
-/// When the element model changes, the visitor interface will sometimes change
-/// as well. If it is desirable to get a compilation error when the structure of
-/// the element model has been modified, then you should consider implementing
-/// the interface `ElementVisitor` directly. Doing so will ensure that changes
-/// that introduce new classes of elements will be flagged. (Of course, not all
-/// changes to the element model require the addition of a new class of element,
-/// and hence cannot be caught this way.)
-///
-/// But if automatic detection of these kinds of changes is not necessary then
-/// you will probably want to extend one of the classes in this library because
-/// doing so will simplify the task of writing your visitor and guard against
-/// future changes to the element model. For example, the
-/// `RecursiveElementVisitor` automates the process of visiting all of the
-/// descendants of an element.
-library;
-
-import 'package:analyzer/dart/element/element.dart';
-
-/// An element visitor that will recursively visit all of the elements in an
-/// element model (like instances of the class [RecursiveElementVisitor]). In
-/// addition, when an element of a specific type is visited not only will the
-/// visit method for that specific type of element be invoked, but additional
-/// methods for the supertypes of that element will also be invoked. For
-/// example, using an instance of this class to visit a [MethodElement] will
-/// cause the method [visitMethodElement] to be invoked but will also cause the
-/// methods [visitExecutableElement] and [visitElement] to be subsequently
-/// invoked. This allows visitors to be written that visit all executable
-/// elements without needing to override the visit method for each of the
-/// specific subclasses of [ExecutableElement].
-///
-/// Note, however, that unlike many visitors, element visitors visit objects
-/// based on the interfaces implemented by those elements. Because interfaces
-/// form a graph structure rather than a tree structure the way classes do, and
-/// because it is generally undesirable for an object to be visited more than
-/// once, this class flattens the interface graph into a pseudo-tree. In
-/// particular, this class treats elements as if the element types were
-/// structured in the following way:
-///
-/// <pre>
-/// Element
-/// ClassElement
-/// CompilationUnitElement
-/// ExecutableElement
-/// ConstructorElement
-/// LocalElement
-/// FunctionElement
-/// MethodElement
-/// PropertyAccessorElement
-/// ExportElement
-/// HtmlElement
-/// ImportElement
-/// LabelElement
-/// LibraryElement
-/// MultiplyDefinedElement
-/// PrefixElement
-/// TypeAliasElement
-/// TypeParameterElement
-/// UndefinedElement
-/// VariableElement
-/// PropertyInducingElement
-/// FieldElement
-/// TopLevelVariableElement
-/// LocalElement
-/// LocalVariableElement
-/// ParameterElement
-/// FieldFormalParameterElement
-/// </pre>
-///
-/// Subclasses that override a visit method must either invoke the overridden
-/// visit method or explicitly invoke the more general visit method. Failure to
-/// do so will cause the visit methods for superclasses of the element to not be
-/// invoked and will cause the children of the visited node to not be visited.
-///
-/// Clients may extend this class.
-@Deprecated('Use Element2, ElementVisitor2, and accept2() instead')
-class GeneralizingElementVisitor<R> implements ElementVisitor<R> {
- /// Initialize a newly created visitor.
- const GeneralizingElementVisitor();
-
- @override
- R? visitClassElement(ClassElement element) => visitElement(element);
-
- @override
- R? visitCompilationUnitElement(CompilationUnitElement element) =>
- visitElement(element);
-
- @override
- R? visitConstructorElement(ConstructorElement element) =>
- visitExecutableElement(element);
-
- R? visitElement(Element element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitEnumElement(EnumElement element) => visitElement(element);
-
- R? visitExecutableElement(ExecutableElement element) => visitElement(element);
-
- @override
- R? visitExtensionElement(ExtensionElement element) => visitElement(element);
-
- @override
- R? visitExtensionTypeElement(ExtensionTypeElement element) =>
- visitElement(element);
-
- @override
- R? visitFieldElement(FieldElement element) =>
- visitPropertyInducingElement(element);
-
- @override
- R? visitFieldFormalParameterElement(FieldFormalParameterElement element) =>
- visitParameterElement(element);
-
- @override
- R? visitFunctionElement(FunctionElement element) =>
- visitLocalElement(element);
-
- @override
- R? visitGenericFunctionTypeElement(GenericFunctionTypeElement element) =>
- visitElement(element);
-
- @override
- R? visitLabelElement(LabelElement element) => visitElement(element);
-
- @override
- R? visitLibraryElement(LibraryElement element) => visitElement(element);
-
- @override
- R? visitLibraryExportElement(LibraryExportElement element) =>
- visitElement(element);
-
- @override
- R? visitLibraryImportElement(LibraryImportElement element) =>
- visitElement(element);
-
- R? visitLocalElement(LocalElement element) {
- if (element is LocalVariableElement) {
- return visitVariableElement(element);
- } else if (element is ParameterElement) {
- return visitVariableElement(element);
- } else if (element is FunctionElement) {
- return visitExecutableElement(element);
- }
- return null;
- }
-
- @override
- R? visitLocalVariableElement(LocalVariableElement element) =>
- visitLocalElement(element);
-
- @override
- R? visitMethodElement(MethodElement element) =>
- visitExecutableElement(element);
-
- @override
- R? visitMixinElement(MixinElement element) => visitElement(element);
-
- @override
- R? visitMultiplyDefinedElement(MultiplyDefinedElement element) =>
- visitElement(element);
-
- @override
- R? visitParameterElement(ParameterElement element) =>
- visitLocalElement(element);
-
- @override
- R? visitPartElement(PartElement element) => visitElement(element);
-
- @override
- R? visitPrefixElement(PrefixElement element) => visitElement(element);
-
- @override
- R? visitPropertyAccessorElement(PropertyAccessorElement element) =>
- visitExecutableElement(element);
-
- R? visitPropertyInducingElement(PropertyInducingElement element) =>
- visitVariableElement(element);
-
- @override
- R? visitSuperFormalParameterElement(SuperFormalParameterElement element) =>
- visitParameterElement(element);
-
- @override
- R? visitTopLevelVariableElement(TopLevelVariableElement element) =>
- visitPropertyInducingElement(element);
-
- @override
- R? visitTypeAliasElement(TypeAliasElement element) => visitElement(element);
-
- @override
- R? visitTypeParameterElement(TypeParameterElement element) =>
- visitElement(element);
-
- R? visitVariableElement(VariableElement element) => visitElement(element);
-}
-
-/// A visitor that will recursively visit all of the element in an element
-/// model. For example, using an instance of this class to visit a
-/// [CompilationUnitElement] will also cause all of the types in the compilation
-/// unit to be visited.
-///
-/// Subclasses that override a visit method must either invoke the overridden
-/// visit method or must explicitly ask the visited element to visit its
-/// children. Failure to do so will cause the children of the visited element to
-/// not be visited.
-///
-/// Clients may extend this class.
-@Deprecated('Use Element2, ElementVisitor2, and accept2() instead')
-class RecursiveElementVisitor<R> implements ElementVisitor<R> {
- /// Initialize a newly created visitor.
- const RecursiveElementVisitor();
-
- @override
- R? visitClassElement(ClassElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitCompilationUnitElement(CompilationUnitElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitConstructorElement(ConstructorElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitEnumElement(EnumElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitExtensionElement(ExtensionElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitExtensionTypeElement(ExtensionTypeElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitFieldElement(FieldElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitFieldFormalParameterElement(FieldFormalParameterElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitFunctionElement(FunctionElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitGenericFunctionTypeElement(GenericFunctionTypeElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitLabelElement(LabelElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitLibraryElement(LibraryElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitLibraryExportElement(LibraryExportElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitLibraryImportElement(LibraryImportElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitLocalVariableElement(LocalVariableElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitMethodElement(MethodElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitMixinElement(MixinElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitMultiplyDefinedElement(MultiplyDefinedElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitParameterElement(ParameterElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitPartElement(PartElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitPrefixElement(PrefixElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitPropertyAccessorElement(PropertyAccessorElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitSuperFormalParameterElement(SuperFormalParameterElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitTopLevelVariableElement(TopLevelVariableElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitTypeAliasElement(TypeAliasElement element) {
- element.visitChildren(this);
- return null;
- }
-
- @override
- R? visitTypeParameterElement(TypeParameterElement element) {
- element.visitChildren(this);
- return null;
- }
-}
-
-/// A visitor that will do nothing when visiting an element. It is intended to
-/// be a superclass for classes that use the visitor pattern primarily as a
-/// dispatch mechanism (and hence don't need to recursively visit a whole
-/// structure) and that only need to visit a small number of element types.
-///
-/// Clients may extend this class.
-@Deprecated('Use Element2, ElementVisitor2, and accept2() instead')
-class SimpleElementVisitor<R> implements ElementVisitor<R> {
- /// Initialize a newly created visitor.
- const SimpleElementVisitor();
-
- @override
- R? visitClassElement(ClassElement element) => null;
-
- @override
- R? visitCompilationUnitElement(CompilationUnitElement element) => null;
-
- @override
- R? visitConstructorElement(ConstructorElement element) => null;
-
- @override
- R? visitEnumElement(EnumElement element) => null;
-
- @override
- R? visitExtensionElement(ExtensionElement element) => null;
-
- @override
- R? visitExtensionTypeElement(ExtensionTypeElement element) => null;
-
- @override
- R? visitFieldElement(FieldElement element) => null;
-
- @override
- R? visitFieldFormalParameterElement(FieldFormalParameterElement element) =>
- null;
-
- @override
- R? visitFunctionElement(FunctionElement element) => null;
-
- @override
- R? visitGenericFunctionTypeElement(GenericFunctionTypeElement element) =>
- null;
-
- @override
- R? visitLabelElement(LabelElement element) => null;
-
- @override
- R? visitLibraryElement(LibraryElement element) => null;
-
- @override
- R? visitLibraryExportElement(LibraryExportElement element) => null;
-
- @override
- R? visitLibraryImportElement(LibraryImportElement element) => null;
-
- @override
- R? visitLocalVariableElement(LocalVariableElement element) => null;
-
- @override
- R? visitMethodElement(MethodElement element) => null;
-
- @override
- R? visitMixinElement(MixinElement element) => null;
-
- @override
- R? visitMultiplyDefinedElement(MultiplyDefinedElement element) => null;
-
- @override
- R? visitParameterElement(ParameterElement element) => null;
-
- @override
- R? visitPartElement(PartElement element) => null;
-
- @override
- R? visitPrefixElement(PrefixElement element) => null;
-
- @override
- R? visitPropertyAccessorElement(PropertyAccessorElement element) => null;
-
- @override
- R? visitSuperFormalParameterElement(SuperFormalParameterElement element) =>
- null;
-
- @override
- R? visitTopLevelVariableElement(TopLevelVariableElement element) => null;
-
- @override
- R? visitTypeAliasElement(TypeAliasElement element) => null;
-
- @override
- R? visitTypeParameterElement(TypeParameterElement element) => null;
-}
-
-/// An AST visitor that will throw an exception if any of the visit methods that
-/// are invoked have not been overridden. It is intended to be a superclass for
-/// classes that implement the visitor pattern and need to (a) override all of
-/// the visit methods or (b) need to override a subset of the visit method and
-/// want to catch when any other visit methods have been invoked.
-///
-/// Clients may extend this class.
-@Deprecated('Use Element2, ElementVisitor2, and accept2() instead')
-class ThrowingElementVisitor<R> implements ElementVisitor<R> {
- /// Initialize a newly created visitor.
- const ThrowingElementVisitor();
-
- @override
- R? visitClassElement(ClassElement element) => _throw(element);
-
- @override
- R? visitCompilationUnitElement(CompilationUnitElement element) =>
- _throw(element);
-
- @override
- R? visitConstructorElement(ConstructorElement element) => _throw(element);
-
- @override
- R? visitEnumElement(EnumElement element) => _throw(element);
-
- @override
- R? visitExtensionElement(ExtensionElement element) => _throw(element);
-
- @override
- R? visitExtensionTypeElement(ExtensionTypeElement element) => _throw(element);
-
- @override
- R? visitFieldElement(FieldElement element) => _throw(element);
-
- @override
- R? visitFieldFormalParameterElement(FieldFormalParameterElement element) =>
- _throw(element);
-
- @override
- R? visitFunctionElement(FunctionElement element) => _throw(element);
-
- @override
- R? visitGenericFunctionTypeElement(GenericFunctionTypeElement element) =>
- _throw(element);
-
- @override
- R? visitLabelElement(LabelElement element) => _throw(element);
-
- @override
- R? visitLibraryElement(LibraryElement element) => _throw(element);
-
- @override
- R? visitLibraryExportElement(LibraryExportElement element) => _throw(element);
-
- @override
- R? visitLibraryImportElement(LibraryImportElement element) => _throw(element);
-
- @override
- R? visitLocalVariableElement(LocalVariableElement element) => _throw(element);
-
- @override
- R? visitMethodElement(MethodElement element) => _throw(element);
-
- @override
- R? visitMixinElement(MixinElement element) => _throw(element);
-
- @override
- R? visitMultiplyDefinedElement(MultiplyDefinedElement element) =>
- _throw(element);
-
- @override
- R? visitParameterElement(ParameterElement element) => _throw(element);
-
- @override
- R? visitPartElement(PartElement element) => _throw(element);
-
- @override
- R? visitPrefixElement(PrefixElement element) => _throw(element);
-
- @override
- R? visitPropertyAccessorElement(PropertyAccessorElement element) =>
- _throw(element);
-
- @override
- R? visitSuperFormalParameterElement(SuperFormalParameterElement element) =>
- _throw(element);
-
- @override
- R? visitTopLevelVariableElement(TopLevelVariableElement element) =>
- _throw(element);
-
- @override
- R? visitTypeAliasElement(TypeAliasElement element) => _throw(element);
-
- @override
- R? visitTypeParameterElement(TypeParameterElement element) => _throw(element);
-
- R _throw(Element element) {
- throw Exception('Missing implementation of visit${element.runtimeType}');
- }
-}
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index c595e5f..97bb45e 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -22,7 +22,6 @@
import 'package:analyzer/src/dart/ast/extensions.dart';
import 'package:analyzer/src/dart/ast/to_source_visitor.dart';
import 'package:analyzer/src/dart/element/element.dart';
-import 'package:analyzer/src/dart/element/member.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_schema.dart';
import 'package:analyzer/src/dart/resolver/body_inference_context.dart';
@@ -31,7 +30,6 @@
import 'package:analyzer/src/generated/inference_log.dart';
import 'package:analyzer/src/generated/resolver.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
-import 'package:analyzer/src/utilities/extensions/element.dart';
import 'package:analyzer/src/utilities/extensions/object.dart';
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
@@ -201,11 +199,6 @@
/// isn't the invocation of a named constructor.
SimpleIdentifier? get constructorName;
- /// The element associated with this annotation, or `null` if the AST
- /// structure hasn't been resolved or if this annotation couldn't be resolved.
- @Deprecated('Use element2 instead')
- Element? get element;
-
/// The element associated with this annotation.
///
/// Returns `null` if the AST structure hasn't been resolved or if this
@@ -304,12 +297,6 @@
_constructorName = _becomeParentOf(name);
}
- @Deprecated('Use element2 instead')
- @override
- Element? get element {
- return element2?.asElement;
- }
-
@override
Element2? get element2 {
if (_element2 case var element?) {
@@ -418,7 +405,7 @@
/// The list must be the same length as the number of arguments, but can
/// contain `null` entries if a given argument doesn't correspond to a formal
/// parameter.
- List<ParameterElementMixin?>? _correspondingStaticParameters;
+ List<FormalParameterElementMixin?>? _correspondingStaticParameters;
/// Initializes a newly created list of arguments.
ArgumentListImpl({
@@ -435,10 +422,11 @@
@override
Token get beginToken => leftParenthesis;
- List<ParameterElementMixin?>? get correspondingStaticParameters =>
+ List<FormalParameterElementMixin?>? get correspondingStaticParameters2 =>
_correspondingStaticParameters;
- set correspondingStaticParameters(List<ParameterElementMixin?>? parameters) {
+ set correspondingStaticParameters2(
+ List<FormalParameterElementMixin?>? parameters) {
if (parameters != null && parameters.length != _arguments.length) {
throw ArgumentError(
"Expected ${_arguments.length} parameters, not ${parameters.length}");
@@ -446,16 +434,6 @@
_correspondingStaticParameters = parameters;
}
- List<FormalParameterElementMixin?>? get correspondingStaticParameters2 =>
- _correspondingStaticParameters
- ?.map((parameter) => parameter?.asElement2)
- .toList();
-
- set correspondingStaticParameters2(
- List<FormalParameterElementMixin?>? value) {
- _correspondingStaticParameters = value?.map((e) => e?.asElement).toList();
- }
-
@override
Token get endToken => rightParenthesis;
@@ -482,7 +460,8 @@
/// - the function being invoked is known based on static type information
/// - the expression corresponds to one of the parameters of the function
/// being invoked
- ParameterElementMixin? _getStaticParameterElementFor(Expression expression) {
+ FormalParameterElementMixin? _getStaticParameterElementFor(
+ Expression expression) {
if (_correspondingStaticParameters == null ||
_correspondingStaticParameters!.length != _arguments.length) {
// Either the AST structure hasn't been resolved, the invocation of which
@@ -772,14 +751,6 @@
/// variablePattern ::= identifier
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class AssignedVariablePattern implements VariablePattern {
- /// The element referenced by this pattern, or `null` if either [name] doesn't
- /// resolve to an element or the AST structure hasn't been resolved.
- ///
- /// In valid code this is either a [LocalVariableElement] or a
- /// [ParameterElement].
- @Deprecated('Use element2 instead')
- Element? get element;
-
/// The element referenced by this pattern.
///
/// Returns `null` if either [name] doesn't resolve to an element or the AST
@@ -803,12 +774,6 @@
@override
Token get beginToken => name;
- @Deprecated('Use element2 instead')
- @override
- Element? get element {
- return element2.asElement;
- }
-
@override
Token get endToken => name;
@@ -880,7 +845,7 @@
ExpressionImpl _rightHandSide;
@override
- MethodElementOrMember? staticElement;
+ MethodElement2OrMember? element;
/// Initializes a newly created assignment expression.
AssignmentExpressionImpl({
@@ -896,14 +861,6 @@
@override
Token get beginToken => _leftHandSide.beginToken;
- @experimental
- @override
- MethodElement2OrMember? get element => staticElement?.asElement2;
-
- set element(MethodElement2OrMember? element) {
- staticElement = element?.asElement;
- }
-
@override
Token get endToken => _rightHandSide.endToken;
@@ -1276,6 +1233,9 @@
R? visitDoStatement(DoStatement node);
+ R? visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node);
+
R? visitDotShorthandInvocation(DotShorthandInvocation node);
R? visitDotShorthandPropertyAccess(DotShorthandPropertyAccess node);
@@ -1589,10 +1549,6 @@
/// The 'augmented' keyword.
Token get augmentedKeyword;
- /// The referenced augmented element: getter, setter, variable.
- @Deprecated('Use fragment instead')
- Element? get element;
-
/// The referenced augmented fragment: getter, setter, variable.
@experimental
Fragment? get fragment;
@@ -1613,10 +1569,6 @@
@override
Token get beginToken => augmentedKeyword;
- @Deprecated('Use fragment instead')
- @override
- Element? get element => fragment as Element?;
-
@override
Token get endToken => augmentedKeyword;
@@ -1657,10 +1609,6 @@
Token get augmentedKeyword;
/// The referenced augmented element: function, constructor, or method.
- @Deprecated('Use fragment instead')
- ExecutableElement? get element;
-
- /// The referenced augmented element: function, constructor, or method.
///
/// Returns `null` if the AST structure hasn't been resolved or if this
/// fragment is the first fragment in the chain.
@@ -1699,10 +1647,6 @@
@override
Token get beginToken => augmentedKeyword;
- @Deprecated('Use fragment instead')
- @override
- ExecutableElement? get element => fragment as ExecutableElement?;
-
@override
Token get endToken => arguments.endToken;
@@ -1867,10 +1811,6 @@
_rightOperand = _becomeParentOf(expression);
}
- @Deprecated('Use element instead')
- @override
- MethodElement? get staticElement => element?.asElement;
-
@override
ChildEntities get _childEntities => ChildEntities()
..addNode('leftOperand', leftOperand)
@@ -2584,10 +2524,6 @@
/// An 'exception' or 'stackTrace' parameter in [CatchClause].
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class CatchClauseParameter extends AstNode {
- /// The declared element, or `null` if the AST hasn't been resolved.
- @Deprecated('Use declaredElement2 instead')
- LocalVariableElement? get declaredElement;
-
/// The declared element.
///
/// Returns `null` if the AST hasn't been resolved.
@@ -2619,12 +2555,6 @@
@override
Token get beginToken => name;
- @Deprecated('Use fragment instead')
- @override
- LocalVariableElementImpl? get declaredElement {
- return declaredFragment;
- }
-
@override
LocalVariableElementImpl2? get declaredElement2 {
return declaredFragment?.element;
@@ -2749,10 +2679,6 @@
/// The token representing the `class` keyword.
Token get classKeyword;
- @Deprecated('Use declaredFragment instead')
- @override
- ClassElement? get declaredElement;
-
@experimental
@override
ClassFragment? get declaredFragment;
@@ -2890,11 +2816,6 @@
this.members._initialize(this, members);
}
- @Deprecated('Use declaredFragment instead')
- @experimental
- @override
- ClassElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => rightBracket;
@@ -2983,10 +2904,6 @@
/// The `base` keyword, or `null` if the keyword was absent.
Token? get baseKeyword;
- @Deprecated('Use declaredFragment instead')
- @override
- ClassElement? get declaredElement;
-
@experimental
@override
ClassFragment? get declaredFragment;
@@ -3094,10 +3011,6 @@
_becomeParentOf(_implementsClause);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ClassElementImpl? get declaredElement => declaredFragment;
-
@override
Token get firstTokenAfterCommentAndMetadata {
return abstractKeyword ??
@@ -3420,11 +3333,6 @@
/// The declarations contained in this compilation unit.
NodeList<CompilationUnitMember> get declarations;
- /// The element associated with this compilation unit, or `null` if the AST
- /// structure hasn't been resolved.
- @Deprecated('Use declaredFragment instead')
- CompilationUnitElement? get declaredElement;
-
/// The fragment associated with this compilation unit.
///
/// Returns `null` if the AST structure hasn't been resolved.
@@ -3532,12 +3440,6 @@
@override
NodeListImpl<CompilationUnitMemberImpl> get declarations => _declarations;
- @Deprecated('Use declaredFragment instead')
- @override
- CompilationUnitElementImpl? get declaredElement {
- return declaredFragment;
- }
-
@override
NodeListImpl<DirectiveImpl> get directives => _directives;
@@ -3656,19 +3558,6 @@
/// [PostfixExpression] when the operator is an increment operator.
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class CompoundAssignmentExpression implements Expression {
- /// The element that is used to read the value, or `null` if this node isn't a
- /// compound assignment, if the AST structure hasn't been resolved, or if the
- /// target couldn't be resolved.
- ///
- /// In valid code this element can be a [LocalVariableElement], a
- /// [ParameterElement], or a [PropertyAccessorElement] getter.
- ///
- /// In invalid code this element is `null`. For example, in `int += 2`, for
- /// recovery purposes, [writeElement] is filled, and can be used for
- /// navigation.
- @Deprecated('Use readElement2 instead')
- Element? get readElement;
-
/// The element that is used to read the value.
///
/// Returns `null` if this node isn't a compound assignment, if the AST
@@ -3690,22 +3579,6 @@
/// hasn't been resolved, or if the target couldn't be resolved.
DartType? get readType;
- /// The element that is used to write the result, or `null` if the AST
- /// structure hasn't been resolved, or if the target couldn't be resolved.
- ///
- /// In valid code this is a [LocalVariableElement], [ParameterElement], or a
- /// [PropertyAccessorElement] setter.
- ///
- /// In invalid code, for recovery, we might use other elements, for example a
- /// [PropertyAccessorElement] getter `myGetter = 0` even though the getter
- /// can't be used to write a value. We do this to help the user to navigate
- /// to the getter, and maybe add the corresponding setter.
- ///
- /// If this node is a compound assignment, e. g. `x += 2`, both [readElement]
- /// and [writeElement] could be non-`null`.
- @Deprecated('Use writeElement2 instead')
- Element? get writeElement;
-
/// The element that is used to write the result.
///
/// Returns `null` if the AST structure hasn't been resolved, or if the target
@@ -3745,16 +3618,6 @@
@override
TypeImpl? writeType;
-
- @Deprecated('Use readElement2 instead')
- @override
- Element? get readElement {
- return readElement2?.asElement;
- }
-
- @Deprecated('Use readElement2 instead')
- @override
- Element? get writeElement => writeElement2.asElement;
}
/// A conditional expression.
@@ -4131,10 +3994,6 @@
/// const constructor.
Token? get constKeyword;
- @Deprecated('Use declaredFragment instead')
- @override
- ConstructorElement? get declaredElement;
-
@experimental
@override
ConstructorFragment? get declaredFragment;
@@ -4272,10 +4131,6 @@
_body = _becomeParentOf(functionBody);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ConstructorElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken {
return _body.endToken;
@@ -4529,10 +4384,6 @@
_name = _becomeParentOf(name);
}
- @Deprecated('Use element instead')
- @override
- ConstructorElementMixin? get staticElement => element?.asElement;
-
@override
NamedTypeImpl get type => _type;
@@ -4625,12 +4476,6 @@
/// constructor couldn't be resolved.
@experimental
ConstructorElement2? get element;
-
- /// The element associated with the referenced constructor based on static
- /// type information, or `null` if the AST structure hasn't been resolved or
- /// if the constructor couldn't be resolved.
- @Deprecated('Use element instead')
- ConstructorElement? get staticElement;
}
/// The name of a constructor being invoked.
@@ -4859,12 +4704,6 @@
/// Each declared name is visible within a name scope.
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class Declaration implements AnnotatedNode {
- /// The element associated with this declaration, or `null` if either this
- /// node corresponds to a list of declarations or if the AST structure hasn't
- /// been resolved.
- @Deprecated('Use declaredFragment instead')
- Element? get declaredElement;
-
/// The fragment declared by this declaration.
///
/// Returns `null` if the AST structure hasn't been resolved.
@@ -4889,10 +4728,6 @@
/// [Annotation] finalConstVarOrType [SimpleIdentifier]
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class DeclaredIdentifier implements Declaration {
- @Deprecated('Use declaredFragment instead')
- @override
- LocalVariableElement? get declaredElement;
-
/// The element associated with this declaration.
///
/// Returns `null` if either this node corresponds to a list of declarations
@@ -4955,10 +4790,6 @@
_becomeParentOf(_type);
}
- @Deprecated('Use declaredFragment instead')
- @override
- LocalVariableElementImpl? get declaredElement => declaredFragment;
-
@experimental
@override
LocalVariableElementImpl2? get declaredElement2 {
@@ -5008,11 +4839,6 @@
/// ( 'var' | 'final' | 'final'? [TypeAnnotation])? [Identifier]
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
sealed class DeclaredVariablePattern implements VariablePattern {
- /// The element associated with this declaration, or `null` if the AST
- /// structure hasn't been resolved.
- @Deprecated('Use declaredFragment instead')
- BindPatternVariableElement? get declaredElement;
-
/// The element declared by this declaration.
///
/// Returns `null` if the AST structure hasn't been resolved.
@@ -5054,12 +4880,6 @@
@override
Token get beginToken => keyword ?? type?.beginToken ?? name;
- @Deprecated('Use declaredFragment instead')
- @override
- BindPatternVariableElementImpl? get declaredElement {
- return declaredFragment;
- }
-
@experimental
@override
BindPatternVariableElementImpl2? get declaredElement2 {
@@ -5187,10 +5007,6 @@
@override
Token? get covariantKeyword => null;
- @Deprecated('Use declaredFragment instead')
- @override
- ParameterElementImpl? get declaredElement => _parameter.declaredElement;
-
@experimental
@override
ParameterElementImpl? get declaredFragment => _parameter.declaredFragment;
@@ -5261,15 +5077,10 @@
/// | [PartDirective]
/// | [PartOfDirective]
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
-sealed class Directive implements AnnotatedNode {
- /// The element associated with this directive, or `null` if the AST structure
- /// hasn't been resolved or if this directive couldn't be resolved.
- @Deprecated('Use directive specific getters')
- Element? get element;
-}
+sealed class Directive implements AnnotatedNode {}
sealed class DirectiveImpl extends AnnotatedNodeImpl implements Directive {
- ElementImpl? _element;
+ ElementImpl? element;
/// Initializes a newly create directive.
///
@@ -5279,13 +5090,6 @@
required super.comment,
required super.metadata,
});
-
- @override
- ElementImpl? get element => _element;
-
- set element(ElementImpl? element) {
- _element = element;
- }
}
/// A do statement.
@@ -5391,6 +5195,91 @@
}
}
+/// A node that represents a dot shorthand constructor invocation.
+///
+/// For example, `.fromCharCode(42)`.
+///
+/// dotShorthandHead ::=
+/// '.' [SimpleIdentifier] [TypeArgumentList]? [ArgumentList]
+@experimental
+@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
+abstract final class DotShorthandConstructorInvocation
+ extends InvocationExpression implements ConstructorReferenceNode {
+ /// The name of the constructor invocation.
+ SimpleIdentifier get constructorName;
+
+ /// The token representing the period.
+ Token get period;
+}
+
+final class DotShorthandConstructorInvocationImpl
+ extends InvocationExpressionImpl
+ implements
+ DotShorthandConstructorInvocation,
+ RewrittenMethodInvocationImpl {
+ @override
+ final Token period;
+
+ SimpleIdentifierImpl _constructorName;
+
+ @override
+ ConstructorElementImpl2? element;
+
+ /// Initializes a newly created dot shorthand constructor invocation.
+ DotShorthandConstructorInvocationImpl({
+ required this.period,
+ required SimpleIdentifierImpl constructorName,
+ required super.typeArguments,
+ required super.argumentList,
+ }) : _constructorName = constructorName {
+ _becomeParentOf(_constructorName);
+ }
+
+ @override
+ Token get beginToken => period;
+
+ @override
+ SimpleIdentifierImpl get constructorName => _constructorName;
+
+ set constructorName(SimpleIdentifierImpl identifier) {
+ _constructorName = _becomeParentOf(identifier);
+ }
+
+ @override
+ Token get endToken => argumentList.endToken;
+
+ @override
+ ExpressionImpl get function => constructorName;
+
+ @override
+ Precedence get precedence => Precedence.postfix;
+
+ @override
+ ChildEntities get _childEntities => ChildEntities()
+ ..addToken('period', period)
+ ..addNode('constructorName', constructorName)
+ ..addNode('typeArguments', typeArguments)
+ ..addNode('argumentList', argumentList);
+
+ @override
+ E? accept<E>(AstVisitor<E> visitor) =>
+ visitor.visitDotShorthandConstructorInvocation(this);
+
+ @override
+ void resolveExpression(ResolverVisitor resolver, TypeImpl contextType) {
+ throw StateError(
+ 'DotShorthandConstructorInvocationImpl should only appear in fully'
+ ' resolved ASTs');
+ }
+
+ @override
+ void visitChildren(AstVisitor visitor) {
+ constructorName.accept(visitor);
+ typeArguments?.accept(visitor);
+ argumentList.accept(visitor);
+ }
+}
+
/// A node that represents a dot shorthand static method or constructor
/// invocation.
///
@@ -5808,12 +5697,6 @@
@experimental
Token? get augmentKeyword;
- /// The constructor that is invoked by this enum constant, or `null` if the
- /// AST structure hasn't been resolved, or if the constructor couldn't be
- /// resolved.
- @Deprecated('Use constructorElement2 instead')
- ConstructorElement? get constructorElement;
-
/// The constructor that's invoked by this enum constant.
///
/// Returns `null` if the AST structure hasn't been resolved, or if the
@@ -5821,10 +5704,6 @@
@experimental
ConstructorElement2? get constructorElement2;
- @Deprecated('Use constructorElement2 instead')
- @override
- FieldElement? get declaredElement;
-
@experimental
@override
FieldFragment? get declaredFragment;
@@ -5864,15 +5743,6 @@
_becomeParentOf(arguments);
}
- @Deprecated('Use constructorElement2 instead')
- @override
- ConstructorElementMixin? get constructorElement =>
- constructorElement2?.asElement;
-
- @Deprecated('Use constructorElement2 instead')
- @override
- FieldElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => arguments?.endToken ?? name;
@@ -5911,10 +5781,6 @@
/// The enumeration constants being declared.
NodeList<EnumConstantDeclaration> get constants;
- @Deprecated('Use declaredFragment instead')
- @override
- EnumElement? get declaredElement;
-
@experimental
@override
EnumFragment? get declaredFragment;
@@ -6011,10 +5877,6 @@
@override
NodeListImpl<EnumConstantDeclarationImpl> get constants => _constants;
- @Deprecated('Use declaredFragment instead')
- @override
- EnumElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => rightBracket;
@@ -6080,12 +5942,6 @@
/// [Annotation] 'export' [StringLiteral] [Combinator]* ';'
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class ExportDirective implements NamespaceDirective {
- /// The element associated with this directive, or `null` if the AST structure
- /// hasn't been resolved.
- @Deprecated('Use libraryExport instead')
- @override
- LibraryExportElement? get element;
-
/// The token representing the `export` keyword.
Token get exportKeyword;
@@ -6117,19 +5973,13 @@
required super.semicolon,
});
- @Deprecated('Use libraryExport instead')
- @override
- LibraryExportElementImpl? get element {
- return super.element as LibraryExportElementImpl?;
- }
-
@override
Token get firstTokenAfterCommentAndMetadata => exportKeyword;
@experimental
@override
LibraryExportElementImpl? get libraryExport {
- return _element as LibraryExportElementImpl?;
+ return element as LibraryExportElementImpl?;
}
@override
@@ -6208,17 +6058,6 @@
/// of `+`.
Precedence get precedence;
- /// The parameter element representing the parameter to which the value of
- /// this expression is bound, or `null` if any of these conditions are not
- /// `true`
- /// - this expression is an argument to an invocation
- /// - the AST structure is resolved
- /// - the function being invoked is known based on static type information
- /// - this expression corresponds to one of the parameters of the function
- /// being invoked
- @Deprecated('Use correspondingParameter instead')
- ParameterElement? get staticParameterElement;
-
/// The static type of this expression, or `null` if the AST structure hasn't
/// been resolved.
DartType? get staticType;
@@ -6351,11 +6190,36 @@
@experimental
@override
FormalParameterElementMixin? get correspondingParameter {
- return switch (staticParameterElement) {
- ParameterElementImpl(:var element) => element,
- ParameterMember member => member,
- _ => null,
- };
+ var parent = this.parent;
+ if (parent is ArgumentListImpl) {
+ return parent._getStaticParameterElementFor(this);
+ } else if (parent is IndexExpressionImpl) {
+ if (identical(parent.index, this)) {
+ return parent._staticParameterElementForIndex;
+ }
+ } else if (parent is BinaryExpressionImpl) {
+ // TODO(scheglov): https://github.com/dart-lang/sdk/issues/49102
+ if (identical(parent.rightOperand, this)) {
+ var parameters = parent.staticInvokeType?.formalParameters;
+ if (parameters != null && parameters.isNotEmpty) {
+ return parameters[0];
+ }
+ return null;
+ }
+ } else if (parent is AssignmentExpressionImpl) {
+ if (identical(parent.rightHandSide, this)) {
+ return parent._staticParameterElementForRightHandSide;
+ }
+ } else if (parent is PrefixExpressionImpl) {
+ // TODO(scheglov): This doesn't look right, there's no element for
+ // the operand, for `a++` we invoke `a = a + 1`, so the parameter
+ // is for `1`, not for `a`.
+ return parent._staticParameterElementForOperand2;
+ } else if (parent is PostfixExpressionImpl) {
+ // TODO(scheglov): The same as above.
+ return parent._staticParameterElementForOperand2;
+ }
+ return null;
}
@override
@@ -6367,40 +6231,6 @@
bool get isAssignable => false;
@override
- ParameterElementMixin? get staticParameterElement {
- var parent = this.parent;
- if (parent is ArgumentListImpl) {
- return parent._getStaticParameterElementFor(this);
- } else if (parent is IndexExpressionImpl) {
- if (identical(parent.index, this)) {
- return parent._staticParameterElementForIndex?.asElement;
- }
- } else if (parent is BinaryExpressionImpl) {
- // TODO(scheglov): https://github.com/dart-lang/sdk/issues/49102
- if (identical(parent.rightOperand, this)) {
- var parameters = parent.staticInvokeType?.parameters;
- if (parameters != null && parameters.isNotEmpty) {
- return parameters[0];
- }
- return null;
- }
- } else if (parent is AssignmentExpressionImpl) {
- if (identical(parent.rightHandSide, this)) {
- return parent._staticParameterElementForRightHandSide?.asElement;
- }
- } else if (parent is PrefixExpressionImpl) {
- // TODO(scheglov): This doesn't look right, there's no element for
- // the operand, for `a++` we invoke `a = a + 1`, so the parameter
- // is for `1`, not for `a`.
- return parent._staticParameterElementForOperand2?.asElement;
- } else if (parent is PostfixExpressionImpl) {
- // TODO(scheglov): The same as above.
- return parent._staticParameterElementForOperand2?.asElement;
- }
- return null;
- }
-
- @override
TypeImpl? get staticType => _staticType;
@override
@@ -6646,10 +6476,6 @@
@experimental
Token? get augmentKeyword;
- @Deprecated('Use declaredFragment instead')
- @override
- ExtensionElement? get declaredElement;
-
@experimental
@override
ExtensionFragment? get declaredFragment;
@@ -6729,10 +6555,6 @@
_members._initialize(this, members);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ExtensionElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => rightBracket;
@@ -6836,10 +6658,6 @@
/// being extended.
ArgumentList get argumentList;
- /// The forced extension element.
- @Deprecated('Use element2 instead')
- ExtensionElement get element;
-
/// The extension that resolution will use to resolve member references.
@experimental
ExtensionElement2 get element2;
@@ -6914,10 +6732,6 @@
@override
Token get beginToken => importPrefix?.name ?? name;
- @Deprecated('Use element2 instead')
- @override
- ExtensionElementImpl get element => element2.firstFragment;
-
@override
Token get endToken => _argumentList.endToken;
@@ -6982,10 +6796,6 @@
/// The `const` keyword.
Token? get constKeyword;
- @Deprecated('Use declaredFragment instead')
- @override
- ExtensionTypeElement? get declaredElement;
-
@experimental
@override
ExtensionTypeFragment? get declaredFragment;
@@ -7072,10 +6882,6 @@
this.members._initialize(this, members);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ExtensionTypeElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => rightBracket;
@@ -7201,10 +7007,6 @@
_becomeParentOf(_fieldList);
}
- @Deprecated('Use declaredFragment instead')
- @override
- Element? get declaredElement => null;
-
@override
Fragment? get declaredFragment => null;
@@ -7785,11 +7587,6 @@
/// The `covariant` keyword, or `null` if the keyword isn't used.
Token? get covariantKeyword;
- /// The element representing this parameter, or `null` if this parameter
- /// hasn't been resolved.
- @Deprecated('Use declaredFragment instead')
- ParameterElement? get declaredElement;
-
///The fragment declared by this parameter.
///
/// Returns `null` if this parameter hasn't been resolved.
@@ -7864,10 +7661,6 @@
@override
ParameterElementImpl? declaredFragment;
- @Deprecated('Use declaredFragment instead')
- @override
- ParameterElementImpl? get declaredElement => declaredFragment;
-
@override
bool get isNamed => kind.isNamed;
@@ -7935,13 +7728,6 @@
/// The left parenthesis.
Token get leftParenthesis;
- /// A list containing the elements representing the parameters in this list.
- ///
- /// The list contains `null`s if the parameters in this list haven't been
- /// resolved.
- @Deprecated('Use parameterFragments instead')
- List<ParameterElement?> get parameterElements;
-
/// A list containing the fragments representing the parameters in this list.
///
/// The list contains `null`s if the parameters in this list haven't been
@@ -7998,20 +7784,11 @@
@override
Token get endToken => rightParenthesis;
- @override
- List<ParameterElementImpl?> get parameterElements {
- int count = _parameters.length;
- var types = <ParameterElementImpl?>[];
- for (int i = 0; i < count; i++) {
- types.add(_parameters[i].declaredFragment);
- }
- return types;
- }
-
@experimental
@override
- List<FormalParameterFragment?> get parameterFragments =>
- parameterElements.cast<FormalParameterFragment?>();
+ List<ParameterElementImpl?> get parameterFragments {
+ return _parameters.map((node) => node.declaredFragment).toList();
+ }
@override
NodeListImpl<FormalParameterImpl> get parameters => _parameters;
@@ -8418,18 +8195,6 @@
/// level function or method containing this [FunctionBody], return `false`.
///
/// Throws an exception if resolution hasn't been performed.
- @Deprecated('Use isPotentiallyMutatedInScope2 instead')
- bool isPotentiallyMutatedInScope(VariableElement variable);
-
- /// If [variable] is a local variable or parameter declared anywhere within
- /// the top level function or method containing this [FunctionBody], return a
- /// boolean indicating whether [variable] is potentially mutated within the
- /// scope of its declaration.
- ///
- /// If [variable] isn't a local variable or parameter declared within the top
- /// level function or method containing this [FunctionBody], return `false`.
- ///
- /// Throws an exception if resolution hasn't been performed.
@experimental
bool isPotentiallyMutatedInScope2(VariableElement2 variable);
}
@@ -8459,13 +8224,6 @@
@override
Token? get star => null;
- @Deprecated('Use isPotentiallyMutatedInScope2 instead')
- @override
- bool isPotentiallyMutatedInScope(VariableElement variable) {
- var v2 = (variable as VariableElementImpl).element;
- return isPotentiallyMutatedInScope2(v2);
- }
-
@override
bool isPotentiallyMutatedInScope2(VariableElement2 variable) {
if (localVariableInfo == null) {
@@ -8502,14 +8260,6 @@
@experimental
Token? get augmentKeyword;
- /// The element defined by this declaration.
- ///
- /// Returns `null` if the AST structure hasn't been resolved or if this node
- /// represents a top-level function.
- @Deprecated('Use declaredFragment instead')
- @override
- ExecutableElement? get declaredElement;
-
/// The fragment declared by this declaration.
///
/// Returns `null` if the AST structure hasn't been resolved or if this node
@@ -8585,12 +8335,6 @@
_becomeParentOf(_functionExpression);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ExecutableElementImpl? get declaredElement {
- return declaredFragment;
- }
-
@override
Token get endToken => _functionExpression.endToken;
@@ -8697,11 +8441,6 @@
/// The body of the function.
FunctionBody get body;
- /// The element associated with the function, or `null` if the AST structure
- /// hasn't been resolved.
- @Deprecated('Use declaredFragment instead')
- ExecutableElement? get declaredElement;
-
/// The fragment declared by this function expression.
///
/// Returns `null` if the AST structure hasn't been resolved.
@@ -8767,10 +8506,6 @@
_body = _becomeParentOf(functionBody);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ExecutableElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken {
return _body.endToken;
@@ -8837,17 +8572,11 @@
/// The expression producing the function being invoked.
@override
Expression get function;
-
- /// The element associated with the function being invoked based on static
- /// type information, or `null` if the AST structure hasn't been resolved or
- /// the function couldn't be resolved.
- @Deprecated('Use element instead')
- ExecutableElement? get staticElement;
}
final class FunctionExpressionInvocationImpl extends InvocationExpressionImpl
with NullShortableExpressionImpl
- implements FunctionExpressionInvocation {
+ implements FunctionExpressionInvocation, RewrittenMethodInvocationImpl {
ExpressionImpl _function;
@override
@@ -8878,12 +8607,6 @@
@override
Precedence get precedence => Precedence.postfix;
- @Deprecated('Use element instead')
- @override
- ExecutableElement? get staticElement {
- return element?.asElement;
- }
-
@override
ChildEntities get _childEntities => ChildEntities()
..addNode('function', function)
@@ -9016,10 +8739,6 @@
/// [TypeAnnotation]? [SimpleIdentifier]
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class FunctionTypeAlias implements TypeAlias {
- @Deprecated('Use declaredFragment instead')
- @override
- TypeAliasElement? get declaredElement;
-
@experimental
@override
TypeAliasFragment? get declaredFragment;
@@ -9073,10 +8792,6 @@
_becomeParentOf(_parameters);
}
- @Deprecated('Use declaredFragment instead')
- @override
- TypeAliasElementImpl? get declaredElement => declaredFragment;
-
@override
FormalParameterListImpl get parameters => _parameters;
@@ -9437,10 +9152,6 @@
_becomeParentOf(_type);
}
- @Deprecated('Use declaredFragment instead')
- @override
- TypeAliasElementImpl? get declaredElement => declaredFragment;
-
@override
GenericFunctionType? get functionType {
var type = _type;
@@ -9602,13 +9313,6 @@
/// The lexical representation of the identifier.
String get name;
- /// The element associated with this identifier based on static type
- /// information, or `null` if the AST structure hasn't been resolved or if
- /// this identifier couldn't be resolved. One example of the latter case is an
- /// identifier that isn't defined within the scope in which it appears.
- @Deprecated('Use element instead')
- Element? get staticElement;
-
/// Returns `true` if the given [name] is visible only within the library in
/// which it's declared.
static bool isPrivateName(String name) => name.isNotEmpty && name[0] == "_";
@@ -9618,12 +9322,6 @@
implements Identifier {
@override
bool get isAssignable => true;
-
- @Deprecated('Use element instead')
- @override
- Element? get staticElement {
- return element?.asElement;
- }
}
/// The basic structure of an if element.
@@ -9986,12 +9684,6 @@
/// The expression from which a `call` method is being referenced.
Expression get expression;
- /// The element associated with the implicit `call` reference based on the
- /// static types.
- @Deprecated('Use element instead')
- @override
- MethodElement get staticElement;
-
/// The type arguments being applied to the tear-off, or `null` if there are
/// no type arguments.
TypeArgumentList? get typeArguments;
@@ -10043,10 +9735,6 @@
Precedence get precedence =>
typeArguments == null ? expression.precedence : Precedence.postfix;
- @Deprecated('Use element instead')
- @override
- MethodElement get staticElement => element.asElement;
-
@override
TypeArgumentListImpl? get typeArguments => _typeArguments;
@@ -10093,12 +9781,6 @@
/// URI isn't deferred.
Token? get deferredKeyword;
- /// The element associated with this directive, or `null` if the AST structure
- /// hasn't been resolved.
- @Deprecated('Use libraryImport instead')
- @override
- LibraryImportElement? get element;
-
/// The token representing the `import` keyword.
Token get importKeyword;
@@ -10152,18 +9834,13 @@
_becomeParentOf(_prefix);
}
- @Deprecated('Use element instead')
- @override
- LibraryImportElementImpl? get element =>
- super.element as LibraryImportElementImpl?;
-
@override
Token get firstTokenAfterCommentAndMetadata => importKeyword;
@experimental
@override
LibraryImportElementImpl? get libraryImport {
- return _element as LibraryImportElementImpl?;
+ return element as LibraryImportElementImpl?;
}
@override
@@ -10257,12 +9934,6 @@
abstract final class ImportPrefixReference implements AstNode {
/// The element to which [name] is resolved.
///
- /// Usually a [PrefixElement], but can be anything in invalid code.
- @Deprecated('Use element2 instead')
- Element? get element;
-
- /// The element to which [name] is resolved.
- ///
/// Usually a [PrefixElement2], but can be anything in invalid code.
@experimental
Element2? get element2;
@@ -10293,12 +9964,6 @@
@override
Token get beginToken => name;
- @Deprecated('Use element2 instead')
- @override
- Element? get element {
- return element2?.asElement;
- }
-
@override
Token get endToken => period;
@@ -10482,10 +10147,6 @@
return _target!;
}
- @Deprecated('Use element instance')
- @override
- MethodElement? get staticElement => element?.asElement;
-
@override
ExpressionImpl? get target => _target;
@@ -10989,8 +10650,8 @@
/// The invocation of a function or method.
///
-/// This will either be a [FunctionExpressionInvocation], [MethodInvocation],
-/// or a [DotShorthandInvocation].
+/// This will either be a [FunctionExpressionInvocation], a [MethodInvocation],
+/// a [DotShorthandConstructorInvocation], or a [DotShorthandInvocation].
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class InvocationExpression implements Expression {
/// The list of arguments to the method.
@@ -11292,10 +10953,6 @@
/// [Annotation] 'library' [LibraryIdentifier]? ';'
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class LibraryDirective implements Directive {
- @Deprecated('Use element2 instead')
- @override
- LibraryElement? get element;
-
/// The element associated with this directive.
///
/// Returns `null` if the AST structure hasn't been resolved or if this
@@ -11337,15 +10994,9 @@
_becomeParentOf(_name);
}
- @Deprecated('Use element2 instead')
- @override
- LibraryElementImpl? get element {
- return element2;
- }
-
@experimental
@override
- LibraryElementImpl? get element2 => _element as LibraryElementImpl?;
+ LibraryElementImpl? get element2 => element as LibraryElementImpl?;
@override
Token get endToken => semicolon;
@@ -12126,10 +11777,6 @@
/// The body of the method.
FunctionBody get body;
- @Deprecated('Use declaredFragment instead')
- @override
- ExecutableElement? get declaredElement;
-
@experimental
@override
ExecutableFragment? get declaredFragment;
@@ -12237,10 +11884,6 @@
_becomeParentOf(body);
}
- @Deprecated('Use declaredFragment instead')
- @override
- ExecutableElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => body.endToken;
@@ -12503,14 +12146,6 @@
/// to couldn't be resolved.
@experimental
MethodElement2? get element;
-
- /// The element associated with the expression based on the static types, or
- /// `null` if the AST structure hasn't been resolved, or there's no meaningful
- /// static element to return. The latter case can occur, for example, when
- /// this is a non-compound assignment expression, or when the method referred
- /// to couldn't be resolved.
- @Deprecated('Use element instead')
- MethodElement? get staticElement;
}
/// The declaration of a mixin.
@@ -12526,10 +12161,6 @@
/// The `base` keyword, or `null` if the keyword was absent.
Token? get baseKeyword;
- @Deprecated('Use declaredFragment instead')
- @override
- MixinElement? get declaredElement;
-
@experimental
@override
MixinFragment? get declaredFragment;
@@ -12612,10 +12243,6 @@
this.members._initialize(this, members);
}
- @Deprecated('Use declaredFragment instead')
- @override
- MixinElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken => rightBracket;
@@ -12733,12 +12360,6 @@
/// [Label] [Expression]
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class NamedExpression implements Expression {
- /// The element representing the parameter being named by this expression, or
- /// `null` if the AST structure hasn't been resolved or if there's no
- /// parameter with the same name as this expression.
- @Deprecated('Use element2 instead')
- ParameterElement? get element;
-
/// The element representing the parameter being named by this expression.
///
/// Returns `null` if the AST structure hasn't been resolved or if there's no
@@ -12772,12 +12393,6 @@
@override
Token get beginToken => _name.beginToken;
- @Deprecated('Use element2 instead')
- @override
- ParameterElementMixin? get element {
- return element2?.asElement;
- }
-
@experimental
@override
FormalParameterElementMixin? get element2 {
@@ -12830,12 +12445,6 @@
/// [ImportPrefixReference]? name typeArguments?
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class NamedType implements TypeAnnotation {
- /// The element of [name2] considering [importPrefix] for example a
- /// [ClassElement2], or [TypeAliasElement2], or `null` if [name2] can't be
- /// resolved, or there's no element for the type name, such as for `void`.
- @Deprecated('Use element2 instead')
- Element? get element;
-
/// The element of [name2] considering [importPrefix].
///
/// This could be a [ClassElement2], [TypeAliasElement2], or other type defining
@@ -12905,12 +12514,6 @@
@override
Token get beginToken => importPrefix?.beginToken ?? name2;
- @Deprecated('Use element2 instead')
- @override
- Element? get element {
- return element2.asElement;
- }
-
@override
Token get endToken => question ?? typeArguments?.endToken ?? name2;
@@ -13946,10 +13549,6 @@
/// The configurations that control which file is actually included.
NodeList<Configuration> get configurations;
- @Deprecated('Use partInclude instead')
- @override
- PartElement? get element;
-
/// Information about this part directive.
///
/// Returns `null` if the AST structure hasn't been resolved.
@@ -13989,12 +13588,6 @@
this.configurations._initialize(this, configurations);
}
- @Deprecated('Use partInclude instead')
- @override
- PartElementImpl? get element {
- return super.element as PartElementImpl?;
- }
-
@override
Token get endToken => semicolon;
@@ -14003,7 +13596,7 @@
@experimental
@override
- PartElementImpl? get partInclude => _element as PartElementImpl?;
+ PartElementImpl? get partInclude => element as PartElementImpl?;
@override
ChildEntities get _childEntities => super._childEntities
@@ -14210,12 +13803,6 @@
/// implied by the variable pattern inside [pattern].
String? get effectiveName;
- /// The element referenced by [effectiveName], or `null` if not resolved yet,
- /// non-`null` inside valid [ObjectPattern]s, always `null` inside
- /// [RecordPattern]s.
- @Deprecated('Use element2 instead')
- Element? get element;
-
/// The element referenced by [effectiveName].
///
/// Returns `null` if the AST structure is not resolved yet.
@@ -14260,12 +13847,6 @@
return null;
}
- @Deprecated('Use element2 instead')
- @override
- Element? get element {
- return element2?.asElement;
- }
-
@override
Token get endToken => pattern.endToken;
@@ -14489,13 +14070,6 @@
/// The postfix operator being applied to the operand.
Token get operator;
-
- /// The element associated with the operator based on the static type of the
- /// operand, or `null` if the AST structure hasn't been resolved, if the
- /// operator isn't user definable, or if the operator couldn't be resolved.
- @Deprecated('Use element instead')
- @override
- MethodElement? get staticElement;
}
final class PostfixExpressionImpl extends ExpressionImpl
@@ -14533,10 +14107,6 @@
@override
Precedence get precedence => Precedence.postfix;
- @Deprecated('Use element2 instead')
- @override
- MethodElement? get staticElement => element?.asElement;
-
@override
ChildEntities get _childEntities => ChildEntities()
..addNode('operand', operand)
@@ -14707,13 +14277,6 @@
/// The prefix operator being applied to the operand.
Token get operator;
-
- /// The element associated with the operator based on the static type of the
- /// operand, or `null` if the AST structure hasn't been resolved, if the
- /// operator isn't user definable, or if the operator couldn't be resolved.
- @Deprecated('Use element instead')
- @override
- MethodElement? get staticElement;
}
final class PrefixExpressionImpl extends ExpressionImpl
@@ -14751,10 +14314,6 @@
@override
Precedence get precedence => Precedence.prefix;
- @Deprecated('Use element instead')
- @override
- MethodElement? get staticElement => element?.asElement;
-
@override
ChildEntities get _childEntities => ChildEntities()
..addToken('operator', operator)
@@ -15417,7 +14976,7 @@
ArgumentListImpl _argumentList;
@override
- ConstructorElementImpl? staticElement;
+ ConstructorElementImpl2? element;
/// Initializes a newly created redirecting invocation to invoke the
/// constructor with the given name with the given arguments.
@@ -15452,14 +15011,6 @@
_constructorName = _becomeParentOf(identifier);
}
- @experimental
- @override
- ConstructorElementImpl2? get element => staticElement?.asElement2;
-
- set element(ConstructorElementImpl2? value) {
- staticElement = value?.asElement;
- }
-
@override
Token get endToken => _argumentList.endToken;
@@ -15488,10 +15039,6 @@
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class RelationalPattern implements DartPattern {
/// The element of the [operator] for the matched type.
- @Deprecated('Use element2 instead')
- MethodElement? get element;
-
- /// The element of the [operator] for the matched type.
///
/// Returns `null` if the AST structure hasn't been resolved or if the
/// operator couldn't be resolved.
@@ -15525,12 +15072,6 @@
@override
Token get beginToken => operator;
- @Deprecated('Use element2 instead')
- @override
- MethodElement? get element {
- return element2?.asElement;
- }
-
@override
Token get endToken => operand.endToken;
@@ -15631,10 +15172,6 @@
@experimental
@AnalyzerPublicApi(message: 'exported by lib/dart/ast/ast.dart')
abstract final class RepresentationDeclaration implements AstNode {
- /// The element of the primary constructor.
- @Deprecated('Use constructorFragment instead')
- ConstructorElement? get constructorElement;
-
/// The fragment of the primary constructor contained in this declaration.
@experimental
ConstructorFragment? get constructorFragment;
@@ -15642,10 +15179,6 @@
/// The optional name of the primary constructor.
RepresentationConstructorName? get constructorName;
- /// The element for [fieldName] with [fieldType].
- @Deprecated('Use fieldFragment instead')
- FieldElement? get fieldElement;
-
/// The fragment for [fieldName] with [fieldType] contained in this
/// declaration.
@experimental
@@ -15709,17 +15242,9 @@
@override
Token get beginToken => constructorName?.beginToken ?? leftParenthesis;
- @Deprecated('Use constructorFragment instead')
- @override
- ConstructorElementImpl? get constructorElement => constructorFragment;
-
@override
Token get endToken => rightParenthesis;
- @Deprecated('Use fieldFragment instead')
- @override
- FieldElementImpl? get fieldElement => fieldFragment;
-
@override
ChildEntities get _childEntities => super._childEntities
..addNode('constructorName', constructorName)
@@ -15908,6 +15433,12 @@
}
}
+/// A resolved dot shorthand invocation.
+///
+/// Either a [FunctionExpressionInvocationImpl], a static method invocation, or
+/// a [DotShorthandConstructorInvocationImpl], a constructor invocation.
+sealed class RewrittenMethodInvocationImpl implements ExpressionImpl {}
+
/// A script tag that can optionally occur at the beginning of a compilation
/// unit.
///
@@ -16350,34 +15881,6 @@
@override
Precedence get precedence => Precedence.primary;
- /// The element being referenced by this identifier, or `null` if this
- /// identifier is used to either read or write a value, the AST structure
- /// hasn't been resolved, or if this identifier couldn't be resolved.
- ///
- /// This element is set when this identifier is used not as an expression,
- /// but just to reference some element.
- ///
- /// Examples are the name of the type in a [NamedType], the name of the method
- /// in a [MethodInvocation], the name of the constructor in a
- /// [ConstructorName], the name of the property in a [PropertyAccess], the
- /// prefix and the identifier in a [PrefixedIdentifier] (which then can be
- /// used to read or write a value).
- ///
- /// In invalid code, for recovery, any element could be used. For example, in
- /// `set mySetter(_) {} mySetter topVar;` a setter is used as a type name. We
- /// do this to help the user to navigate to this element, and maybe change its
- /// name, add a new declaration, etc.
- ///
- /// If either [readElement] or [writeElement] aren't `null`, the
- /// [referenceElement] is `null`, because the identifier is being used to
- /// read or write a value.
- ///
- /// All three of [readElement], [writeElement], and [referenceElement] can be
- /// `null` when the AST structure hasn't been resolved, or this identifier
- /// couldn't be resolved.
- @Deprecated('Use more specific elements of nodes')
- Element? get referenceElement => null;
-
@override
ChildEntities get _childEntities => ChildEntities()..addToken('token', token);
@@ -17022,10 +16525,6 @@
@override
Token get endToken => _argumentList.endToken;
- @Deprecated('Use element instead')
- @override
- ConstructorElementMixin? get staticElement => element?.asElement;
-
@override
ChildEntities get _childEntities => ChildEntities()
..addToken('superKeyword', superKeyword)
@@ -18022,10 +17521,6 @@
_becomeParentOf(_variableList);
}
- @Deprecated('Use declaredFragment instead')
- @override
- Element? get declaredElement => null;
-
@override
Fragment? get declaredFragment => null;
@@ -18444,10 +17939,6 @@
/// upper bound.
TypeAnnotation? get bound;
- @Deprecated('Use declaredFragment instead')
- @override
- TypeParameterElement? get declaredElement;
-
@experimental
@override
TypeParameterFragment? get declaredFragment;
@@ -18501,10 +17992,6 @@
_bound = _becomeParentOf(type);
}
- @Deprecated('Use declaredFragment instead')
- @override
- TypeParameterElementImpl? get declaredElement => declaredFragment;
-
@override
Token get endToken {
return _bound?.endToken ?? name;
@@ -18697,14 +18184,6 @@
///
/// Returns `null` if the AST structure hasn't been resolved or if this node
/// represents the declaration of a top-level variable or a field.
- @Deprecated('Use declaredFragment instead')
- @override
- VariableElement? get declaredElement;
-
- /// The element declared by this declaration.
- ///
- /// Returns `null` if the AST structure hasn't been resolved or if this node
- /// represents the declaration of a top-level variable or a field.
@experimental
LocalVariableElement2? get declaredElement2;
@@ -18771,12 +18250,6 @@
_becomeParentOf(_initializer);
}
- @Deprecated('Use declaredFragment instead')
- @override
- VariableElementImpl? get declaredElement {
- return declaredFragment;
- }
-
@experimental
@override
LocalVariableElementImpl2? get declaredElement2 {
diff --git a/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart b/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
index 54581ed..05b284d 100644
--- a/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
@@ -349,6 +349,15 @@
}
@override
+ void visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) {
+ _visitToken(node.period);
+ _visitNode(node.constructorName);
+ _visitNode(node.typeArguments);
+ _visitNode(node.argumentList);
+ }
+
+ @override
void visitDotShorthandInvocation(DotShorthandInvocation node) {
_visitToken(node.period);
_visitNode(node.memberName);
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 5a3cf7b..b6b842c 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -869,6 +869,17 @@
}
@override
+ Constant visitDotShorthandPropertyAccess(
+ covariant DotShorthandPropertyAccessImpl node) {
+ return _getConstantValue(
+ errorNode: node,
+ expression: node,
+ identifier: node.propertyName,
+ element: node.propertyName.element,
+ );
+ }
+
+ @override
Constant visitDoubleLiteral(DoubleLiteral node) {
return DartObjectImpl(
typeSystem,
@@ -2975,7 +2986,7 @@
} else if (initializer is RedirectingConstructorInvocationImpl) {
// This is a redirecting constructor, so just evaluate the constructor
// it redirects to.
- var baseElement = initializer.staticElement;
+ var baseElement = initializer.element?.lastFragment;
if (baseElement != null && baseElement.isConst) {
// Instantiate the constructor with the in-scope type arguments.
var constructor = ConstructorMember.from(baseElement, definingType);
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 89b1815..9412274 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -90,65 +90,6 @@
}
@Deprecated(elementModelDeprecationMsg)
-class AugmentedClassElementImpl extends AugmentedInterfaceElementImpl
- implements AugmentedClassElement {
- AugmentedClassElementImpl(super.firstFragment);
-
- @override
- ClassElementImpl get firstFragment {
- return super.firstFragment as ClassElementImpl;
- }
-}
-
-@Deprecated(elementModelDeprecationMsg)
-class AugmentedEnumElementImpl extends AugmentedInterfaceElementImpl
- implements AugmentedEnumElement {
- AugmentedEnumElementImpl(super.firstFragment);
-
- @override
- List<FieldElement> get constants => firstFragment.constants;
-
- @override
- EnumElementImpl get firstFragment {
- return super.firstFragment as EnumElementImpl;
- }
-}
-
-@Deprecated(elementModelDeprecationMsg)
-class AugmentedExtensionElementImpl extends AugmentedInstanceElementImpl
- implements AugmentedExtensionElement {
- AugmentedExtensionElementImpl(super.firstFragment);
-
- @override
- DartType get extendedType => firstFragment.extendedType;
-
- @override
- ExtensionElementImpl get firstFragment {
- return super.firstFragment as ExtensionElementImpl;
- }
-}
-
-@Deprecated(elementModelDeprecationMsg)
-class AugmentedExtensionTypeElementImpl extends AugmentedInterfaceElementImpl
- implements AugmentedExtensionTypeElement {
- AugmentedExtensionTypeElementImpl(super.firstFragment);
-
- @override
- ExtensionTypeElementImpl get firstFragment {
- return super.firstFragment as ExtensionTypeElementImpl;
- }
-
- @override
- ConstructorElement get primaryConstructor => firstFragment.primaryConstructor;
-
- @override
- FieldElement get representation => firstFragment.representation;
-
- @override
- DartType get typeErasure => firstFragment.typeErasure;
-}
-
-@Deprecated(elementModelDeprecationMsg)
class AugmentedInstanceElementImpl implements AugmentedInstanceElement {
@override
final InstanceElementImpl firstFragment;
@@ -253,21 +194,6 @@
}
}
-@Deprecated(elementModelDeprecationMsg)
-class AugmentedMixinElementImpl extends AugmentedInterfaceElementImpl
- implements AugmentedMixinElement {
- AugmentedMixinElementImpl(super.firstFragment);
-
- @override
- MixinElementImpl get firstFragment {
- return super.firstFragment as MixinElementImpl;
- }
-
- @override
- List<InterfaceType> get superclassConstraints =>
- firstFragment.superclassConstraints;
-}
-
class BindPatternVariableElementImpl extends PatternVariableElementImpl
implements
// ignore: deprecated_member_use_from_same_package,analyzer_use_new_elements
@@ -331,10 +257,7 @@
/// An [InterfaceElementImpl] which is a class.
class ClassElementImpl extends ClassOrMixinElementImpl
- implements
- // ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
- ClassElement,
- ClassFragment {
+ implements ClassFragment {
late ClassElementImpl2 augmentedInternal;
/// Initialize a newly created class element to have the given [name] at the
@@ -347,10 +270,6 @@
super.accessors = accessors;
}
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedClassElement get augmented => AugmentedClassElementImpl(this);
-
@override
set constructors(List<ConstructorElementImpl> constructors) {
assert(!isMixinApplication);
@@ -381,12 +300,6 @@
return constructors.any((c) => !c.isFactory && c.isConst);
}
- @override
- bool get hasNonFinalField {
- return element.hasNonFinalField;
- }
-
- @override
bool get isAbstract {
return hasModifier(Modifier.ABSTRACT);
}
@@ -400,15 +313,12 @@
return hasModifier(Modifier.BASE);
}
- @override
bool get isConstructable => !isSealed && !isAbstract;
- @override
bool get isDartCoreEnum {
return name == 'Enum' && library.isDartCore;
}
- @override
bool get isDartCoreObject {
return name == 'Object' && library.isDartCore;
}
@@ -417,10 +327,8 @@
return name == 'Record' && library.isDartCore;
}
- @override
bool get isExhaustive => isSealed;
- @override
bool get isFinal {
return hasModifier(Modifier.FINAL);
}
@@ -429,7 +337,6 @@
setModifier(Modifier.FINAL, isFinal);
}
- @override
bool get isInterface {
return hasModifier(Modifier.INTERFACE);
}
@@ -438,7 +345,6 @@
setModifier(Modifier.INTERFACE, isInterface);
}
- @override
bool get isMixinApplication {
return hasModifier(Modifier.MIXIN_APPLICATION);
}
@@ -448,7 +354,6 @@
setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication);
}
- @override
bool get isMixinClass {
return hasModifier(Modifier.MIXIN_CLASS);
}
@@ -457,7 +362,6 @@
setModifier(Modifier.MIXIN_CLASS, isMixinClass);
}
- @override
bool get isSealed {
return hasModifier(Modifier.SEALED);
}
@@ -466,7 +370,6 @@
setModifier(Modifier.SEALED, isSealed);
}
- @override
bool get isValidMixin {
var supertype = this.supertype;
if (supertype != null && !supertype.isDartCoreObject) {
@@ -499,46 +402,11 @@
return super.previousFragment as ClassElementImpl?;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitClassElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeClassElement(this);
}
- @Deprecated('Use ClassElement2 instead')
- @override
- bool isExtendableIn(LibraryElement library) {
- if (library == this.library) {
- return true;
- }
- return !isInterface && !isFinal && !isSealed;
- }
-
- @Deprecated('Use ClassElement2 instead')
- @override
- bool isImplementableIn(LibraryElement library) {
- if (library == this.library) {
- return true;
- }
- return !isBase && !isFinal && !isSealed;
- }
-
- @Deprecated('Use ClassElement2 instead')
- @override
- bool isMixableIn(LibraryElement library) {
- if (library == this.library) {
- return true;
- } else if (this.library.featureSet.isEnabled(Feature.class_modifiers)) {
- return isMixinClass && !isInterface && !isFinal && !isSealed;
- }
- return true;
- }
-
@override
void _buildMixinAppConstructors() {
// Do nothing if not a mixin application.
@@ -1000,14 +868,6 @@
required this.lineInfo,
}) : super(null, -1);
- @Deprecated('Use accessibleExtensions2 instead')
- @override
- List<ExtensionElement> get accessibleExtensions {
- return scope.accessibleExtensions
- .map((e) => e.firstFragment as ExtensionElement)
- .toList();
- }
-
@override
List<ExtensionElement2> get accessibleExtensions2 {
return scope.accessibleExtensions;
@@ -1059,7 +919,6 @@
];
}
- @override
List<ClassElementImpl> get classes {
return _classes;
}
@@ -1093,7 +952,6 @@
return this;
}
- @override
List<EnumElementImpl> get enums {
return _enums;
}
@@ -1109,7 +967,6 @@
@override
List<EnumFragment> get enums2 => enums.cast<EnumFragment>();
- @override
List<ExtensionElementImpl> get extensions {
return _extensions;
}
@@ -1127,7 +984,6 @@
List<ExtensionFragment> get extensions2 =>
extensions.cast<ExtensionFragment>();
- @override
List<ExtensionTypeElementImpl> get extensionTypes {
return _extensionTypes;
}
@@ -1245,7 +1101,6 @@
return super.metadata;
}
- @override
List<MixinElementImpl> get mixins {
return _mixins;
}
@@ -1368,50 +1223,11 @@
List<TypeAliasFragment> get typeAliases2 =>
typeAliases.cast<TypeAliasFragment>();
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitCompilationUnitElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeCompilationUnitElement(this);
}
- @override
- ClassElementImpl? getClass(String className) {
- for (var class_ in classes) {
- if (class_.name == className) {
- return class_;
- }
- }
- return null;
- }
-
- @Deprecated(elementModelDeprecationMsg)
- @override
- EnumElement? getEnum(String name) {
- for (var element in enums) {
- if (element.name == name) {
- return element;
- }
- }
- return null;
- }
-
- /// Returns the mixin defined in this compilation unit that has the given
- /// [name], or `null` if this compilation unit does not define a mixin with
- /// the given name.
- @Deprecated(elementModelDeprecationMsg)
- MixinElement? getMixin(String name) {
- for (var mixin in mixins) {
- if (mixin.name == name) {
- return mixin;
- }
- }
- return null;
- }
-
void setLinkedData(Reference reference, ElementLinkedData linkedData) {
this.reference = reference;
reference.element = this;
@@ -1769,11 +1585,6 @@
assert(false);
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitConstructorElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeConstructorElement(this);
@@ -2290,10 +2101,6 @@
@override
Null get previousFragment => null;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => null;
}
/// The synthetic element representing the declaration of the type `dynamic`.
@@ -3416,16 +3223,6 @@
return getDisplayString();
}
- /// Use the given [visitor] to visit all of the children of this element.
- /// There is no guarantee of the order in which the children will be visited.
- @Deprecated('Use Element2 and visitChildren2() instead')
- @override
- void visitChildren(ElementVisitor visitor) {
- for (Element child in children) {
- child.accept(visitor);
- }
- }
-
/// Return flags that denote presence of a few specific annotations.
int _getMetadataFlags() {
var result = _metadataFlags;
@@ -3722,21 +3519,13 @@
abstract class ElementOrMember {}
/// An [InterfaceElementImpl] which is an enum.
-class EnumElementImpl extends InterfaceElementImpl
- implements
- // ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
- EnumElement,
- EnumFragment {
+class EnumElementImpl extends InterfaceElementImpl implements EnumFragment {
late EnumElementImpl2 augmentedInternal;
/// Initialize a newly created class element to have the given [name] at the
/// given [offset] in the file that contains the declaration of this element.
EnumElementImpl(super.name, super.offset);
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedEnumElement get augmented => AugmentedEnumElementImpl(this);
-
List<FieldElementImpl> get constants {
return fields.where((field) => field.isEnumConstant).toList();
}
@@ -3772,12 +3561,6 @@
return null;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitEnumElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeEnumElement(this);
@@ -4116,10 +3899,7 @@
}
class ExtensionElementImpl extends InstanceElementImpl
- implements
- // ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
- ExtensionElement,
- ExtensionFragment {
+ implements ExtensionFragment {
late ExtensionElementImpl2 augmentedInternal;
/// Initialize a newly created extension element to have the given [name] at
@@ -4127,11 +3907,6 @@
/// element.
ExtensionElementImpl(super.name, super.nameOffset);
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedExtensionElement get augmented =>
- AugmentedExtensionElementImpl(this);
-
@Deprecated('Use Element2 instead')
@override
List<Element> get children => [
@@ -4159,7 +3934,6 @@
return augmentedInternal;
}
- @override
TypeImpl get extendedType {
return element.extendedType;
}
@@ -4198,53 +3972,10 @@
@override
DartType get thisType => extendedType;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitExtensionElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeExtensionElement(this);
}
-
- @Deprecated(elementModelDeprecationMsg)
- @override
- FieldElement? getField(String name) {
- for (FieldElement fieldElement in fields) {
- if (name == fieldElement.name) {
- return fieldElement;
- }
- }
- return null;
- }
-
- @override
- PropertyAccessorElementOrMember? getGetter(String getterName) {
- for (var accessor in accessors) {
- if (accessor.isGetter && accessor.name == getterName) {
- return accessor;
- }
- }
- return null;
- }
-
- @override
- MethodElementOrMember? getMethod(String methodName) {
- for (var method in methods) {
- if (method.name == methodName) {
- return method;
- }
- }
- return null;
- }
-
- @Deprecated(elementModelDeprecationMsg)
- @override
- PropertyAccessorElement? getSetter(String setterName) {
- return InterfaceElementImpl.getSetterFromAccessors(setterName, accessors);
- }
}
class ExtensionElementImpl2 extends InstanceElementImpl2
@@ -4284,13 +4015,9 @@
}
class ExtensionTypeElementImpl extends InterfaceElementImpl
- implements
- // ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
- ExtensionTypeElement,
- ExtensionTypeFragment {
+ implements ExtensionTypeFragment {
late ExtensionTypeElementImpl2 augmentedInternal;
- @override
late DartType typeErasure;
/// Whether the element has direct or indirect reference to itself,
@@ -4303,11 +4030,6 @@
ExtensionTypeElementImpl(super.name, super.nameOffset);
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedExtensionTypeElement get augmented =>
- AugmentedExtensionTypeElementImpl(this);
-
@override
ExtensionTypeElementImpl2 get element {
linkedData?.read(this);
@@ -4327,7 +4049,6 @@
ExtensionTypeElementImpl? get previousFragment =>
super.previousFragment as ExtensionTypeElementImpl?;
- @override
ConstructorElementImpl get primaryConstructor {
return constructors.first;
}
@@ -4336,7 +4057,6 @@
ConstructorFragment get primaryConstructor2 =>
primaryConstructor as ConstructorFragment;
- @override
FieldElementImpl get representation {
return fields.first;
}
@@ -4344,12 +4064,6 @@
@override
FieldFragment get representation2 => representation as FieldFragment;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitExtensionTypeElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeExtensionTypeElement(this);
@@ -4539,10 +4253,6 @@
@override
FieldElementImpl? get previousFragment =>
super.previousFragment as FieldElementImpl?;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitFieldElement(this);
}
class FieldElementImpl2 extends PropertyInducingElementImpl2
@@ -4704,11 +4414,6 @@
FieldFormalParameterElementImpl? get previousFragment =>
super.previousFragment as FieldFormalParameterElementImpl?;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitFieldFormalParameterElement(this);
-
@override
FieldFormalParameterElementImpl2 _createElement(
FormalParameterFragment firstFragment) =>
@@ -5458,10 +5163,6 @@
@override
ElementKind get kind => ElementKind.FUNCTION;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitFunctionElement(this);
}
/// Common internal interface shared by elements whose type is a function type.
@@ -5619,12 +5320,6 @@
_type = type;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitGenericFunctionTypeElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeGenericFunctionTypeElement(this);
@@ -7208,10 +6903,6 @@
@override
LabelElementImpl? get previousFragment => null;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitLabelElement(this);
}
class LabelElementImpl2 extends ElementImpl2
@@ -7656,10 +7347,6 @@
return result;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitLibraryElement(this);
-
@override
T? accept2<T>(ElementVisitor2<T> visitor) {
return visitor.visitLibraryElement(this);
@@ -7684,32 +7371,10 @@
}
@override
- ClassElementImpl? getClass(String name) {
- for (var unitElement in units) {
- var element = unitElement.getClass(name);
- if (element != null) {
- return element;
- }
- }
- return null;
- }
-
- @override
ClassElementImpl2? getClass2(String name) {
return _getElementByName(classes, name);
}
- @Deprecated(elementModelDeprecationMsg)
- EnumElement? getEnum(String name) {
- for (var unitElement in units) {
- var element = unitElement.getEnum(name);
- if (element != null) {
- return element;
- }
- }
- return null;
- }
-
@override
EnumElement2? getEnum2(String name) {
return _getElementByName(enums, name);
@@ -7737,17 +7402,6 @@
return _getElementByName(getters, name);
}
- @Deprecated(elementModelDeprecationMsg)
- MixinElement? getMixin(String name) {
- for (var unitElement in units) {
- var element = unitElement.getMixin(name);
- if (element != null) {
- return element;
- }
- }
- return null;
- }
-
@override
MixinElement2? getMixin2(String name) {
return _getElementByName(mixins, name);
@@ -7889,12 +7543,6 @@
@override
CompilationUnitElementImpl get libraryFragment => enclosingElement3;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitLibraryExportElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeExportElement(this);
@@ -7976,12 +7624,6 @@
return Namespace.EMPTY;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitLibraryImportElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeImportElement(this);
@@ -8193,11 +7835,6 @@
@override
LocalVariableElementImpl? get previousFragment => null;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitLocalVariableElement(this);
}
class LocalVariableElementImpl2 extends PromotableElementImpl2
@@ -8731,10 +8368,6 @@
}
return this;
}
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitMethodElement(this);
}
class MethodElementImpl2 extends ExecutableElementImpl2
@@ -8815,10 +8448,7 @@
/// A [ClassElementImpl] representing a mixin declaration.
class MixinElementImpl extends ClassOrMixinElementImpl
- implements
- // ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
- MixinElement,
- MixinFragment {
+ implements MixinFragment {
List<InterfaceTypeImpl> _superclassConstraints = const [];
/// Names of methods, getters, setters, and operators that this mixin
@@ -8832,10 +8462,6 @@
/// given [offset] in the file that contains the declaration of this element.
MixinElementImpl(super.name, super.offset);
- @Deprecated(elementModelDeprecationMsg)
- @override
- AugmentedMixinElement get augmented => AugmentedMixinElementImpl(this);
-
@override
MixinElementImpl2 get element {
linkedData?.read(this);
@@ -8885,25 +8511,10 @@
throw StateError('Attempt to set a supertype for a mixin declaration.');
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitMixinElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeMixinElement(this);
}
-
- @Deprecated('Use MixinElement2 instead')
- @override
- bool isImplementableIn(LibraryElement library) {
- if (library == this.library) {
- return true;
- }
- return !isBase;
- }
}
class MixinElementImpl2 extends InterfaceElementImpl2 implements MixinElement2 {
@@ -9254,11 +8865,6 @@
@override
Source? get source => null;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitMultiplyDefinedElement(this);
-
@override
String getDisplayString({
@Deprecated('Only non-nullable by default mode is supported')
@@ -9331,16 +8937,6 @@
buffer.write("]");
return buffer.toString();
}
-
- /// Use the given [visitor] to visit all of the children of this element.
- /// There is no guarantee of the order in which the children will be visited.
- @Deprecated('Use Element2 and visitChildren2() instead')
- @override
- void visitChildren(ElementVisitor visitor) {
- for (Element child in children) {
- child.accept(visitor);
- }
- }
}
class MultiplyDefinedElementImpl2 extends ElementImpl2
@@ -9552,10 +9148,6 @@
@override
Null get previousFragment => null;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => null;
-
DartType instantiate({
required NullabilitySuffix nullabilitySuffix,
}) {
@@ -9829,11 +9421,6 @@
_typeParameters = typeParameters;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitParameterElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeFormalParameter(this);
@@ -10019,10 +9606,6 @@
@override
CompilationUnitElementImpl get libraryFragment => enclosingUnit;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitPartElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writePartElement(this);
@@ -10167,10 +9750,6 @@
_scope = value;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitPrefixElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writePrefixElement(this);
@@ -10416,11 +9995,6 @@
@override
PropertyInducingFragment? get variable3 => variable2;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitPropertyAccessorElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeExecutableElement(
@@ -11074,11 +10648,6 @@
return null;
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitSuperFormalParameterElement(this);
-
/// Return the index of this super-formal parameter among other super-formals.
int indexIn(ConstructorElementImpl enclosingElement) {
return enclosingElement.parameters
@@ -11272,11 +10841,6 @@
@override
TopLevelVariableElementImpl? get previousFragment =>
super.previousFragment as TopLevelVariableElementImpl?;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitTopLevelVariableElement(this);
}
class TopLevelVariableElementImpl2 extends PropertyInducingElementImpl2
@@ -11492,12 +11056,6 @@
);
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) {
- return visitor.visitTypeAliasElement(this);
- }
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeTypeAliasElement(this);
@@ -11849,11 +11407,6 @@
set variance(shared.Variance? newVariance) => _variance = newVariance;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitTypeParameterElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeTypeParameter(this);
diff --git a/pkg/analyzer/lib/src/dart/element/member.dart b/pkg/analyzer/lib/src/dart/element/member.dart
index 6d93e25..398e5c5 100644
--- a/pkg/analyzer/lib/src/dart/element/member.dart
+++ b/pkg/analyzer/lib/src/dart/element/member.dart
@@ -129,11 +129,6 @@
@override
ConstructorElementImpl2 get _element2 => declaration.asElement2;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitConstructorElement(this);
-
@override
T? accept2<T>(ElementVisitor2<T> visitor) {
return visitor.visitConstructorElement(this);
@@ -492,11 +487,6 @@
@override
bool get isCovariant => declaration.isCovariant;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitFieldFormalParameterElement(this);
}
/// A field element defined in a parameterized type where the values of the type
@@ -644,10 +634,6 @@
@override
FieldElement2 get _element2 => declaration.asElement2;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitFieldElement(this);
-
@override
T? accept2<T>(ElementVisitor2<T> visitor) {
return visitor.visitFieldElement(this);
@@ -1031,16 +1017,6 @@
String toString() {
return getDisplayString();
}
-
- /// Use the given [visitor] to visit all of the children of this element.
- /// There is no guarantee of the order in which the children will be visited.
- @Deprecated('Use Element2 and visitChildren2() instead')
- @override
- void visitChildren(ElementVisitor visitor) {
- for (Element child in children) {
- child.accept(visitor);
- }
- }
}
/// A method element defined in a parameterized type where the values of the
@@ -1110,10 +1086,6 @@
@override
MethodElementImpl2 get _element2 => declaration.asElement2;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) => visitor.visitMethodElement(this);
-
@override
T? accept2<T>(ElementVisitor2<T> visitor) {
return visitor.visitMethodElement(this);
@@ -1282,11 +1254,6 @@
@override
FormalParameterElementImpl get _element2 => declaration.asElement2;
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitParameterElement(this);
-
@override
T? accept2<T>(ElementVisitor2<T> visitor) {
return visitor.visitFormalParameterElement(this);
@@ -1453,11 +1420,6 @@
}
}
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitPropertyAccessorElement(this);
-
@override
void appendTo(ElementDisplayStringBuilder builder) {
builder.writeExecutableElement(
@@ -1610,11 +1572,6 @@
FormalParameterElement? get superConstructorParameter2 =>
superConstructorParameter?.asElement2;
-
- @Deprecated('Use Element2 and accept2() instead')
- @override
- T? accept<T>(ElementVisitor<T> visitor) =>
- visitor.visitSuperFormalParameterElement(this);
}
/// A variable element defined in a parameterized type where the values of the
diff --git a/pkg/analyzer/lib/src/dart/element/type_provider.dart b/pkg/analyzer/lib/src/dart/element/type_provider.dart
index b234d69..a13983e 100644
--- a/pkg/analyzer/lib/src/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_provider.dart
@@ -2,13 +2,11 @@
// 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/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
-import 'package:analyzer/src/utilities/extensions/element.dart';
const Map<String, Set<String>> _nonSubtypableClassMap = {
'dart:async': _nonSubtypableDartAsyncClassNames,
@@ -161,12 +159,6 @@
}) : _coreLibrary = coreLibrary,
_asyncLibrary = asyncLibrary;
- @Deprecated('Use boolElement2 instead')
- @override
- ClassElementImpl get boolElement {
- return boolElement2.asElement;
- }
-
@override
ClassElementImpl2 get boolElement2 {
return _boolElement ??= _getClassElement(_coreLibrary, 'bool');
@@ -197,12 +189,6 @@
);
}
- @Deprecated('Use doubleElement2 instead')
- @override
- ClassElementImpl get doubleElement {
- return doubleElement2.asElement;
- }
-
@override
ClassElementImpl2 get doubleElement2 {
return _doubleElement ??= _getClassElement(_coreLibrary, "double");
@@ -222,12 +208,6 @@
@override
TypeImpl get dynamicType => DynamicTypeImpl.instance;
- @Deprecated('Use enumElement2 instead')
- @override
- ClassElementImpl? get enumElement {
- return enumElement2?.asElement;
- }
-
@override
ClassElementImpl2? get enumElement2 {
if (!_hasEnumElement) {
@@ -272,12 +252,6 @@
);
}
- @Deprecated('Use futureElement2 instead')
- @override
- ClassElementImpl get futureElement {
- return futureElement2.asElement;
- }
-
@override
ClassElementImpl2 get futureElement2 {
return _futureElement ??= _getClassElement(_asyncLibrary, 'Future');
@@ -291,12 +265,6 @@
);
}
- @Deprecated('Use futureOrElement2 instead')
- @override
- ClassElementImpl get futureOrElement {
- return futureOrElement2.asElement;
- }
-
@override
ClassElementImpl2 get futureOrElement2 {
return _futureOrElement ??= _getClassElement(_asyncLibrary, 'FutureOr');
@@ -310,12 +278,6 @@
);
}
- @Deprecated('Use intElement2 instead')
- @override
- ClassElementImpl get intElement {
- return intElement2.asElement;
- }
-
@override
ClassElementImpl2 get intElement2 {
return _intElement ??= _getClassElement(_coreLibrary, "int");
@@ -340,12 +302,6 @@
);
}
- @Deprecated('Use iterableElement2 instead')
- @override
- ClassElementImpl get iterableElement {
- return iterableElement2.asElement;
- }
-
@override
ClassElementImpl2 get iterableElement2 {
return _iterableElement ??= _getClassElement(_coreLibrary, 'Iterable');
@@ -359,23 +315,11 @@
);
}
- @Deprecated('Use listElement2 instead')
- @override
- ClassElementImpl get listElement {
- return listElement2.asElement;
- }
-
@override
ClassElementImpl2 get listElement2 {
return _listElement ??= _getClassElement(_coreLibrary, 'List');
}
- @Deprecated('Use mapElement2 instead')
- @override
- ClassElementImpl get mapElement {
- return mapElement2.asElement;
- }
-
@override
ClassElementImpl2 get mapElement2 {
return _mapElement ??= _getClassElement(_coreLibrary, 'Map');
@@ -392,12 +336,6 @@
@override
NeverTypeImpl get neverType => NeverTypeImpl.instance;
- @Deprecated('Use nullElement2 instead')
- @override
- ClassElementImpl get nullElement {
- return nullElement2.asElement;
- }
-
@override
ClassElementImpl2 get nullElement2 {
return _nullElement ??= _getClassElement(_coreLibrary, 'Null');
@@ -411,12 +349,6 @@
);
}
- @Deprecated('Use numElement2 instead')
- @override
- ClassElementImpl get numElement {
- return numElement2.asElement;
- }
-
@override
ClassElementImpl2 get numElement2 {
return _numElement ??= _getClassElement(_coreLibrary, 'num');
@@ -433,12 +365,6 @@
InterfaceTypeImpl get numTypeQuestion =>
_numTypeQuestion ??= numType.withNullability(NullabilitySuffix.question);
- @Deprecated('Use objectElement2 instead')
- @override
- ClassElementImpl get objectElement {
- return objectElement2.asElement;
- }
-
@override
ClassElementImpl2 get objectElement2 {
return _objectElement ??= _getClassElement(_coreLibrary, 'Object');
@@ -460,12 +386,6 @@
);
}
- @Deprecated('Use recordElement2 instead')
- @override
- ClassElementImpl get recordElement {
- return recordElement2.asElement;
- }
-
@override
ClassElementImpl2 get recordElement2 {
return _recordElement ??= _getClassElement(_coreLibrary, 'Record');
@@ -479,12 +399,6 @@
);
}
- @Deprecated('Use setElement2 instead')
- @override
- ClassElementImpl get setElement {
- return setElement2.asElement;
- }
-
@override
ClassElementImpl2 get setElement2 {
return _setElement ??= _getClassElement(_coreLibrary, 'Set');
@@ -510,23 +424,11 @@
);
}
- @Deprecated('Use streamElement2 instead')
- @override
- ClassElementImpl get streamElement {
- return streamElement2.asElement;
- }
-
@override
ClassElementImpl2 get streamElement2 {
return _streamElement ??= _getClassElement(_asyncLibrary, 'Stream');
}
- @Deprecated('Use stringElement2 instead')
- @override
- ClassElementImpl get stringElement {
- return stringElement2.asElement;
- }
-
@override
ClassElementImpl2 get stringElement2 {
return _stringElement ??= _getClassElement(_coreLibrary, 'String');
@@ -540,12 +442,6 @@
);
}
- @Deprecated('Use symbolElement2 instead')
- @override
- ClassElementImpl get symbolElement {
- return symbolElement2.asElement;
- }
-
@override
ClassElementImpl2 get symbolElement2 {
return _symbolElement ??= _getClassElement(_coreLibrary, 'Symbol');
@@ -590,13 +486,6 @@
);
}
- @Deprecated('Use isNonSubtypableClass2() instead')
- @override
- bool isNonSubtypableClass(InterfaceElement element) {
- element as InterfaceElementImpl;
- return isNonSubtypableClass2(element.element);
- }
-
@override
bool isNonSubtypableClass2(InterfaceElement2 element) {
var name = element.name3;
diff --git a/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart
index ff73d99..63944d2 100644
--- a/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/constructor_reference_resolver.dart
@@ -91,7 +91,8 @@
{required DartType contextType}) {
var constructorName = node.constructorName;
var elementToInfer = _resolver.inferenceHelper.constructorElementToInfer(
- constructorName: constructorName,
+ typeElement: constructorName.type.element2,
+ constructorName: constructorName.name,
definingLibrary: _resolver.definingLibrary,
);
diff --git a/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart
index 1527d9d..f7d8cc9 100644
--- a/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/instance_creation_expression_resolver.dart
@@ -7,7 +7,8 @@
import 'package:analyzer/src/dart/resolver/invocation_inferrer.dart';
import 'package:analyzer/src/generated/resolver.dart';
-/// A resolver for [InstanceCreationExpression] nodes.
+/// A resolver for [InstanceCreationExpression] and
+/// [DotShorthandConstructorInvocation] nodes.
///
/// This resolver is responsible for rewriting a given
/// [InstanceCreationExpression] as a [MethodInvocation] if the parsed
@@ -49,6 +50,48 @@
_resolveInstanceCreationExpression(node, contextType: contextType);
}
+ /// Resolves a [DotShorthandConstructorInvocation] node.
+ void resolveDotShorthand(DotShorthandConstructorInvocationImpl node) {
+ TypeImpl contextType =
+ _resolver.getDotShorthandContext().unwrapTypeSchemaView();
+
+ // The static namespace denoted by `S` is also the namespace denoted by
+ // `FutureOr<S>`.
+ contextType = _resolver.typeSystem.futureOrBase(contextType);
+
+ // TODO(kallentu): Support other context types
+ if (contextType is InterfaceTypeImpl) {
+ _resolveDotShorthandConstructorInvocation(node, contextType: contextType);
+ }
+
+ // TODO(kallentu): Report error.
+ }
+
+ void _resolveDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocationImpl node,
+ {required TypeImpl contextType}) {
+ var whyNotPromotedArguments = <WhyNotPromotedGetter>[];
+ _resolver.elementResolver.visitDotShorthandConstructorInvocation(node);
+ var elementToInfer = _resolver.inferenceHelper.constructorElementToInfer(
+ typeElement: contextType.element3,
+ constructorName: node.constructorName,
+ definingLibrary: _resolver.definingLibrary,
+ );
+ DotShorthandConstructorInvocationInferrer(
+ resolver: _resolver,
+ node: node,
+ argumentList: node.argumentList,
+ contextType: contextType,
+ whyNotPromotedArguments: whyNotPromotedArguments)
+ .resolveInvocation(
+ // TODO(paulberry): eliminate this cast by changing the type of
+ // `ConstructorElementToInfer.asType`.
+ rawType: elementToInfer?.asType as FunctionTypeImpl?);
+ node.recordStaticType(contextType, resolver: _resolver);
+ _resolver.checkForArgumentTypesNotAssignableInList(
+ node.argumentList, whyNotPromotedArguments);
+ }
+
void _resolveInstanceCreationExpression(InstanceCreationExpressionImpl node,
{required TypeImpl contextType}) {
var whyNotPromotedArguments = <WhyNotPromotedGetter>[];
@@ -58,7 +101,8 @@
constructorName = node.constructorName;
_resolver.elementResolver.visitInstanceCreationExpression(node);
var elementToInfer = _resolver.inferenceHelper.constructorElementToInfer(
- constructorName: constructorName,
+ typeElement: constructorName.type.element2,
+ constructorName: node.constructorName.name,
definingLibrary: _resolver.definingLibrary,
);
InstanceCreationInferrer(
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
index eb6e8de..794fb00 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inference_helper.dart
@@ -6,6 +6,7 @@
library;
import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
@@ -86,17 +87,16 @@
/// and the [constructorName] does not have explicit type arguments,
/// return the element and type parameters to infer. Otherwise return `null`.
ConstructorElementToInfer? constructorElementToInfer({
- required ConstructorName constructorName,
+ required Element2? typeElement,
+ required SimpleIdentifierImpl? constructorName,
required LibraryElementImpl definingLibrary,
}) {
List<TypeParameterElementImpl2> typeParameters;
ConstructorElementMixin2? rawElement;
- var typeName = constructorName.type;
- var typeElement = typeName.element2;
if (typeElement is InterfaceElementImpl2) {
typeParameters = typeElement.typeParameters2;
- var constructorIdentifier = constructorName.name;
+ var constructorIdentifier = constructorName;
if (constructorIdentifier == null) {
rawElement = typeElement.unnamedConstructor2;
} else {
@@ -111,7 +111,7 @@
typeParameters = typeElement.typeParameters2;
var aliasedType = typeElement.aliasedType;
if (aliasedType is InterfaceTypeImpl) {
- var constructorIdentifier = constructorName.name;
+ var constructorIdentifier = constructorName;
rawElement = aliasedType.lookUpConstructor2(
constructorIdentifier?.name,
definingLibrary,
diff --git a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
index ef78b1a..db9bc80 100644
--- a/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/invocation_inferrer.dart
@@ -132,6 +132,47 @@
}
/// Specialization of [InvocationInferrer] for performing type inference on AST
+/// nodes of type [DotShorthandConstructorInvocation].
+class DotShorthandConstructorInvocationInferrer
+ extends FullInvocationInferrer<DotShorthandConstructorInvocationImpl> {
+ DotShorthandConstructorInvocationInferrer(
+ {required super.resolver,
+ required super.node,
+ required super.argumentList,
+ required super.contextType,
+ required super.whyNotPromotedArguments})
+ : super._();
+
+ @override
+ SimpleIdentifierImpl get _errorEntity => node.constructorName;
+
+ // TODO(kallentu): Implement const constructors.
+ @override
+ bool get _isConst => false;
+
+ @override
+ bool get _needsTypeArgumentBoundsCheck => true;
+
+ @override
+ TypeArgumentListImpl? get _typeArguments => node.typeArguments;
+
+ @override
+ List<FormalParameterElement>? _storeResult(
+ List<DartType>? typeArgumentTypes, FunctionTypeImpl? invokeType) {
+ if (invokeType != null) {
+ var constructedType = invokeType.returnType;
+ var constructorElement = ConstructorMember.from2(
+ node.element!.baseElement,
+ constructedType as InterfaceType,
+ );
+ node.constructorName.element = constructorElement;
+ return constructorElement.formalParameters;
+ }
+ return null;
+ }
+}
+
+/// Specialization of [InvocationInferrer] for performing type inference on AST
/// nodes of type [DotShorthandInvocation].
class DotShorthandInvocationInferrer
extends InvocationExpressionInferrer<DotShorthandInvocationImpl> {
diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
index 7cbde01..a949f7c 100644
--- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
@@ -202,9 +202,10 @@
/// Resolves the dot shorthand invocation, [node].
///
- /// If [node] is rewritten to be a [FunctionExpressionInvocation] in the
- /// process, then returns that new node. Otherwise, returns `null`.
- FunctionExpressionInvocationImpl? resolveDotShorthand(
+ /// If [node] is rewritten to be a [FunctionExpressionInvocation] or a
+ /// [DotShorthandConstructorInvocation] in the process, then returns that new
+ /// node. Otherwise, returns `null`.
+ RewrittenMethodInvocationImpl? resolveDotShorthand(
DotShorthandInvocationImpl node,
List<WhyNotPromotedGetter> whyNotPromotedArguments) {
_invocation = node;
@@ -1072,9 +1073,10 @@
/// Resolves the dot shorthand invocation, [node], as an method invocation
/// with a type literal target.
///
- /// If [node] is rewritten to be a [FunctionExpressionInvocation] in the
- /// process, then returns that new node. Otherwise, returns `null`.
- FunctionExpressionInvocationImpl? _resolveReceiverTypeLiteralForDotShorthand(
+ /// If [node] is rewritten to be a [FunctionExpressionInvocation] or a
+ /// [DotShorthandConstructorInvocation] in the process, then returns that new
+ /// node. Otherwise, returns `null`.
+ RewrittenMethodInvocationImpl? _resolveReceiverTypeLiteralForDotShorthand(
DotShorthandInvocationImpl node,
InterfaceElement2 receiver,
SimpleIdentifierImpl nameNode,
@@ -1109,8 +1111,23 @@
return null;
}
- // TODO(kallentu): Dot shorthands - Could be constructor, replace with
- // InstanceCreationExpressionImpl.
+ // The dot shorthand is a constructor invocation so we rewrite to a
+ // [DotShorthandConstructorInvocation].
+ if (receiver.getNamedConstructor2(name)
+ case ConstructorElementImpl2 element?
+ when element.isAccessibleIn2(_resolver.definingLibrary)) {
+ nameNode.element = element;
+ var replacement = DotShorthandConstructorInvocationImpl(
+ period: node.period,
+ constructorName: nameNode,
+ typeArguments: node.typeArguments,
+ argumentList: node.argumentList)
+ ..element = element;
+ _resolver.replaceExpression(node, replacement);
+ _resolver.flowAnalysis.transferTestData(node, replacement);
+ return replacement;
+ }
+
_setInvalidTypeResolutionForDotShorthand(node,
whyNotPromotedArguments: whyNotPromotedArguments,
contextType: contextType);
diff --git a/pkg/analyzer/lib/src/fine/library_manifest.dart b/pkg/analyzer/lib/src/fine/library_manifest.dart
index d2c6e59..bed6f3e 100644
--- a/pkg/analyzer/lib/src/fine/library_manifest.dart
+++ b/pkg/analyzer/lib/src/fine/library_manifest.dart
@@ -140,16 +140,11 @@
(typeParameters) {
classItem.declaredMembers.clear();
classItem.inheritedMembers.clear();
- _addInterfaceElementStaticExecutables(
+ _addInterfaceElementExecutables(
encodingContext: encodingContext,
instanceElement: element,
interfaceItem: classItem,
);
- _addInterfaceElementInstanceExecutables(
- encodingContext: encodingContext,
- interfaceElement: element,
- interfaceItem: classItem,
- );
},
);
}
@@ -250,6 +245,36 @@
}
}
+ void _addInstanceElementExecutables({
+ required EncodeContext encodingContext,
+ required InstanceElementImpl2 instanceElement,
+ required InstanceItem instanceItem,
+ }) {
+ for (var getter in instanceElement.getters2) {
+ _addInstanceElementGetter(
+ encodingContext: encodingContext,
+ instanceItem: instanceItem,
+ element: getter,
+ );
+ }
+
+ for (var method in instanceElement.methods2) {
+ _addInstanceElementMethod(
+ encodingContext: encodingContext,
+ instanceItem: instanceItem,
+ element: method,
+ );
+ }
+
+ for (var setter in instanceElement.setters2) {
+ _addInstanceElementSetter(
+ encodingContext: encodingContext,
+ instanceItem: instanceItem,
+ element: setter,
+ );
+ }
+ }
+
void _addInstanceElementGetter({
required EncodeContext encodingContext,
required InstanceItem instanceItem,
@@ -260,6 +285,10 @@
return;
}
+ if (instanceItem.replaceDuplicate(lookupName)) {
+ return;
+ }
+
var item = _getOrBuildElementItem(element, () {
return InstanceItemGetterItem.fromElement(
id: ManifestItemId.generate(),
@@ -270,33 +299,6 @@
instanceItem.declaredMembers[lookupName] = item;
}
- void _addInstanceElementInstanceExecutable({
- required EncodeContext encodingContext,
- required InstanceItem instanceItem,
- required ExecutableElementImpl2 element,
- }) {
- switch (element) {
- case GetterElementImpl():
- _addInstanceElementGetter(
- encodingContext: encodingContext,
- instanceItem: instanceItem,
- element: element,
- );
- case MethodElementImpl2():
- _addInstanceElementMethod(
- encodingContext: encodingContext,
- instanceItem: instanceItem,
- element: element,
- );
- case SetterElementImpl():
- _addInstanceElementSetter(
- encodingContext: encodingContext,
- instanceItem: instanceItem,
- element: element,
- );
- }
- }
-
void _addInstanceElementMethod({
required EncodeContext encodingContext,
required InstanceItem instanceItem,
@@ -307,6 +309,10 @@
return;
}
+ if (instanceItem.replaceDuplicate(lookupName)) {
+ return;
+ }
+
var item = _getOrBuildElementItem(element, () {
return InstanceItemMethodItem.fromElement(
id: ManifestItemId.generate(),
@@ -327,6 +333,10 @@
return;
}
+ if (instanceItem.replaceDuplicate(lookupName)) {
+ return;
+ }
+
var item = _getOrBuildElementItem(element, () {
return InstanceItemSetterItem.fromElement(
id: ManifestItemId.generate(),
@@ -337,42 +347,6 @@
instanceItem.declaredMembers[lookupName] = item;
}
- void _addInstanceElementStaticExecutables({
- required EncodeContext encodingContext,
- required InstanceElementImpl2 instanceElement,
- required InstanceItem instanceItem,
- }) {
- for (var getter in instanceElement.getters2) {
- if (getter.isStatic) {
- _addInstanceElementGetter(
- encodingContext: encodingContext,
- instanceItem: instanceItem,
- element: getter,
- );
- }
- }
-
- for (var method in instanceElement.methods2) {
- if (method.isStatic) {
- _addInstanceElementMethod(
- encodingContext: encodingContext,
- instanceItem: instanceItem,
- element: method,
- );
- }
- }
-
- for (var getter in instanceElement.setters2) {
- if (getter.isStatic) {
- _addInstanceElementSetter(
- encodingContext: encodingContext,
- instanceItem: instanceItem,
- element: getter,
- );
- }
- }
- }
-
void _addInterfaceElementConstructor({
required EncodeContext encodingContext,
required InterfaceItem interfaceItem,
@@ -393,28 +367,7 @@
interfaceItem.declaredMembers[lookupName] = item;
}
- void _addInterfaceElementInstanceExecutables({
- required EncodeContext encodingContext,
- required InterfaceElementImpl2 interfaceElement,
- required InterfaceItem interfaceItem,
- }) {
- var inheritance = interfaceElement.inheritanceManager;
- var map = inheritance.getInterface2(interfaceElement).map2;
- for (var entry in map.entries) {
- var executable = entry.value;
- if (executable.enclosingElement2 == interfaceElement) {
- // SAFETY: declared in the element are always impl.
- executable as ExecutableElementImpl2;
- _addInstanceElementInstanceExecutable(
- encodingContext: encodingContext,
- instanceItem: interfaceItem,
- element: executable,
- );
- }
- }
- }
-
- void _addInterfaceElementStaticExecutables({
+ void _addInterfaceElementExecutables({
required EncodeContext encodingContext,
required InterfaceElementImpl2 instanceElement,
required InterfaceItem interfaceItem,
@@ -434,7 +387,7 @@
);
}
- _addInstanceElementStaticExecutables(
+ _addInstanceElementExecutables(
encodingContext: encodingContext,
instanceElement: instanceElement,
instanceItem: interfaceItem,
@@ -461,16 +414,11 @@
(typeParameters) {
mixinItem.declaredMembers.clear();
mixinItem.inheritedMembers.clear();
- _addInterfaceElementStaticExecutables(
+ _addInterfaceElementExecutables(
encodingContext: encodingContext,
instanceElement: element,
interfaceItem: mixinItem,
);
- _addInterfaceElementInstanceExecutables(
- encodingContext: encodingContext,
- interfaceElement: element,
- interfaceItem: mixinItem,
- );
},
);
}
diff --git a/pkg/analyzer/lib/src/fine/manifest_item.dart b/pkg/analyzer/lib/src/fine/manifest_item.dart
index dcd1bb8..d0772da 100644
--- a/pkg/analyzer/lib/src/fine/manifest_item.dart
+++ b/pkg/analyzer/lib/src/fine/manifest_item.dart
@@ -85,6 +85,17 @@
return declaredMembers[name]?.id;
}
+ /// If there is already a declared member with [name], replace it with a
+ /// fresh instance of [InstanceItemDuplicateItem] and return `true`.
+ /// Otherwise return `false`.
+ bool replaceDuplicate(LookupName name) {
+ if (declaredMembers.containsKey(name)) {
+ declaredMembers[name] = InstanceItemDuplicateItem();
+ return true;
+ }
+ return false;
+ }
+
@override
void write(BufferedSink sink) {
super.write(sink);
@@ -106,6 +117,54 @@
}
}
+/// Placeholder for a name that has duplicate declared member.
+/// It is always given a new ID.
+class InstanceItemDuplicateItem
+ extends InstanceItemMemberItem<ExecutableElementImpl2> {
+ factory InstanceItemDuplicateItem() {
+ return InstanceItemDuplicateItem._(
+ id: ManifestItemId.generate(),
+ metadata: ManifestMetadata(annotations: []),
+ isStatic: false,
+ );
+ }
+
+ factory InstanceItemDuplicateItem.read(SummaryDataReader reader) {
+ return InstanceItemDuplicateItem._(
+ id: ManifestItemId.read(reader),
+ metadata: ManifestMetadata.read(reader),
+ isStatic: reader.readBool(),
+ );
+ }
+
+ InstanceItemDuplicateItem._({
+ required super.id,
+ required super.metadata,
+ required super.isStatic,
+ });
+
+ @override
+ bool match(MatchContext context, ExecutableElementImpl2 element) {
+ super.match(context, element); // we ignore it
+ // Duplicate items don't have any specific information, they are just
+ // a flag, that previously the same name was declared twice. So, there is
+ // no way to meaningfully match them. We always return `false`, and
+ // build a new item (and ID) for this name.
+ //
+ // The reason is that we don't want to prefer first or last duplicated
+ // element, we just wait until there is no error. And once it is fixed,
+ // we will build the actual item, with a new ID, and recompute all uses
+ // once again.
+ return false;
+ }
+
+ @override
+ void write(BufferedSink sink) {
+ sink.writeEnum(_ManifestItemKind2.instanceDuplicate);
+ super.write(sink);
+ }
+}
+
class InstanceItemGetterItem extends InstanceItemMemberItem<GetterElementImpl> {
final ManifestType returnType;
final ManifestNode? constInitializer;
@@ -186,6 +245,8 @@
SummaryDataReader reader) {
var kind = reader.readEnum(_ManifestItemKind2.values);
switch (kind) {
+ case _ManifestItemKind2.instanceDuplicate:
+ return InstanceItemDuplicateItem.read(reader);
case _ManifestItemKind2.instanceGetter:
return InstanceItemGetterItem.read(reader);
case _ManifestItemKind2.instanceMethod:
@@ -770,6 +831,7 @@
}
enum _ManifestItemKind2 {
+ instanceDuplicate,
instanceGetter,
instanceMethod,
instanceSetter,
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index 8e37daa..303a538 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -163,11 +163,23 @@
_resolveAnnotations(node.metadata);
}
+ void visitDotShorthandConstructorInvocation(
+ covariant DotShorthandConstructorInvocationImpl node) {
+ var invokedConstructor = node.element;
+ var argumentList = node.argumentList;
+ var parameters =
+ _resolveArgumentsToFunction(argumentList, invokedConstructor);
+ if (parameters != null) {
+ argumentList.correspondingStaticParameters2 = parameters;
+ }
+ }
+
/// Resolves the dot shorthand invocation, [node].
///
- /// If [node] is rewritten to be a [FunctionExpressionInvocation] in the
- /// process, then returns that new node. Otherwise, returns `null`.
- FunctionExpressionInvocationImpl? visitDotShorthandInvocation(
+ /// If [node] is rewritten to be a [FunctionExpressionInvocation] or a
+ /// [DotShorthandConstructorInvocation] in the process, then returns that new
+ /// node. Otherwise, returns `null`.
+ RewrittenMethodInvocationImpl? visitDotShorthandInvocation(
covariant DotShorthandInvocationImpl node,
{List<WhyNotPromotedGetter>? whyNotPromotedArguments,
required TypeImpl contextType}) {
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 2dc74de..a07cc27 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -2292,20 +2292,28 @@
<Map<SharedTypeView, NonPromotionReason> Function()>[];
node.typeArguments?.accept(this);
- var functionRewrite = elementResolver.visitDotShorthandInvocation(node,
+ var rewrittenExpression = elementResolver.visitDotShorthandInvocation(node,
whyNotPromotedArguments: whyNotPromotedArguments,
contextType: contextType);
- // TODO(kallentu): Handle constructors.
- if (functionRewrite is FunctionExpressionInvocationImpl) {
- _resolveRewrittenFunctionExpressionInvocation(
- functionRewrite, whyNotPromotedArguments,
- contextType: contextType);
+ switch (rewrittenExpression) {
+ case null:
+ // TODO(kallentu): Report an error here.
+ break;
+ case FunctionExpressionInvocationImpl():
+ _resolveRewrittenFunctionExpressionInvocation(
+ rewrittenExpression, whyNotPromotedArguments,
+ contextType: contextType);
+
+ var replacement =
+ insertGenericFunctionInstantiation(node, contextType: contextType);
+ checkForArgumentTypesNotAssignableInList(
+ node.argumentList, whyNotPromotedArguments);
+ _insertImplicitCallReference(replacement, contextType: contextType);
+
+ case DotShorthandConstructorInvocationImpl():
+ _instanceCreationExpressionResolver
+ .resolveDotShorthand(rewrittenExpression);
}
- var replacement =
- insertGenericFunctionInstantiation(node, contextType: contextType);
- checkForArgumentTypesNotAssignableInList(
- node.argumentList, whyNotPromotedArguments);
- _insertImplicitCallReference(replacement, contextType: contextType);
if (node.isDotShorthand) {
popDotShorthandContext();
diff --git a/pkg/analyzer/lib/src/lint/linter_visitor.dart b/pkg/analyzer/lib/src/lint/linter_visitor.dart
index ac77c44..0abe6b7 100644
--- a/pkg/analyzer/lib/src/lint/linter_visitor.dart
+++ b/pkg/analyzer/lib/src/lint/linter_visitor.dart
@@ -259,6 +259,13 @@
}
@override
+ void visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) {
+ _runSubscriptions(node, _registry._forDotShorthandConstructorInvocation);
+ node.visitChildren(this);
+ }
+
+ @override
void visitDotShorthandInvocation(DotShorthandInvocation node) {
_runSubscriptions(node, _registry._forDotShorthandInvocation);
node.visitChildren(this);
@@ -1171,6 +1178,8 @@
final List<_Subscription<DefaultFormalParameter>> _forDefaultFormalParameter =
[];
final List<_Subscription<DoStatement>> _forDoStatement = [];
+ final List<_Subscription<DotShorthandConstructorInvocation>>
+ _forDotShorthandConstructorInvocation = [];
final List<_Subscription<DotShorthandInvocation>> _forDotShorthandInvocation =
[];
final List<_Subscription<DotShorthandPropertyAccess>>
@@ -1503,6 +1512,12 @@
_forDoStatement.add(_Subscription(rule, visitor, _getTimer(rule)));
}
+ void addDotShorthandConstructorInvocation(
+ AnalysisRule rule, AstVisitor visitor) {
+ _forDotShorthandConstructorInvocation
+ .add(_Subscription(rule, visitor, _getTimer(rule)));
+ }
+
void addDotShorthandInvocation(AnalysisRule rule, AstVisitor visitor) {
_forDotShorthandInvocation
.add(_Subscription(rule, visitor, _getTimer(rule)));
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
index 20ab500..64b3d87 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
@@ -270,7 +270,7 @@
operator: Tokens.fromType(operatorType),
rightHandSide: rightHandSide,
);
- node.staticElement = _reader.readElement() as MethodElementOrMember?;
+ node.element = _reader.readElement2() as MethodElement2OrMember?;
node.readElement2 = _reader.readElement2();
node.readType = _reader.readType();
node.writeElement2 = _reader.readElement2();
diff --git a/pkg/analyzer/lib/src/test_utilities/find_node.dart b/pkg/analyzer/lib/src/test_utilities/find_node.dart
index f5f1bf8..4db9a4ec 100644
--- a/pkg/analyzer/lib/src/test_utilities/find_node.dart
+++ b/pkg/analyzer/lib/src/test_utilities/find_node.dart
@@ -59,6 +59,9 @@
ConstructorFieldInitializer get singleConstructorFieldInitializer =>
_single();
+ DotShorthandConstructorInvocation
+ get singleDotShorthandConstructorInvocation => _single();
+
DotShorthandInvocation get singleDotShorthandInvocation => _single();
DotShorthandPropertyAccess get singleDotShorthandPropertyAccess => _single();
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index d069823..d11a5eb 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -9155,8 +9155,7 @@
}
test_dependency_classTypaAlias_constructor_named() async {
- configuration
- .withStreamResolvedUnitResults = false;
+ configuration.withStreamResolvedUnitResults = false;
await _runChangeScenarioTA(
initialA: r'''
class A {
@@ -14986,6 +14985,204 @@
);
}
+ test_manifest_class_getter_toDuplicate_hasInstance_addInstance_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int get foo {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ int get foo {}
+ double get foo {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_getter_toDuplicate_hasInstance_addInstance_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int get foo {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ double get foo {}
+ int get foo {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_getter_toDuplicate_hasInstance_addStatic_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int get foo {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ int get foo {}
+ static double get foo {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_getter_toDuplicate_hasInstance_addStatic_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int get foo {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static double get foo {}
+ int get foo {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_getter_toDuplicate_hasStatic_addStatic_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int get foo {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static int get foo {}
+ static double get foo {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_getter_toDuplicate_hasStatic_addStatic_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int get foo {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static double get foo {}
+ static int get foo {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
test_manifest_class_interfacesAdd() async {
await _runLibraryManifestScenario(
initialCode: r'''
@@ -15741,6 +15938,270 @@
);
}
+ test_manifest_class_method_fromDuplicate_hasInstanceInstance_removeFirst() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+ double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasInstanceInstance_removeSecond() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+ double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasInstanceStatic_removeFirst() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+ static double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasInstanceStatic_removeSecond() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+ static double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasStaticInstance_removeFirst() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+ double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasStaticInstance_removeSecond() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+ double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasStaticStatic_removeFirst() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+ static double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_fromDuplicate_hasStaticStatic_removeSecond() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+ static double foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
test_manifest_class_method_metadata() async {
await _runLibraryManifestScenario(
initialCode: r'''
@@ -16018,6 +16479,270 @@
);
}
+ test_manifest_class_method_toDuplicate_hasInstance_addInstance_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ int foo() {}
+ double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasInstance_addInstance_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ double foo() {}
+ int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasInstance_addStatic_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ int foo() {}
+ static double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasInstance_addStatic_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static double foo() {}
+ int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasStatic_addInstance_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static int foo() {}
+ double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasStatic_addInstance_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ double foo() {}
+ static int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasStatic_addStatic_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static int foo() {}
+ static double foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
+ test_manifest_class_method_toDuplicate_hasStatic_addStatic_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static int foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M1
+''',
+ updatedCode: r'''
+class A {
+ static double foo() {}
+ static int foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo: #M2
+''',
+ );
+ }
+
test_manifest_class_method_typeParameter() async {
configuration.withElementManifests = true;
await _runLibraryManifestScenario(
@@ -16691,6 +17416,204 @@
);
}
+ test_manifest_class_setter_toDuplicate_hasInstance_addInstance_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ set foo(int _) {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M1
+''',
+ updatedCode: r'''
+class A {
+ set foo(int _) {}
+ set foo(double _) {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_class_setter_toDuplicate_hasInstance_addInstance_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ set foo(int _) {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M1
+''',
+ updatedCode: r'''
+class A {
+ set foo(double _) {}
+ set foo(int _) {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_class_setter_toDuplicate_hasInstance_addStatic_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ set foo(int _) {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M1
+''',
+ updatedCode: r'''
+class A {
+ set foo(int _) {}
+ static set foo(double _) {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_class_setter_toDuplicate_hasInstance_addStatic_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ set foo(int _) {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M1
+''',
+ updatedCode: r'''
+class A {
+ static set foo(double _) {}
+ set foo(int _) {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_class_setter_toDuplicate_hasStatic_addStatic_after() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static set foo(int _) {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M1
+''',
+ updatedCode: r'''
+class A {
+ static set foo(int _) {}
+ static set foo(double _) {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_class_setter_toDuplicate_hasStatic_addStatic_before() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ static set foo(int _) {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M1
+''',
+ updatedCode: r'''
+class A {
+ static set foo(double _) {}
+ static set foo(int _) {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ manifest
+ A: #M0
+ declaredMembers
+ foo=: #M2
+''',
+ );
+ }
+
test_manifest_class_setter_valueType() async {
configuration.withElementManifests = true;
await _runLibraryManifestScenario(
diff --git a/pkg/analyzer/test/src/dart/analysis/result_printer.dart b/pkg/analyzer/test/src/dart/analysis/result_printer.dart
index 50c0d13..9d5fb42 100644
--- a/pkg/analyzer/test/src/dart/analysis/result_printer.dart
+++ b/pkg/analyzer/test/src/dart/analysis/result_printer.dart
@@ -808,6 +808,8 @@
if (configuration.withElementManifests) {
sink.withIndent(() {
switch (item) {
+ case InstanceItemDuplicateItem():
+ sink.writelnWithIndent('duplicate');
case InstanceItemGetterItem():
_writeMetadata(item);
_writeNamedType('returnType', item.returnType);
diff --git a/pkg/analyzer/test/src/dart/resolution/constant_test.dart b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
index 9172087..13b3208 100644
--- a/pkg/analyzer/test/src/dart/resolution/constant_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/constant_test.dart
@@ -32,13 +32,14 @@
]);
var aLib = findElement2.import('package:test/a.dart').importedLibrary!;
- var aConstructor = aLib.getClass('A')!.constructors.single;
- var p = aConstructor.parameters.single as DefaultParameterElementImpl;
+ var aConstructor = aLib.getClass2('A')!.constructors2.single;
+ var p = aConstructor.formalParameters.single;
+ var pf = p.firstFragment as DefaultParameterElementImpl;
// To evaluate `const A()` we have to evaluate `{int p}`.
// Even if its value is `null`.
- expect(p.isConstantEvaluated, isTrue);
- expect(p.computeConstantValue()!.isNull, isTrue);
+ expect(pf.isConstantEvaluated, isTrue);
+ expect(pf.computeConstantValue()!.isNull, isTrue);
}
test_constFactoryRedirection_super() async {
diff --git a/pkg/analyzer/test/src/dart/resolution/dot_shorthand_constructor_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/dot_shorthand_constructor_invocation_test.dart
new file mode 100644
index 0000000..dcdc882
--- /dev/null
+++ b/pkg/analyzer/test/src/dart/resolution/dot_shorthand_constructor_invocation_test.dart
@@ -0,0 +1,124 @@
+// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
+// 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:test_reflective_loader/test_reflective_loader.dart';
+
+import 'context_collection_resolution.dart';
+import 'node_text_expectations.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(DotShorthandConstructorInvocationResolutionTest);
+ defineReflectiveTests(UpdateNodeTextExpectations);
+ });
+}
+
+@reflectiveTest
+class DotShorthandConstructorInvocationResolutionTest
+ extends PubPackageResolutionTest {
+ test_constructor_named() async {
+ await assertNoErrorsInCode(r'''
+class C {
+ int x;
+ C.named(this.x);
+}
+
+void main() {
+ C c = .named(1);
+ print(c);
+}
+''');
+
+ var node = findNode.singleDotShorthandConstructorInvocation;
+ assertResolvedNodeText(node, r'''
+DotShorthandConstructorInvocation
+ period: .
+ constructorName: SimpleIdentifier
+ token: named
+ element: <testLibraryFragment>::@class::C::@constructor::named#element
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 1
+ correspondingParameter: <testLibraryFragment>::@class::C::@constructor::named::@parameter::x#element
+ staticType: int
+ rightParenthesis: )
+ staticType: C
+''');
+ }
+
+ test_constructor_named_futureOr() async {
+ await assertNoErrorsInCode(r'''
+import 'dart:async';
+
+class C<T> {
+ T value;
+ C.id(this.value);
+}
+
+void main() async {
+ FutureOr<C?>? c = .id(2);
+ print(c);
+}
+''');
+
+ var node = findNode.singleDotShorthandConstructorInvocation;
+ assertResolvedNodeText(node, r'''
+DotShorthandConstructorInvocation
+ period: .
+ constructorName: SimpleIdentifier
+ token: id
+ element: ConstructorMember
+ baseElement: <testLibraryFragment>::@class::C::@constructor::id#element
+ substitution: {T: dynamic}
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 2
+ correspondingParameter: FieldFormalParameterMember
+ baseElement: <testLibraryFragment>::@class::C::@constructor::id::@parameter::value#element
+ substitution: {T: dynamic}
+ staticType: int
+ rightParenthesis: )
+ staticType: C<dynamic>?
+''');
+ }
+
+ test_new() async {
+ await assertNoErrorsInCode(r'''
+class C {
+ int x;
+ C(this.x);
+}
+
+void main() {
+ C c = .new(1);
+ print(c);
+}
+''');
+
+ var node = findNode.singleDotShorthandConstructorInvocation;
+ assertResolvedNodeText(node, r'''
+DotShorthandConstructorInvocation
+ period: .
+ constructorName: SimpleIdentifier
+ token: new
+ element: <testLibraryFragment>::@class::C::@constructor::new#element
+ staticType: null
+ argumentList: ArgumentList
+ leftParenthesis: (
+ arguments
+ IntegerLiteral
+ literal: 1
+ correspondingParameter: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x#element
+ staticType: int
+ rightParenthesis: )
+ staticType: C
+''');
+ }
+}
diff --git a/pkg/analyzer/test/src/dart/resolution/dot_shorthand_property_access_test.dart b/pkg/analyzer/test/src/dart/resolution/dot_shorthand_property_access_test.dart
index 23029d1..ee35029e 100644
--- a/pkg/analyzer/test/src/dart/resolution/dot_shorthand_property_access_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/dot_shorthand_property_access_test.dart
@@ -43,6 +43,80 @@
''');
}
+ test_const_class() async {
+ await assertNoErrorsInCode('''
+class C {
+ static const C member = const C._(1);
+ final int x;
+ C(this.x);
+ const C._(this.x);
+}
+
+void main() {
+ const C c = .member;
+ print(c);
+}
+''');
+
+ var identifier = findNode.singleDotShorthandPropertyAccess;
+ assertResolvedNodeText(identifier, r'''
+DotShorthandPropertyAccess
+ period: .
+ propertyName: SimpleIdentifier
+ token: member
+ element: <testLibraryFragment>::@class::C::@getter::member#element
+ staticType: C
+ staticType: C
+''');
+ }
+
+ test_const_enum() async {
+ await assertNoErrorsInCode('''
+enum Color { red, green, blue }
+
+void main() {
+ const Color c = .blue;
+ print(c);
+}
+''');
+
+ var identifier = findNode.singleDotShorthandPropertyAccess;
+ assertResolvedNodeText(identifier, r'''
+DotShorthandPropertyAccess
+ period: .
+ propertyName: SimpleIdentifier
+ token: blue
+ element: <testLibraryFragment>::@enum::Color::@getter::blue#element
+ staticType: Color
+ staticType: Color
+''');
+ }
+
+ test_const_extensionType() async {
+ await assertNoErrorsInCode('''
+extension type C(int x) {
+ static const C member = const C._(1);
+ const C._(this.x);
+}
+
+void main() {
+ const C c = .member;
+ print(c);
+}
+''');
+
+ var identifier = findNode.singleDotShorthandPropertyAccess;
+ assertResolvedNodeText(identifier, r'''
+DotShorthandPropertyAccess
+ period: .
+ propertyName: SimpleIdentifier
+ token: member
+ element: <testLibraryFragment>::@extensionType::C::@getter::member#element
+ staticType: C
+ staticType: C
+''');
+ }
+
test_enum_basic() async {
await assertNoErrorsInCode('''
enum C { red }
diff --git a/pkg/analyzer/test/src/dart/resolution/test_all.dart b/pkg/analyzer/test/src/dart/resolution/test_all.dart
index ec3b0ee..0d2875e 100644
--- a/pkg/analyzer/test/src/dart/resolution/test_all.dart
+++ b/pkg/analyzer/test/src/dart/resolution/test_all.dart
@@ -26,6 +26,8 @@
import 'constructor_reference_test.dart' as constructor_reference;
import 'constructor_test.dart' as constructor;
import 'declared_variable_pattern_test.dart' as declared_variable_pattern;
+import 'dot_shorthand_constructor_invocation_test.dart'
+ as dot_shorthand_constructor_invocation;
import 'dot_shorthand_invocation_test.dart' as dot_shorthand_invocation;
import 'dot_shorthand_property_access_test.dart'
as dot_shorthand_property_access;
@@ -142,6 +144,7 @@
constructor_reference.main();
constructor.main();
declared_variable_pattern.main();
+ dot_shorthand_constructor_invocation.main();
dot_shorthand_invocation.main();
dot_shorthand_property_access.main();
enum_resolution.main();
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 08a3653..a37432d 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -466,6 +466,17 @@
}
@override
+ void visitDotShorthandConstructorInvocation(
+ DotShorthandConstructorInvocation node) {
+ _sink.writeln('DotShorthandConstructorInvocation');
+ _sink.withIndent(() {
+ _writeNamedChildEntities(node);
+ _writeParameterElement(node);
+ _writeType('staticType', node.staticType);
+ });
+ }
+
+ @override
void visitDotShorthandInvocation(DotShorthandInvocation node) {
_sink.writeln('DotShorthandInvocation');
_sink.withIndent(() {
diff --git a/pkg/linter/test/rules/all.dart b/pkg/linter/test/rules/all.dart
index 5d611fb9..66a1469 100644
--- a/pkg/linter/test/rules/all.dart
+++ b/pkg/linter/test/rules/all.dart
@@ -12,7 +12,6 @@
import 'always_specify_types_test.dart' as always_specify_types;
import 'always_use_package_imports_test.dart' as always_use_package_imports;
import 'analyzer_public_api_test.dart' as analyzer_public_api;
-import 'analyzer_use_new_elements_test.dart' as analyzer_use_new_elements;
import 'annotate_overrides_test.dart' as annotate_overrides;
import 'annotate_redeclares_test.dart' as annotate_redeclares;
import 'avoid_annotating_with_dynamic_test.dart'
@@ -334,7 +333,6 @@
always_specify_types.main();
always_use_package_imports.main();
analyzer_public_api.main();
- analyzer_use_new_elements.main();
annotate_overrides.main();
annotate_redeclares.main();
avoid_annotating_with_dynamic.main();
diff --git a/pkg/linter/test/rules/analyzer_use_new_elements_test.dart b/pkg/linter/test/rules/analyzer_use_new_elements_test.dart
deleted file mode 100644
index 1113a73..0000000
--- a/pkg/linter/test/rules/analyzer_use_new_elements_test.dart
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
-// 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/file_system/physical_file_system.dart';
-import 'package:analyzer_utilities/package_root.dart';
-import 'package:linter/src/rules/analyzer_use_new_elements.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../rule_test_support.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(AnalyzerUseNewElementsTest);
- });
-}
-
-@reflectiveTest
-class AnalyzerUseNewElementsTest extends LintRuleTest {
- @override
- String get lintRule => AnalyzerUseNewElements.code.name;
-
- @override
- void setUp() {
- super.setUp();
-
- var physicalProvider = PhysicalResourceProvider.INSTANCE;
- var pkgPath = physicalProvider.pathContext.normalize(packageRoot);
- var analyzerLibSource = physicalProvider
- .getFolder(pkgPath)
- .getChildAssumingFolder('analyzer')
- .getChildAssumingFolder('lib');
-
- var analyzerFolder = newFolder('/packages/analyzer');
- analyzerLibSource.copyTo(analyzerFolder);
-
- newPackageConfigJsonFileFromBuilder(
- testPackageRootPath,
- PackageConfigFileBuilder()
- ..add(name: 'analyzer', rootPath: analyzerFolder.path),
- );
- }
-
- test_enablement_optedOut() async {
- await assertDiagnostics(
- r'''
-// ignore_for_file: analyzer_use_new_elements
-import 'package:analyzer/dart/element/element.dart';
-
-ClassElement f() {
- throw 42;
-}
-''',
- [error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 100, 12)],
- );
- }
-
- test_interfaceTypeImpl_element() async {
- await assertDiagnostics(
- r'''
-import 'package:analyzer/src/dart/element/type.dart';
-
-void f(InterfaceTypeImpl type) {
- type.element;
-}
-''',
- [error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 95, 7), lint(95, 7)],
- );
- }
-
- test_methodInvocation_hasFormalParameter() async {
- newFile('$testPackageLibPath/a.dart', r'''
-import 'package:analyzer/dart/element/element.dart';
-
-void foo([List<ClassElement>? elements]) {}
-''');
-
- await assertNoDiagnostics(r'''
-import 'a.dart';
-
-void f() {
- foo();
-}
-''');
- }
-
- test_methodInvocation_hasType() async {
- newFile('$testPackageLibPath/a.dart', r'''
-import 'package:analyzer/dart/element/element.dart';
-
-List<ClassElement> getAllClasses() => [];
-''');
-
- await assertDiagnostics(
- r'''
-import 'a.dart';
-
-void f() {
- getAllClasses();
-}
-''',
- [lint(31, 13)],
- );
- }
-
- test_methodInvocation_inDeprecated() async {
- newFile('$testPackageLibPath/a.dart', r'''
-import 'package:analyzer/dart/element/element.dart';
-
-List<ClassElement> getAllClasses() => [];
-''');
-
- await assertNoDiagnostics(r'''
-import 'a.dart';
-
-@deprecated
-void f() {
- getAllClasses();
-}
-''');
- }
-
- test_methodInvocation_inDeprecated2() async {
- await assertNoDiagnostics(r'''
-import 'package:analyzer/dart/element/element.dart';
-
-@deprecated
-void f(Element element) {
- var foo = element.nonSynthetic;
- print(foo);
-}
-''');
- }
-
- test_namedType() async {
- await assertDiagnostics(
- r'''
-import 'package:analyzer/dart/element/element.dart';
-
-ClassElement f() {
- throw 42;
-}
-''',
- [
- error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 54, 12),
- lint(54, 12),
- ],
- );
- }
-
- test_propertyAccess() async {
- await assertDiagnostics(
- r'''
-import 'package:analyzer/dart/ast/ast.dart';
-
-void f(ClassDeclaration a) {
- a.declaredElement;
-}
-''',
- [
- error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 79, 15),
- lint(79, 15),
- ],
- );
- }
-
- test_propertyAccess_declaredElement_src() async {
- await assertDiagnostics(
- r'''
-import 'package:analyzer/src/dart/ast/ast.dart';
-
-void f(ClassDeclarationImpl a) {
- a.declaredElement;
-}
-''',
- [
- error(HintCode.DEPRECATED_MEMBER_USE_WITH_MESSAGE, 87, 15),
- lint(87, 15),
- ],
- );
- }
-
- test_propertyAccess_nestedType() async {
- newFile('$testPackageLibPath/a.dart', r'''
-import 'package:analyzer/dart/element/element.dart';
-
-List<ClassElement> get allClasses => [];
-''');
-
- await assertDiagnostics(
- r'''
-import 'a.dart';
-
-void f() {
- allClasses;
-}
-''',
- [lint(31, 10)],
- );
- }
-}
diff --git a/tools/VERSION b/tools/VERSION
index 0999d2d..0790b08 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 3
MINOR 9
PATCH 0
-PRERELEASE 30
+PRERELEASE 31
PRERELEASE_PATCH 0