Version 2.14.0-253.0.dev
Merge commit '9ea11a9e2026b5f588b1752ced7c65361afd363a' into 'dev'
diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json
index fe124c6..fb51c91 100644
--- a/.dart_tool/package_config.json
+++ b/.dart_tool/package_config.json
@@ -11,7 +11,7 @@
"constraint, update this by running tools/generate_package_config.dart."
],
"configVersion": 2,
- "generated": "2021-06-15T06:05:26.285605",
+ "generated": "2021-06-24T14:38:26.203286",
"generator": "tools/generate_package_config.dart",
"packages": [
{
@@ -154,7 +154,7 @@
"name": "charcode",
"rootUri": "../third_party/pkg/charcode",
"packageUri": "lib/",
- "languageVersion": "2.10"
+ "languageVersion": "2.12"
},
{
"name": "cli_util",
diff --git a/DEPS b/DEPS
index b9ea344..4450909 100644
--- a/DEPS
+++ b/DEPS
@@ -81,12 +81,12 @@
"boringssl_rev" : "1607f54fed72c6589d560254626909a64124f091",
"browser-compat-data_tag": "v1.0.22",
"browser_launcher_rev": "12ab9f351a44ac803de9bc17bb2180bb312a9dd7",
- "charcode_rev": "bcd8a12c315b7a83390e4865ad847ecd9344cba2",
+ "charcode_rev": "84ea427711e24abf3b832923959caa7dd9a8514b",
"chrome_rev" : "19997",
"cli_util_rev" : "8c504de5deb08fe32ecf51f9662bb37d8c708e57",
"clock_rev" : "a494269254ba978e7ef8f192c5f7fec3fc05b9d3",
"collection_rev": "9967dcd3d7645db6de48d5abfab3018bb0c84236",
- "convert_rev": "a60156c6efd653657c8926b5788219ed609917d7",
+ "convert_rev": "413f591577419d8a8b95d445094a82c926650bd1",
"crypto_rev": "1c8ccc07b83b100216dc6dede767371043385648",
"csslib_rev": "e411d862fd8cc50415c1badf2632e017373b3f47",
"dart2js_info_rev" : "e0acfeb5affdf94c53067e68bd836adf589628fd",
@@ -117,7 +117,7 @@
"http_multi_server_rev": "de1b312164c24a1690b46c6e97bd47eff40c4649",
"http_parser_rev": "7720bfd42a0c096734c5213478fdce92c62f0293",
"http_retry_rev": "845771af7bb5ab38ab740ce4a31f3b0c7680302b",
- "http_rev": "e89b190936d53d0e36148436283e28ba1091b35a",
+ "http_rev": "f93c76fabdb03963303762e3fe16cbdf60799cff",
"http_throttle_tag" : "1.0.2",
"icu_rev" : "81d656878ec611cb0b42d52c82e9dae93920d9ba",
"idl_parser_rev": "5fb1ebf49d235b5a70c9f49047e83b0654031eb7",
@@ -164,7 +164,7 @@
"test_process_tag": "2.0.0",
"term_glyph_rev": "6a0f9b6fb645ba75e7a00a4e20072678327a0347",
"test_reflective_loader_rev": "54e930a11c372683792e22bddad79197728c91ce",
- "test_rev": "cd91c38f184fe7162ecbab8bfa2f15d2a335015d",
+ "test_rev": "eb1155c999b298e641c22b7fea42c8f6c4bcb00b",
"typed_data_tag": "f94fc57b8e8c0e4fe4ff6cfd8290b94af52d3719",
"usage_rev": "e0780cd8b2f8af69a28dc52678ffe8492da27d06",
"vector_math_rev": "0c9f5d68c047813a6dcdeb88ba7a42daddf25025",
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index a064291..a4614c2 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -698,7 +698,10 @@
]
}
common_optimize_on_ldflags = [
+ # Linker GC.
"/OPT:REF",
+ # Identical code folding to reduce size.
+ # Warning: This changes C/C++ semantics of function pointer comparison.
"/OPT:ICF",
]
} else {
@@ -729,7 +732,7 @@
common_optimize_on_ldflags += [
# Specifically tell the linker to perform optimizations.
# See http://lwn.net/Articles/192624/ .
- "-Wl,-O1",
+ "-Wl,-O2",
"-Wl,--gc-sections",
]
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_key_to_constructors.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_key_to_constructors.dart
new file mode 100644
index 0000000..f55c2e9
--- /dev/null
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_key_to_constructors.dart
@@ -0,0 +1,178 @@
+// Copyright (c) 2021, 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:analysis_server/src/services/correction/dart/abstract_producer.dart';
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analyzer/dart/analysis/features.dart';
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer/dart/element/element.dart';
+import 'package:analyzer/dart/element/nullability_suffix.dart';
+import 'package:analyzer/dart/element/type.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:collection/collection.dart';
+
+class AddKeyToConstructors extends CorrectionProducer {
+ @override
+ FixKind get fixKind => DartFixKind.ADD_KEY_TO_CONSTRUCTORS;
+
+ @override
+ Future<void> compute(ChangeBuilder builder) async {
+ var node = this.node;
+ var parent = node.parent;
+ if (node is SimpleIdentifier && parent is ClassDeclaration) {
+ // The lint is on the name of the class when there are no constructors.
+ var targetLocation =
+ utils.prepareNewConstructorLocation(resolvedResult.session, parent);
+ if (targetLocation == null) {
+ return;
+ }
+ var keyType = await _getKeyType();
+ if (keyType == null) {
+ return;
+ }
+ var className = node.name;
+ var canBeConst = _canBeConst(parent.declaredElement);
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addInsertion(targetLocation.offset, (builder) {
+ builder.write(targetLocation.prefix);
+ if (canBeConst) {
+ builder.write('const ');
+ }
+ builder.write(className);
+ builder.write('({');
+ builder.writeType(keyType);
+ builder.write(' key}) : super(key: key);');
+ builder.write(targetLocation.suffix);
+ });
+ });
+ } else if (parent is ConstructorDeclaration) {
+ // The lint is on a constructor when that constructor doesn't have a `key`
+ // parameter.
+ var keyType = await _getKeyType();
+ if (keyType == null) {
+ return;
+ }
+ var parameterList = parent.parameters;
+ var parameters = parameterList.parameters;
+ if (parameters.isEmpty) {
+ // There are no parameters, so add the first parameter.
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addInsertion(parameterList.leftParenthesis.end, (builder) {
+ builder.write('{');
+ builder.writeType(keyType);
+ builder.write(' key}');
+ });
+ _updateSuper(builder, parent);
+ });
+ return;
+ }
+ var leftDelimiter = parameterList.leftDelimiter;
+ if (leftDelimiter == null) {
+ // There are no named parameters, so add the delimiters.
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addInsertion(parameters.last.end, (builder) {
+ builder.write(', {');
+ builder.writeType(keyType);
+ builder.write(' key}');
+ });
+ _updateSuper(builder, parent);
+ });
+ } else if (leftDelimiter.type == TokenType.OPEN_CURLY_BRACKET) {
+ // There are other named parameters, so add the new named parameter.
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addInsertion(leftDelimiter.end, (builder) {
+ builder.writeType(keyType);
+ builder.write(' key, ');
+ });
+ _updateSuper(builder, parent);
+ });
+ }
+ }
+ }
+
+ /// Return `true` if the [classElement] can be instantiated as a `const`.
+ bool _canBeConst(ClassElement? classElement) {
+ var currentClass = classElement;
+ while (currentClass != null && !currentClass.isDartCoreObject) {
+ for (var field in currentClass.fields) {
+ if (!field.isSynthetic && !field.isFinal) {
+ return false;
+ }
+ }
+ currentClass = currentClass.supertype?.element;
+ }
+ return true;
+ }
+
+ /// Return the type for the class `Key`.
+ Future<DartType?> _getKeyType() async {
+ var keyClass = await sessionHelper.getClass(flutter.widgetsUri, 'Key');
+ if (keyClass == null) {
+ return null;
+ }
+ var isNonNullable = resolvedResult.libraryElement.featureSet
+ .isEnabled(Feature.non_nullable);
+ return keyClass.instantiate(
+ typeArguments: const [],
+ nullabilitySuffix:
+ isNonNullable ? NullabilitySuffix.question : NullabilitySuffix.star,
+ );
+ }
+
+ void _updateSuper(
+ DartFileEditBuilder builder, ConstructorDeclaration constructor) {
+ if (constructor.factoryKeyword != null ||
+ constructor.redirectedConstructor != null) {
+ // Can't have a super constructor invocation.
+ // TODO(brianwilkerson) Consider extending the redirected constructor to
+ // also take a key, or finding the constructor invocation in the body of
+ // the factory and updating it.
+ return;
+ }
+ var initializers = constructor.initializers;
+ SuperConstructorInvocation? invocation;
+ for (var initializer in initializers) {
+ if (initializer is SuperConstructorInvocation) {
+ invocation = initializer;
+ } else if (initializer is RedirectingConstructorInvocation) {
+ return;
+ }
+ }
+ if (invocation == null) {
+ // There is no super constructor invocation, so add one.
+ if (initializers.isEmpty) {
+ builder.addSimpleInsertion(
+ constructor.parameters.rightParenthesis.end, ' : super(key: key)');
+ } else {
+ builder.addSimpleInsertion(initializers.last.end, ', super(key: key)');
+ }
+ } else {
+ // There is a super constructor invocation, so update it.
+ var argumentList = invocation.argumentList;
+ var arguments = argumentList.arguments;
+ var existing = arguments.firstWhereOrNull((argument) =>
+ argument is NamedExpression && argument.name.label.name == 'key');
+ if (existing == null) {
+ // There is no 'key' argument, so add it.
+ if (arguments.isEmpty) {
+ builder.addSimpleInsertion(
+ argumentList.leftParenthesis.end, 'key: key');
+ } else {
+ // This case should never happen because 'key' is the only parameter
+ // in the constructors for both `StatelessWidget` and `StatefulWidget`.
+ builder.addSimpleInsertion(
+ argumentList.leftParenthesis.end, 'key: key, ');
+ }
+ } else {
+ // There is an existing 'key' argument, so we leave it alone.
+ }
+ }
+ }
+
+ /// Return an instance of this class. Used as a tear-off in `FixProcessor`.
+ static AddKeyToConstructors newInstance() => AddKeyToConstructors();
+}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_case_clauses.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_case_clauses.dart
index 434f13d..16a7d03 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_case_clauses.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_case_clauses.dart
@@ -55,10 +55,14 @@
var statementIndent = utils.getLinePrefix(statement.offset);
var singleIndent = utils.getIndent(1);
+ var location = utils.newCaseClauseAtEndLocation(statement);
final enumName_final = enumName;
await builder.addDartFileEdit(file, (builder) {
- builder.addInsertion(utils.getLineThis(statement.end), (builder) {
+ // TODO(brianwilkerson) Consider inserting the names in order into the
+ // switch statement.
+ builder.addInsertion(location.offset, (builder) {
+ builder.write(location.prefix);
for (var constantName in enumConstantNames) {
builder.write(statementIndent);
builder.write(singleIndent);
@@ -76,6 +80,7 @@
builder.write(singleIndent);
builder.writeln('break;');
}
+ builder.write(location.suffix);
});
});
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_like_case_clauses.dart b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_like_case_clauses.dart
index b3e308f..c383fc4 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_like_case_clauses.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/add_missing_enum_like_case_clauses.dart
@@ -32,26 +32,34 @@
var missingNames = _constantNames(classElement)
..removeWhere((e) => caseNames.contains(e));
missingNames.sort();
- var firstCase = node.members[0];
- var caseIndent = utils.getLinePrefix(firstCase.offset);
- var statementIndent = utils.getLinePrefix(firstCase.statements[0].offset);
- // TODO(brianwilkerson) Consider inserting the names in order into the
- // switch statement.
+
+ var statementIndent = utils.getLinePrefix(node.offset);
+ var singleIndent = utils.getIndent(1);
+ var location = utils.newCaseClauseAtEndLocation(node);
+
await builder.addDartFileEdit(file, (builder) {
- builder.addInsertion(node.members.last.end, (builder) {
+ // TODO(brianwilkerson) Consider inserting the names in order into the
+ // switch statement.
+ builder.addInsertion(location.offset, (builder) {
+ builder.write(location.prefix);
for (var name in missingNames) {
- builder.writeln();
- builder.write(caseIndent);
+ builder.write(statementIndent);
+ builder.write(singleIndent);
builder.write('case ');
builder.write(className);
builder.write('.');
builder.write(name);
builder.writeln(':');
builder.write(statementIndent);
+ builder.write(singleIndent);
+ builder.write(singleIndent);
builder.writeln('// TODO: Handle this case.');
builder.write(statementIndent);
- builder.write('break;');
+ builder.write(singleIndent);
+ builder.write(singleIndent);
+ builder.writeln('break;');
}
+ builder.write(location.suffix);
});
});
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
index 5b1977e..9241efc 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_file.dart
@@ -41,10 +41,16 @@
} else if (parent is PartDirective) {
var source = parent.uriSource;
if (source != null) {
- var libName = resolvedResult.libraryElement.name;
+ var pathContext = resourceProvider.pathContext;
+ var relativePath = pathContext.relative(
+ resolvedResult.libraryElement.source.fullName,
+ from: pathContext.dirname(source.fullName));
+
+ // URIs always use forward slashes regardless of platform.
+ var relativeUri = pathContext.split(relativePath).join('/');
+
await builder.addDartFileEdit(source.fullName, (builder) {
- // TODO(brianwilkerson) Consider using the URI rather than name.
- builder.addSimpleInsertion(0, 'part of $libName;$eol$eol');
+ builder.addSimpleInsertion(0, "part of '$relativeUri';$eol$eol");
});
_fileName = source.shortName;
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_string_escape.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_string_escape.dart
new file mode 100644
index 0000000..6e4d118
--- /dev/null
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_unnecessary_string_escape.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2021, 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:analysis_server/src/services/correction/dart/abstract_producer.dart';
+import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analyzer/source/source_range.dart';
+import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+
+class RemoveUnnecessaryStringEscape extends CorrectionProducer {
+ @override
+ bool get canBeAppliedInBulk => true;
+
+ @override
+ bool get canBeAppliedToFile => true;
+
+ @override
+ FixKind get fixKind => DartFixKind.REMOVE_UNNECESSARY_STRING_ESCAPE;
+
+ @override
+ FixKind get multiFixKind =>
+ DartFixKind.REMOVE_UNNECESSARY_STRING_ESCAPE_MULTI;
+
+ @override
+ Future<void> compute(ChangeBuilder builder) async {
+ var offset = diagnostic?.problemMessage.offset;
+ if (offset == null) {
+ return;
+ }
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addDeletion(SourceRange(offset, 1));
+ });
+ }
+
+ /// Return an instance of this class. Used as a tear-off in `FixProcessor`.
+ static RemoveUnnecessaryStringEscape newInstance() =>
+ RemoveUnnecessaryStringEscape();
+}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 2c2cf47..c162055 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -179,6 +179,10 @@
'dart.fix.add.fieldFormalParameters',
70,
'Add final field formal parameters');
+ static const ADD_KEY_TO_CONSTRUCTORS = FixKind(
+ 'dart.fix.add.keyToConstructors',
+ DartFixKindPriority.DEFAULT,
+ "Add 'key' to constructors");
static const ADD_LATE = FixKind(
'dart.fix.add.late', DartFixKindPriority.DEFAULT, "Add 'late' modifier");
static const ADD_MISSING_ENUM_CASE_CLAUSES = FixKind(
@@ -687,6 +691,14 @@
'dart.fix.remove.unnecessaryParentheses.multi',
DartFixKindPriority.IN_FILE,
'Remove all unnecessary parentheses in file');
+ static const REMOVE_UNNECESSARY_STRING_ESCAPE = FixKind(
+ 'dart.fix.remove.unnecessaryStringEscape',
+ DartFixKindPriority.DEFAULT,
+ "Remove unnecessary '\\' in string");
+ static const REMOVE_UNNECESSARY_STRING_ESCAPE_MULTI = FixKind(
+ 'dart.fix.remove.unnecessaryStringEscape.multi',
+ DartFixKindPriority.DEFAULT,
+ "Remove unnecessary '\\' in strings in file");
static const REMOVE_UNNECESSARY_STRING_INTERPOLATION = FixKind(
'dart.fix.remove.unnecessaryStringInterpolation',
DartFixKindPriority.DEFAULT,
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index de4a8fc..624d70a 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -14,6 +14,7 @@
import 'package:analysis_server/src/services/correction/dart/add_diagnostic_property_reference.dart';
import 'package:analysis_server/src/services/correction/dart/add_explicit_cast.dart';
import 'package:analysis_server/src/services/correction/dart/add_field_formal_parameters.dart';
+import 'package:analysis_server/src/services/correction/dart/add_key_to_constructors.dart';
import 'package:analysis_server/src/services/correction/dart/add_late.dart';
import 'package:analysis_server/src/services/correction/dart/add_missing_enum_case_clauses.dart';
import 'package:analysis_server/src/services/correction/dart/add_missing_enum_like_case_clauses.dart';
@@ -118,6 +119,7 @@
import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_cast.dart';
import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_new.dart';
import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_parentheses.dart';
+import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_string_escape.dart';
import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_string_interpolation.dart';
import 'package:analysis_server/src/services/correction/dart/remove_unused.dart';
import 'package:analysis_server/src/services/correction/dart/remove_unused_catch_clause.dart';
@@ -547,6 +549,9 @@
LintNames.unnecessary_parenthesis: [
RemoveUnnecessaryParentheses.newInstance,
],
+ LintNames.unnecessary_string_escapes: [
+ RemoveUnnecessaryStringEscape.newInstance,
+ ],
LintNames.unnecessary_string_interpolations: [
RemoveUnnecessaryStringInterpolation.newInstance,
],
@@ -560,6 +565,9 @@
LintNames.use_function_type_syntax_for_parameters: [
ConvertToGenericFunctionSyntax.newInstance,
],
+ LintNames.use_key_in_widget_constructors: [
+ AddKeyToConstructors.newInstance,
+ ],
LintNames.use_rethrow_when_possible: [
UseRethrow.newInstance,
],
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 31d0876..7259632 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -970,6 +970,21 @@
return TokenUtils.getTokens(trimmedText, unit.featureSet).isEmpty;
}
+ ClassMemberLocation newCaseClauseAtEndLocation(SwitchStatement statement) {
+ var blockStartLine = getLineThis(statement.leftBracket.offset);
+ var blockEndLine = getLineThis(statement.end);
+ var offset = blockEndLine;
+ var prefix = '';
+ var suffix = '';
+ if (blockStartLine == blockEndLine) {
+ // The switch body is on a single line.
+ prefix = endOfLine;
+ offset = statement.leftBracket.end;
+ suffix = getLinePrefix(statement.offset);
+ }
+ return ClassMemberLocation(prefix, offset, suffix);
+ }
+
ClassMemberLocation? prepareNewClassMemberLocation(
CompilationUnitMember declaration,
bool Function(ClassMember existingMember) shouldSkip) {
diff --git a/pkg/analysis_server/lib/src/services/linter/lint_names.dart b/pkg/analysis_server/lib/src/services/linter/lint_names.dart
index e091101..0bf6b44 100644
--- a/pkg/analysis_server/lib/src/services/linter/lint_names.dart
+++ b/pkg/analysis_server/lib/src/services/linter/lint_names.dart
@@ -108,6 +108,7 @@
'unnecessary_nullable_for_final_variable_declarations';
static const String unnecessary_overrides = 'unnecessary_overrides';
static const String unnecessary_parenthesis = 'unnecessary_parenthesis';
+ static const String unnecessary_string_escapes = 'unnecessary_string_escapes';
static const String unnecessary_string_interpolations =
'unnecessary_string_interpolations';
static const String unnecessary_this = 'unnecessary_this';
@@ -115,5 +116,7 @@
'use_full_hex_values_for_flutter_colors';
static const String use_function_type_syntax_for_parameters =
'use_function_type_syntax_for_parameters';
+ static const String use_key_in_widget_constructors =
+ 'use_key_in_widget_constructors';
static const String use_rethrow_when_possible = 'use_rethrow_when_possible';
}
diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart
index cbc0c97..927950d 100644
--- a/pkg/analysis_server/test/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/analysis/get_hover_test.dart
@@ -104,7 +104,7 @@
/// my doc
A.named() {}
}
-main() {
+void f() {
new A.named();
}
''');
@@ -134,7 +134,7 @@
class A {
const A(int i);
}
-main() {
+void f() {
const a = A(0);
}
''');
@@ -159,7 +159,7 @@
addTestFile('''
library my.library;
class A {}
-main() {
+void f() {
var a = A();
}
''');
@@ -185,7 +185,7 @@
library my.library;
class A {
}
-main() {
+void f() {
new A();
}
''');
@@ -210,7 +210,7 @@
addTestFile('''
library my.library;
class A<T> {}
-main() {
+void f() {
new A<String>();
}
''');
@@ -254,10 +254,10 @@
* doc aaa
* doc bbb
*/
-main() {
+void f() {
}
''');
- var hover = await prepareHover('main() {');
+ var hover = await prepareHover('f() {');
expect(hover.dartdoc, '''doc aaa\ndoc bbb''');
}
@@ -330,10 +330,10 @@
addTestFile('''
/// doc aaa
/// doc bbb
-main() {
+void f() {
}
''');
- var hover = await prepareHover('main() {');
+ var hover = await prepareHover('f() {');
expect(hover.dartdoc, '''doc aaa\ndoc bbb''');
}
@@ -410,7 +410,7 @@
/// doc bbb
String fff;
}
-main(A a) {
+void f(A a) {
print(a.fff);
}
''');
@@ -429,7 +429,7 @@
Future<void> test_integerLiteral() async {
addTestFile('''
-main() {
+void f() {
foo(123);
}
foo(Object myParameter) {}
@@ -454,7 +454,7 @@
Future<void> test_integerLiteral_promoted() async {
addTestFile('''
-main() {
+void f() {
foo(123);
}
foo(double myParameter) {}
@@ -524,7 +524,7 @@
Future<void> test_localVariable_reference_withPropagatedType() async {
addTestFile('''
library my.library;
-main() {
+void f() {
var vvv = 123;
print(vvv);
}
@@ -574,7 +574,7 @@
List<String> mmm(int a, String b) {
}
}
-main(A a) {
+void f(A a) {
a.mmm(42, 'foo');
}
''');
@@ -601,7 +601,7 @@
@deprecated
static void test() {}
}
-main() {
+void f() {
A.test();
}
''');
@@ -675,7 +675,7 @@
Future<void> test_noHoverInfo() async {
addTestFile('''
library my.library;
-main() {
+void f() {
// nothing
}
''');
@@ -688,7 +688,7 @@
addTestFile('''
int? f(double? a) => null;
-main() {
+void f() {
f(null);
}
''');
@@ -704,7 +704,7 @@
final int fff;
A({this.fff});
}
-main() {
+void f() {
new A(fff: 42);
}
''');
@@ -757,7 +757,7 @@
final int fff;
A({this.fff});
}
-main() {
+void f() {
new A(fff: 42);
}
''');
@@ -779,7 +779,7 @@
/// setting
set foo(int x) {}
}
-main(A a) {
+void f(A a) {
a.foo = 123;
}
''');
@@ -797,7 +797,7 @@
int get foo => 42;
set foo(int x) {}
}
-main(A a) {
+void f(A a) {
a.foo = 123;
}
''');
@@ -821,7 +821,7 @@
int get foo => 42;
set foo(int x) {}
}
-main(B b) {
+void f(B b) {
b.foo = 123;
}
''');
@@ -843,7 +843,7 @@
int get foo => 42;
set foo(int x) {}
}
-main(B b) {
+void f(B b) {
b.foo = 123;
}
''');
@@ -864,7 +864,7 @@
class B extends A {
set foo(int x) {}
}
-main(B b) {
+void f(B b) {
b.foo = 123;
}
''');
diff --git a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
index 89296f2..5a156c0 100644
--- a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
@@ -27,11 +27,11 @@
class AAA {
const AAA(a, b, c);
}
-@AAA(1, 2, 3) main() {}
+@AAA(1, 2, 3) void f() {}
''');
await prepareHighlights();
assertHasRegion(HighlightRegionType.ANNOTATION, '@AAA(', '@AAA('.length);
- assertHasRegion(HighlightRegionType.ANNOTATION, ') main', ')'.length);
+ assertHasRegion(HighlightRegionType.ANNOTATION, ') void f', ')'.length);
}
Future<void> test_ANNOTATION_hasTypeArguments_hasArguments() async {
@@ -52,7 +52,7 @@
Future<void> test_ANNOTATION_noArguments() async {
addTestFile('''
const AAA = 42;
-@AAA main() {}
+@AAA void f() {}
''');
await prepareHighlights();
assertHasRegion(HighlightRegionType.ANNOTATION, '@AAA');
@@ -62,7 +62,7 @@
addTestFile('''
abstract class A {};
abstract class B = Object with A;
-main() {
+void f() {
var abstract = 42;
}''');
await prepareHighlights();
@@ -74,7 +74,7 @@
Future<void> test_BUILT_IN_as() async {
addTestFile('''
import 'dart:math' as math;
-main() {
+void f() {
p as int;
var as = 42;
}''');
@@ -88,7 +88,7 @@
addTestFile('''
fa() async {}
fb() async* {}
-main() {
+void f() {
bool async = false;
}
''');
@@ -100,7 +100,7 @@
Future<void> test_BUILT_IN_await() async {
addTestFile('''
-main() async {
+void f() async {
await 42;
await for (var item in []) {
print(item);
@@ -151,7 +151,7 @@
Future<void> test_BUILT_IN_deferred() async {
addTestFile('''
import 'dart:math' deferred as math;
-main() {
+void f() {
var deferred = 42;
}''');
await prepareHighlights();
@@ -162,7 +162,7 @@
Future<void> test_BUILT_IN_export() async {
addTestFile('''
export "dart:math";
-main() {
+void f() {
var export = 42;
}''');
await prepareHighlights();
@@ -176,13 +176,13 @@
external A();
external aaa();
}
-external main() {
+external f() {
var external = 42;
}''');
await prepareHighlights();
assertHasRegion(HighlightRegionType.BUILT_IN, 'external A()');
assertHasRegion(HighlightRegionType.BUILT_IN, 'external aaa()');
- assertHasRegion(HighlightRegionType.BUILT_IN, 'external main()');
+ assertHasRegion(HighlightRegionType.BUILT_IN, 'external f()');
assertNoRegion(HighlightRegionType.BUILT_IN, 'external = 42');
}
@@ -192,7 +192,7 @@
A.named();
factory A() => A.named();
}
-main() {
+void f() {
var factory = 42;
}''');
await prepareHighlights();
@@ -218,7 +218,7 @@
class A {
get bbb => 2;
}
-main() {
+void f() {
var get = 42;
}''');
await prepareHighlights();
@@ -230,7 +230,7 @@
Future<void> test_BUILT_IN_hide() async {
addTestFile('''
import 'foo.dart' hide Foo;
-main() {
+void f() {
var hide = 42;
}''');
await prepareHighlights();
@@ -242,7 +242,7 @@
addTestFile('''
class A {}
class B implements A {}
-main() {
+void f() {
var implements = 42;
}''');
await prepareHighlights();
@@ -253,7 +253,7 @@
Future<void> test_BUILT_IN_import() async {
addTestFile('''
import "foo.dart";
-main() {
+void f() {
var import = 42;
}''');
await prepareHighlights();
@@ -264,7 +264,7 @@
Future<void> test_BUILT_IN_library() async {
addTestFile('''
library lib;
-main() {
+void f() {
var library = 42;
}''');
await prepareHighlights();
@@ -278,7 +278,7 @@
class B {
bbb() native "bbb_native";
}
-main() {
+void f() {
var native = 42;
}''');
await prepareHighlights();
@@ -298,7 +298,7 @@
Future<void> test_BUILT_IN_on_inTry() async {
addTestFile('''
-main() {
+void f() {
try {
} on int catch (e) {
}
@@ -314,7 +314,7 @@
class A {
operator +(x) => null;
}
-main() {
+void f() {
var operator = 42;
}''');
await prepareHighlights();
@@ -325,7 +325,7 @@
Future<void> test_BUILT_IN_part() async {
addTestFile('''
part "my_part.dart";
-main() {
+void f() {
var part = 42;
}''');
newFile('/project/bin/my_part.dart', content: 'part of lib;');
@@ -337,7 +337,7 @@
Future<void> test_BUILT_IN_partOf() async {
addTestFile('''
part of lib;
-main() {
+void f() {
var part = 1;
var of = 2;
}''');
@@ -354,7 +354,7 @@
class A
set bbb(x) {}
}
-main() {
+void f() {
var set = 42;
}''');
await prepareHighlights();
@@ -366,7 +366,7 @@
Future<void> test_BUILT_IN_show() async {
addTestFile('''
import 'foo.dart' show Foo;
-main() {
+void f() {
var show = 42;
}''');
await prepareHighlights();
@@ -380,7 +380,7 @@
static aaa;
static bbb() {}
}
-main() {
+void f() {
var static = 42;
}''');
await prepareHighlights();
@@ -393,7 +393,7 @@
addTestFile('''
fa() sync {}
fb() sync* {}
-main() {
+void f() {
bool sync = false;
}
''');
@@ -408,7 +408,7 @@
typedef A();
typedef B = void Function();
typedef C = List<int>;
-main() {
+void f() {
var typedef = 42;
}''');
await prepareHighlights();
@@ -420,7 +420,7 @@
Future<void> test_BUILT_IN_yield() async {
addTestFile('''
-main() async* {
+void f() async* {
yield 42;
}
''');
@@ -430,7 +430,7 @@
Future<void> test_BUILT_IN_yieldStar() async {
addTestFile('''
-main() async* {
+void f() async* {
yield* [];
}
''');
@@ -469,7 +469,7 @@
/**
* documentation comment
*/
-void main() {
+void f() {
// end-of-line comment
my_function(1);
}
@@ -490,7 +490,7 @@
AAA() {}
AAA.name(p) {}
}
-main() {
+void f() {
new AAA<int>();
new AAA<int>.name(42);
}
@@ -510,7 +510,7 @@
AAA() {}
AAA.name(p) {}
}
-main() {
+void f() {
AAA<int>();
AAA<int>.name(42);
}
@@ -577,7 +577,7 @@
Future<void> test_DYNAMIC_LOCAL_VARIABLE() async {
addTestFile('''
f() {}
-main(p) {
+void f(p) {
var v = f();
v;
}
@@ -590,7 +590,7 @@
Future<void> test_DYNAMIC_PARAMETER() async {
addTestFile('''
-main(p) {
+void f(p) {
print(p);
}
''');
@@ -626,7 +626,7 @@
Future<void> test_ENUM_CONSTANT() async {
addTestFile('''
enum MyEnum {AAA, BBB}
-main() {
+void f() {
print(MyEnum.AAA);
print(MyEnum.BBB);
}
@@ -658,7 +658,7 @@
get bbb => null;
static get ccc => null;
}
-main(A a) {
+void f(A a) {
aaa;
a.bbb;
A.ccc;
@@ -678,7 +678,7 @@
Future<void> test_IDENTIFIER_DEFAULT() async {
addTestFile('''
-main() {
+void f() {
aaa = 42;
bbb(84);
CCC ccc;
@@ -693,7 +693,7 @@
Future<void> test_IMPORT_PREFIX() async {
addTestFile('''
import 'dart:math' as ma;
-main() {
+void f() {
ma.max(1, 2);
}
''');
@@ -709,7 +709,7 @@
int bbb = 2;
A([this.bbb = 3]);
}
-main(A a) {
+void f(A a) {
a.aaa = 4;
a.bbb = 5;
}
@@ -736,7 +736,7 @@
Future<void> test_KEYWORD() async {
addTestFile('''
-main() {
+void f() {
assert(true);
for (;;) break;
switch (0) {
@@ -924,16 +924,16 @@
Future<void> test_KEYWORD_void() async {
addTestFile('''
-void main() {
+void f() {
}
''');
await prepareHighlights();
- assertHasRegion(HighlightRegionType.KEYWORD, 'void main()');
+ assertHasRegion(HighlightRegionType.KEYWORD, 'void f()');
}
Future<void> test_LABEL() async {
addTestFile('''
-main() {
+void f() {
myLabel:
while (true) {
break myLabel;
@@ -1002,7 +1002,7 @@
Future<void> test_LOCAL_FUNCTION() async {
addTestFile('''
-main() {
+void f() {
fff() {}
fff();
fff;
@@ -1016,7 +1016,7 @@
Future<void> test_LOCAL_VARIABLE() async {
addTestFile('''
-main() {
+void f() {
int vvv = 0;
vvv;
vvv = 1;
@@ -1034,7 +1034,7 @@
aaa() {}
static bbb() {}
}
-main(A a) {
+void f(A a) {
a.aaa();
a.aaa;
A.bbb();
@@ -1053,7 +1053,7 @@
Future<void> test_METHOD_bestType() async {
addTestFile('''
-main(p) {
+void f(p) {
if (p is List) {
p.add(null);
}
@@ -1065,7 +1065,7 @@
Future<void> test_PARAMETER() async {
addTestFile('''
-main(int p) {
+void f(int p) {
p;
p = 42;
}
@@ -1082,7 +1082,7 @@
final int aaa;
C({this.aaa, int bbb});
}
-main() {
+void f() {
new C(aaa: 1, bbb: 2);
}
''');
@@ -1100,7 +1100,7 @@
set bbb(x) {}
static set ccc(x) {}
}
-main(A a) {
+void f(A a) {
aaa = 1;
a.bbb = 2;
A.ccc = 3;
@@ -1122,7 +1122,7 @@
static get bbb => null;
static set ccc(x) {}
}
-main() {
+void f() {
A.aaa = 2;
A.bbb;
A.ccc = 3;
@@ -1138,7 +1138,7 @@
Future<void> test_TOP_LEVEL_FUNCTION() async {
addTestFile('''
fff(p) {}
-main() {
+void f() {
fff(42);
}
''');
@@ -1154,7 +1154,7 @@
const V1 = 1;
var V2 = 2;
@V1 // annotation
-main() {
+void f() {
print(V1);
V2 = 3;
}
@@ -1192,13 +1192,13 @@
Future<void> test_TYPE_NAME_DYNAMIC() async {
addTestFile('''
-dynamic main() {
+dynamic f() {
dynamic = 42;
}
''');
await prepareHighlights();
- assertHasRegion(HighlightRegionType.TYPE_NAME_DYNAMIC, 'dynamic main()');
- assertNoRegion(HighlightRegionType.IDENTIFIER_DEFAULT, 'dynamic main()');
+ assertHasRegion(HighlightRegionType.TYPE_NAME_DYNAMIC, 'dynamic f()');
+ assertNoRegion(HighlightRegionType.IDENTIFIER_DEFAULT, 'dynamic f()');
assertNoRegion(HighlightRegionType.TYPE_NAME_DYNAMIC, 'dynamic = 42');
}
@@ -1219,7 +1219,7 @@
Future<void>
test_UNRESOLVED_INSTANCE_MEMBER_REFERENCE_dynamicVarTarget() async {
addTestFile('''
-main(p) {
+void f(p) {
p.aaa;
p.aaa++;
p.aaa += 0;
@@ -1244,7 +1244,7 @@
test_UNRESOLVED_INSTANCE_MEMBER_REFERENCE_nonDynamicTarget() async {
addTestFile('''
import 'dart:math' as math;
-main(String str) {
+void f(String str) {
new Object().aaa();
math.bbb();
str.ccc();
diff --git a/pkg/analysis_server/test/client/completion_driver_test.dart b/pkg/analysis_server/test/client/completion_driver_test.dart
index 9aac2e6..13d807c 100644
--- a/pkg/analysis_server/test/client/completion_driver_test.dart
+++ b/pkg/analysis_server/test/client/completion_driver_test.dart
@@ -225,7 +225,7 @@
void a2() { }
}
-void main() {
+void f() {
var a = A();
a.^
}
@@ -264,7 +264,7 @@
await addTestFile('''
import 'a.dart';
-void main() {
+void f() {
^
}
''');
@@ -292,7 +292,7 @@
await addTestFile('''
import 'a.dart';
-void main() {
+void f() {
^
}
''');
@@ -320,7 +320,7 @@
await addTestFile('''
import 'a.dart';
-void main() {
+void f() {
^
}
''');
@@ -346,7 +346,7 @@
await addTestFile('''
import 'a.dart';
import 'b.dart';
-void main() {
+void f() {
^
}
''');
@@ -370,7 +370,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -413,7 +413,7 @@
''');
await addTestFile('''
-void main() {
+void m() {
^
}
''');
@@ -429,7 +429,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -448,7 +448,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -464,7 +464,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -482,7 +482,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -504,7 +504,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -524,7 +524,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -540,7 +540,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -555,7 +555,7 @@
''');
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -584,7 +584,7 @@
await addTestFile('''
import 'a.dart';
-void main(List<String> args) {
+void f(List<String> args) {
var a = A.b(o: ^)
}
''');
@@ -610,7 +610,7 @@
await addTestFile('''
import 'a.dart';
-void main(List<String> args) {
+void f(List<String> args) {
var a = ^
}
''');
@@ -651,7 +651,7 @@
Future<void> test_sdk_lib_future_isNotDuplicated() async {
await addTestFile('''
-void main() {
+void f() {
^
}
''');
@@ -669,7 +669,7 @@
Future<void> test_sdk_lib_suggestions() async {
await addTestFile('''
-void main() {
+void f() {
^
}
''');
diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart
index 8ace81f..894f8d4 100644
--- a/pkg/analysis_server/test/completion_test.dart
+++ b/pkg/analysis_server/test/completion_test.dart
@@ -219,11 +219,11 @@
class L{var k;void.!1}''', <String>['1-k']);
buildTests('testCommentSnippets044', '''
-class List{}class XXX {XXX.fisk();}main() {main(); new !1}}''',
+class List{}class XXX {XXX.fisk();}void f() {f(); new !1}}''',
<String>['1+List', '1+XXX.fisk']);
buildTests('testCommentSnippets045', '''
-class List{}class XXX {XXX.fisk();}main() {main(); !1}}''',
+class List{}class XXX {XXX.fisk();}void f() {f(); !1}}''',
<String>['1+List', '1+XXX.fisk']);
buildTests('testCommentSnippets047', '''
@@ -541,11 +541,11 @@
p(x)=>0;var E;f(q)=>!1p(!2E);''', <String>['1+p', '2+E']);
buildTests('testCommentSnippets076', '''
-class Map<K,V>{}class List<E>{}class int{}main() {var m=new Map<Lis!1t<Map<int,in!2t>>,List<!3int>>();}''',
+class Map<K,V>{}class List<E>{}class int{}void f() {var m=new Map<Lis!1t<Map<int,in!2t>>,List<!3int>>();}''',
<String>['1+List', '2+int', '3+int']);
buildTests('testCommentSnippets076a', '''
-class Map<K,V>{}class List<E>{}class int{}main() {var m=new Map<Lis!1t<Map<int,in!2t>>,List<!3>>();}''',
+class Map<K,V>{}class List<E>{}class int{}void f() {var m=new Map<Lis!1t<Map<int,in!2t>>,List<!3>>();}''',
<String>['1+List', '2+int', '3+int']);
buildTests('testCommentSnippets077', '''
@@ -571,15 +571,15 @@
]);
buildTests('testCommentSnippets078', '''
-class Map{static from()=>null;clear(){}}void main() { Map.!1 }''',
+class Map{static from()=>null;clear(){}}void f() { Map.!1 }''',
<String>['1+from', '1-clear']); // static method, instance method
buildTests('testCommentSnippets079', '''
-class Map{static from()=>null;clear(){}}void main() { Map s; s.!1 }''',
+class Map{static from()=>null;clear(){}}void f() { Map s; s.!1 }''',
<String>['1-from', '1+clear']); // static method, instance method
buildTests('testCommentSnippets080', '''
-class RuntimeError{var message;}void main() { RuntimeError.!1 }''',
+class RuntimeError{var message;}void f() { RuntimeError.!1 }''',
<String>['1-message']); // field
buildTests(
@@ -595,20 +595,20 @@
'''
class HttpRequest {}
class HttpResponse {}
- main() {
+ void f() {
var v = (HttpRequest req, HttpResp!1)
}''',
<String>['1+HttpResponse'],
failingTests: '1');
buildTests('testCommentSnippets083', '''
-main() {(.!1)}''', <String>['1-toString']);
+void f() {(.!1)}''', <String>['1-toString']);
buildTests('testCommentSnippets083a', '''
-main() { .!1 }''', <String>['1-toString']);
+void f() { .!1 }''', <String>['1-toString']);
buildTests('testCommentSnippets083b', '''
-main() { null.!1 }''', <String>['1+toString']);
+void f() { null.!1 }''', <String>['1+toString']);
buildTests('testCommentSnippets085', '''
class List{}class Map{}class Z extends List with !1Ma!2p {}''',
@@ -710,7 +710,7 @@
}",
",
@AAA(!1)
-main() {
+void f() {
}''',
<String>[
'1+AAA' /*":" + ProposalKind.ARGUMENT_LIST*/,
@@ -727,7 +727,7 @@
const bar = null;
@foo!1
-main() {
+void f() {
}''',
<String>['1+fooConst', '1-fooNotConst', '1-bar'],
failingTests: '1');
@@ -738,7 +738,7 @@
const AAA.nnn(int c, int d);
}
@AAA!1
-main() {
+void f() {
}''', <String>[
'1+AAA' /*":" + ProposalKind.CONSTRUCTOR*/,
'1+AAA.nnn' /*":" + ProposalKind.CONSTRUCTOR*/
@@ -760,7 +760,7 @@
static Enum FOO = new Enum();
}
f(Enum e) {}
-main() {
+void f() {
f(En!1);
}''', <String>['1+Enum']);
@@ -768,12 +768,12 @@
class A {
test() {}
}
-main(A a) {
+void f(A a) {
a.test(!1);
}''', <String>['1-test']);
buildTests('testCompletion_as_asIdentifierPrefix', '''
-main(p) {
+void f(p) {
var asVisible;
var v = as!1;
}''', <String>['1+asVisible']);
@@ -783,13 +783,13 @@
var asVisible;
}
-main(A p) {
+void f(A p) {
var v = p.as!1;
}''', <String>['1+asVisible']);
buildTests('testCompletion_as_incompleteStatement', '''
class MyClass {}
-main(p) {
+void f(p) {
var justSomeVar;
var v = p as !1
}''', <String>['1+MyClass', '1-justSomeVar']);
@@ -800,9 +800,9 @@
}
-main(A a) {
+void f(A a) {
a..!1 aaa();
-}''', <String>['1+aaa', '1-main']);
+}''', <String>['1+aaa', '1-f']);
buildTests('testCompletion_combinator_afterComma', '''
import 'dart:math' show cos, !1;''',
@@ -842,7 +842,7 @@
A.first(int p);
A.second(double p);
}
-main() {
+void f() {
new A.first(!1);
}''',
<String>['1+A.first', '1-A.second'],
@@ -852,7 +852,7 @@
'testCompletion_constructorArguments_whenPrefixedType',
'''
import 'dart:math' as m;
-main() {
+void f() {
new m.Random(!1);
}''',
<String>['1+Random:ARGUMENT_LIST'],
@@ -963,19 +963,19 @@
]);
buildTests('testCompletion_double_inFractionPart', '''
-main() {
+void f() {
1.0!1
-}''', <String>['1-abs', '1-main']);
+}''', <String>['1-abs', '1-f']);
buildTests('testCompletion_enum', '''
enum MyEnum {A, B, C}
-main() {
+void f() {
MyEnum.!1;
}''', <String>['1+values', '1+A', '1+B', '1+C']);
buildTests('testCompletion_exactPrefix_hasHigherRelevance', '''
var STR;
-main(p) {
+void f(p) {
var str;
str!1;
STR!2;
@@ -1028,7 +1028,7 @@
'testCompletion_functionTypeParameter_namedArgument',
'''
typedef FFF(a, b, {x1, x2, y});
-main(FFF fff) {
+void f(FFF fff) {
fff(1, 2, !1)!2;
}''',
<String>['1+x1', '2-x2'],
@@ -1066,7 +1066,7 @@
'''
class A { a() => null; x() => null}
class B { a() => null; y() => null}
-void main() {
+void f() {
var x;
var c;
if(c) {
@@ -1084,7 +1084,7 @@
'''
class A { a() => null; x() => null}
class B { a() => null; y() => null}
-void main() {
+void f() {
var x;
var c;
if(c) {
@@ -1146,7 +1146,7 @@
buildTests('testCompletion_incompleteClosure_parameterType', '''
f1(cb(String s)) {}
f2(String s) {}
-main() {
+void f() {
f1((Str!1));
f2((Str!2));
}''', <String>['1+String', '1-bool', '2+String', '2-bool']);
@@ -1154,7 +1154,7 @@
buildTests(
'testCompletion_inPeriodPeriod',
'''
-main(String str) {
+void f(String str) {
1 < str.!1.length;
1 + str.!2.length;
1 + 2 * str.!3.length;
@@ -1166,7 +1166,7 @@
buildTests('testCompletion_instanceCreation_unresolved', '''
class A {
}
-main() {
+void f() {
new NoSuchClass(!1);
new A.noSuchConstructor(!2);
}''', <String>['1+int', '2+int']);
@@ -1181,7 +1181,7 @@
buildTests('testCompletion_is', '''
class MyClass {}
-main(p) {
+void f(p) {
var isVariable;
if (p is MyCla!1) {}
var v1 = p is MyCla!2;
@@ -1200,7 +1200,7 @@
buildTests(
'testCompletion_is_asIdentifierStart',
'''
-main(p) {
+void f(p) {
var isVisible;
var v1 = is!1;
var v2 = is!2
@@ -1213,21 +1213,21 @@
var isVisible;
}
-main(A p) {
+void f(A p) {
var v1 = p.is!1;
var v2 = p.is!2
}''', <String>['1+isVisible', '2+isVisible']);
buildTests('testCompletion_is_incompleteStatement1', '''
class MyClass {}
-main(p) {
+void f(p) {
var justSomeVar;
var v = p is !1
}''', <String>['1+MyClass', '1-justSomeVar']);
buildTests('testCompletion_is_incompleteStatement2', '''
class MyClass {}
-main(p) {
+void f(p) {
var isVariable;
var v = p is!1
}''', <String>['1+is', '1-isVariable']);
@@ -1236,7 +1236,7 @@
class Foo { int input = 7; mth() { if (in!1) {}}}''', <String>['1+input']);
buildTests('testCompletion_keyword_syntheticIdentifier', '''
-main() {
+void f() {
var caseVar;
var otherVar;
var v = case!1
@@ -1257,7 +1257,7 @@
static myFuncDouble(double p) {}
}
bar(p) {}
-main(p) {
+void f(p) {
foo( Functions.!1; );
}''',
<String>[
@@ -1274,7 +1274,7 @@
static myFunc(int p) {}
}
bar(p) {}
-main(p) {
+void f(p) {
foo( (int p) => Functions.!1; );
}''',
<String>[
@@ -1288,7 +1288,7 @@
class Functions {
static int myFunc(int p) {}
}
-main(p) {
+void f(p) {
foo(Functions.!1);
}''', <String>[
'1+myFunc' /*":" + ProposalKind.METHOD*/,
@@ -1296,19 +1296,19 @@
]);
buildTests('testCompletion_namedArgument_alreadyUsed', '''
-func({foo}) {} main() { func(foo: 0, fo!1); }''', <String>['1-foo']);
+func({foo}) {} void f() { func(foo: 0, fo!1); }''', <String>['1-foo']);
buildTests(
'testCompletion_namedArgument_constructor',
'''
-class A {A({foo, bar}) {}} main() { new A(fo!1); }''',
+class A {A({foo, bar}) {}} void f() { new A(fo!1); }''',
<String>['1+foo', '1-bar'],
failingTests: '1');
buildTests(
'testCompletion_namedArgument_empty',
'''
-func({foo, bar}) {} main() { func(!1); }''',
+func({foo, bar}) {} void f() { func(!1); }''',
<String>[
'1+foo' /*":" + ProposalKind.NAMED_ARGUMENT*/,
'1-foo' /*":" + ProposalKind.OPTIONAL_ARGUMENT*/
@@ -1318,15 +1318,15 @@
buildTests(
'testCompletion_namedArgument_function',
'''
-func({foo, bar}) {} main() { func(fo!1); }''',
+func({foo, bar}) {} void f() { func(fo!1); }''',
<String>['1+foo', '1-bar'],
failingTests: '1');
buildTests('testCompletion_namedArgument_notNamed', '''
-func([foo]) {} main() { func(fo!1); }''', <String>['1-foo']);
+func([foo]) {} void f() { func(fo!1); }''', <String>['1-foo']);
buildTests('testCompletion_namedArgument_unresolvedFunction', '''
-main() { func(fo!1); }''', <String>['1-foo']);
+void f() { func(fo!1); }''', <String>['1-foo']);
buildTests('testCompletion_newMemberType1', '''
class Collection{}class List extends Collection{}class Foo { !1 }''',
@@ -1350,7 +1350,7 @@
class A {
A([foo, bar]);
}
-main() {
+void f() {
new A(!1);
new A(0, !2);
}''',
@@ -1367,7 +1367,7 @@
'testCompletion_positionalArgument_function',
'''
func([foo, bar]) {}
-main() {
+void f() {
func(!1);
func(0, !2);
}''',
@@ -1389,7 +1389,7 @@
class B extends A {
bar() {}
}
-main() {
+void f() {
A v = new B();
v.!1
}''',
@@ -1405,7 +1405,7 @@
A._c();
A.c();
}
-main() {
+void f() {
new A.!1
}''', <String>['1+_c', '1+c']);
@@ -1414,7 +1414,7 @@
_m() {}
m() {}
}
-main(A a) {
+void f(A a) {
a.!1
}''', <String>['1+_m', '1+m']);
@@ -1423,7 +1423,7 @@
static int FIELD;
int field;
}
-main() {
+void f() {
A.!1
}''', <String>['1+FIELD', '1-field']);
@@ -1436,7 +1436,7 @@
static int FIELD_B;
static int methodB() {}
}
-main() {
+void f() {
B.!1;
}''', <String>['1+FIELD_B', '1-FIELD_A', '1+methodB', '1-methodA']);
@@ -1451,7 +1451,7 @@
class C extends A {
int fieldC;
}
-main(B b, C c) {
+void f(B b, C c) {
b.a.!1;
c.!2;
}''', <String>['1-FIELD', '1+fieldA', '2+fieldC', '2+fieldA']);
@@ -1477,7 +1477,7 @@
class B extends A {
var fb;
mb() {}
- main() {
+ void f() {
super.!1
}
}''', <String>['1+fa', '1-fb', '1+ma', '1-mb']);
@@ -1535,7 +1535,7 @@
buildTests(
'testCompletion_this_bad_inTopLevelFunction',
'''
-main() {
+void f() {
this.!1;
}''',
<String>['1-toString'],
@@ -1565,7 +1565,7 @@
class B extends A {
var fb;
mb() {}
- main() {
+ void m() {
this.!1
}
}''', <String>['1+fa', '1+fb', '1+ma', '1+mb']);
@@ -1584,7 +1584,7 @@
buildTests('test_export_ignoreIfThisLibraryExports', '''
export 'dart:math';
libFunction() {};
-main() {
+void f() {
!1
}''', <String>['1-cos', '1+libFunction']);
@@ -1597,7 +1597,7 @@
'test_export_showIfImportLibraryWithExport',
'''
import 'lib.dart' as p;
-main() {
+void f() {
p.!1
}''',
<String>['1+cos', '1-sin', '1+libFunction'],
@@ -1606,13 +1606,13 @@
buildTests('test_importPrefix_hideCombinator', '''
import 'dart:math' as math hide pi;
-main() {
+void f() {
math.!1
}''', <String>['1-pi', '1+ln10']);
buildTests('test_importPrefix_showCombinator', '''
import 'dart:math' as math show pi;
-main() {
+void f() {
math.!1
}''', <String>['1+pi', '1-ln10']);
@@ -1628,7 +1628,7 @@
'test_memberOfPrivateClass_otherLibrary',
'''
import 'lib.dart';
-main(A a) {
+void f(A a) {
a.!1
}''',
<String>['1+foo'],
@@ -1646,7 +1646,7 @@
'test_noPrivateElement_otherLibrary_constructor',
'''
import 'lib.dart';
-main() {
+void f() {
new A.!1
}''',
<String>['1-_c', '1+c'],
@@ -1663,7 +1663,7 @@
'test_noPrivateElement_otherLibrary_member',
'''
import 'lib.dart';
- main(A a) {
+ void f(A a) {
a.!1
}''',
<String>['1-_f', '1+f'],
@@ -1680,7 +1680,7 @@
'testLibrary001',
'''
import 'firth.dart';
-main() {
+void f() {
throw new Seria!1lizationException();}''',
<String>['1+SerializationException'],
extraFiles: sources,
@@ -1717,8 +1717,10 @@
// TODO Enable after type propagation is implemented. Not yet.
// TODO Include corelib analysis
- buildTests('testLibrary005',
- '''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''', <String>['1+abs'],
+ buildTests(
+ 'testLibrary005',
+ '''var PHI;void f(){PHI=5.3;PHI.abs().!1 Object x;}''',
+ <String>['1+abs'],
failingTests: '1');
// Exercise import and export handling.
@@ -1747,7 +1749,7 @@
'''
import 'imp1.dart';
import 'imp2.dart';
-main() {!1
+void f() {!1
i1();
i2();
e1a();
@@ -1768,7 +1770,7 @@
'testLibrary007',
'''
import 'l1.dart';
-main() {
+void f() {
var x = l!1
var y = _!2
}''',
@@ -2146,7 +2148,7 @@
buildTests('test019', '''
var truefalse = 0;
var falsetrue = 1;
-main() {
+void f() {
var foo = true!1
}''', <String>['1+true', '1+truefalse', '1-falsetrue']);
@@ -2325,7 +2327,7 @@
a.field.!1
}
}
-main() {
+void f() {
A1 a = new A1();
a.field.!2
}''',
@@ -2337,7 +2339,7 @@
'''
class HttpServer{}
class HttpClient{}
-main() {
+void f() {
new HtS!1
}''',
<String>['1+HttpServer', '1-HttpClient'],
diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart
index da117aa..d9c733a 100644
--- a/pkg/analysis_server/test/domain_completion_test.dart
+++ b/pkg/analysis_server/test/domain_completion_test.dart
@@ -28,7 +28,7 @@
Future<void> test_ArgumentList_constructor_named_fieldFormalParam() async {
// https://github.com/dart-lang/sdk/issues/31023
addTestFile('''
-main() { new A(field: ^);}
+void f() { new A(field: ^);}
class A {
A({this.field: -1}) {}
}
@@ -37,7 +37,7 @@
}
Future<void> test_ArgumentList_constructor_named_param_label() async {
- addTestFile('main() { new A(^);}'
+ addTestFile('void f() { new A(^);}'
'class A { A({one, two}) {} }');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'one: ');
@@ -46,7 +46,7 @@
}
Future<void> test_ArgumentList_factory_named_param_label() async {
- addTestFile('main() { new A(^);}'
+ addTestFile('void f() { new A(^);}'
'class A { factory A({one, two}) => throw 0; }');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'one: ');
@@ -123,7 +123,7 @@
}
Future<void> test_ArgumentList_imported_function_named_param() async {
- addTestFile('main() { int.parse("16", ^);}');
+ addTestFile('void f() { int.parse("16", ^);}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ');
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ');
@@ -131,7 +131,7 @@
}
Future<void> test_ArgumentList_imported_function_named_param1() async {
- addTestFile('main() { foo(o^);} foo({one, two}) {}');
+ addTestFile('void f() { foo(o^);} foo({one, two}) {}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'one: ');
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'two: ');
@@ -139,7 +139,7 @@
}
Future<void> test_ArgumentList_imported_function_named_param2() async {
- addTestFile('mainx() {A a = new A(); a.foo(one: 7, ^);}'
+ addTestFile('void f() {A a = new A(); a.foo(one: 7, ^);}'
'class A { foo({one, two}) {} }');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'two: ');
@@ -147,7 +147,7 @@
}
Future<void> test_ArgumentList_imported_function_named_param_label1() async {
- addTestFile('main() { int.parse("16", r^: 16);}');
+ addTestFile('void f() { int.parse("16", r^: 16);}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix');
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError');
@@ -155,7 +155,7 @@
}
Future<void> test_ArgumentList_imported_function_named_param_label3() async {
- addTestFile('main() { int.parse("16", ^: 16);}');
+ addTestFile('void f() { int.parse("16", ^: 16);}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ');
assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ');
@@ -163,7 +163,7 @@
}
Future<void> test_catch() async {
- addTestFile('main() {try {} ^}');
+ addTestFile('void f() {try {} ^}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.KEYWORD, 'on');
assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch');
@@ -172,7 +172,7 @@
}
Future<void> test_catch2() async {
- addTestFile('main() {try {} on Foo {} ^}');
+ addTestFile('void f() {try {} on Foo {} ^}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.KEYWORD, 'on');
assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch');
@@ -186,7 +186,7 @@
}
Future<void> test_catch3() async {
- addTestFile('main() {try {} catch (e) {} finally {} ^}');
+ addTestFile('void f() {try {} catch (e) {} finally {} ^}');
await getSuggestions();
assertNoResult('on');
assertNoResult('catch');
@@ -200,7 +200,7 @@
}
Future<void> test_catch4() async {
- addTestFile('main() {try {} finally {} ^}');
+ addTestFile('void f() {try {} finally {} ^}');
await getSuggestions();
assertNoResult('on');
assertNoResult('catch');
@@ -214,7 +214,7 @@
}
Future<void> test_catch5() async {
- addTestFile('main() {try {} ^ finally {}}');
+ addTestFile('void f() {try {} ^ finally {}}');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.KEYWORD, 'on');
assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch');
@@ -300,7 +300,7 @@
newFile(filePath, content: 'library libA;');
addTestFile('''
import "$incompleteImportText^.dart";
- main() {}''');
+ void f() {}''');
return getSuggestions().then((_) {
expect(replacementOffset,
equals(completionOffset - incompleteImportText.length));
@@ -313,7 +313,7 @@
Future<void> test_imports() {
addTestFile('''
import 'dart:html';
- main() {^}
+ void f() {^}
''');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
@@ -464,7 +464,7 @@
Future<void> test_imports_prefixed() {
addTestFile('''
import 'dart:html' as foo;
- main() {^}
+ void f() {^}
''');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
@@ -480,7 +480,7 @@
Future<void> test_imports_prefixed2() {
addTestFile('''
import 'dart:html' as foo;
- main() {foo.^}
+ void f() {foo.^}
''');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
@@ -492,7 +492,7 @@
Future<void> test_inComment_block_beforeNode() async {
addTestFile('''
- main(aaa, bbb) {
+ void f(aaa, bbb) {
/* text ^ */
print(42);
}
@@ -517,7 +517,7 @@
Future<void> test_inComment_endOfLine_beforeNode() async {
addTestFile('''
- main(aaa, bbb) {
+ void f(aaa, bbb) {
// text ^
print(42);
}
@@ -528,7 +528,7 @@
Future<void> test_inComment_endOfLine_beforeToken() async {
addTestFile('''
- main(aaa, bbb) {
+ void f(aaa, bbb) {
// text ^
}
''');
@@ -539,7 +539,7 @@
Future<void> test_inDartDoc1() async {
addTestFile('''
/// ^
- main(aaa, bbb) {}
+ void f(aaa, bbb) {}
''');
await getSuggestions();
expect(suggestions, isEmpty);
@@ -548,7 +548,7 @@
Future<void> test_inDartDoc2() async {
addTestFile('''
/// Some text^
- main(aaa, bbb) {}
+ void f(aaa, bbb) {}
''');
await getSuggestions();
expect(suggestions, isEmpty);
@@ -580,10 +580,10 @@
part "${toUriStr('/testA.dart')}";
import "dart:math";
/// The [^]
- main(aaa, bbb) {}
+ void f(aaa, bbb) {}
''');
await getSuggestions();
- assertHasResult(CompletionSuggestionKind.IDENTIFIER, 'main');
+ assertHasResult(CompletionSuggestionKind.IDENTIFIER, 'f');
assertHasResult(CompletionSuggestionKind.IDENTIFIER, 'foo');
assertHasResult(CompletionSuggestionKind.IDENTIFIER, 'min');
}
@@ -591,10 +591,10 @@
Future<void> test_inDartDoc_reference2() async {
addTestFile('''
/// The [m^]
- main(aaa, bbb) {}
+ void f(aaa, bbb) {}
''');
await getSuggestions();
- assertHasResult(CompletionSuggestionKind.IDENTIFIER, 'main');
+ assertHasResult(CompletionSuggestionKind.IDENTIFIER, 'f');
}
Future<void> test_inDartDoc_reference3() async {
@@ -652,7 +652,7 @@
}
Future<void> test_invocation() {
- addTestFile('class A {b() {}} main() {A a; a.^}');
+ addTestFile('class A {b() {}} void f() {A a; a.^}');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
expect(replacementLength, equals(0));
@@ -661,7 +661,7 @@
}
Future<void> test_invocation_withTrailingStmt() {
- addTestFile('class A {b() {}} main() {A a; a.^ int x = 7;}');
+ addTestFile('class A {b() {}} void f() {A a; a.^ int x = 7;}');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
expect(replacementLength, equals(0));
@@ -672,7 +672,7 @@
Future<void> test_is_asPrefixedIdentifierStart() async {
addTestFile('''
class A { var isVisible;}
-main(A p) { var v1 = p.is^; }''');
+void f(A p) { var v1 = p.is^; }''');
await getSuggestions();
assertHasResult(CompletionSuggestionKind.INVOCATION, 'isVisible');
}
@@ -694,7 +694,7 @@
A();
A.named();
}
-main() {
+void f() {
^
}
''');
@@ -746,7 +746,7 @@
A();
A.named();
}
-main() {
+void f() {
int A = 0;
^
}
@@ -781,7 +781,7 @@
}
Future<void> test_offset_past_eof() async {
- addTestFile('main() { }', offset: 300);
+ addTestFile('void f() { }', offset: 300);
var request = CompletionGetSuggestionsParams(testFile, completionOffset)
.toRequest('0');
var response = await waitResponse(request);
@@ -811,7 +811,7 @@
''');
addTestFile('''
part of libA;
- main() {^}''');
+ void f() {^}''');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
expect(replacementLength, equals(0));
@@ -833,7 +833,7 @@
library libA;
part "a.dart";
import 'dart:html';
- main() {^}
+ void f() {^}
''');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset));
@@ -850,7 +850,7 @@
Future<void> test_sentToPlugins() async {
addTestFile('''
- void main() {
+ void f() {
^
}
''');
@@ -871,7 +871,7 @@
Future<void> test_simple() {
addTestFile('''
- void main() {
+ void f() {
^
}
''');
@@ -886,7 +886,7 @@
}
Future<void> test_static() async {
- addTestFile('class A {static b() {} c() {}} main() {A.^}');
+ addTestFile('class A {static b() {} c() {}} void f() {A.^}');
await getSuggestions();
expect(replacementOffset, equals(completionOffset));
expect(replacementLength, equals(0));
@@ -898,7 +898,7 @@
addTestFile('''
typedef foo();
var test = '';
- main() {tes^t}
+ void f() {tes^t}
''');
return getSuggestions().then((_) {
expect(replacementOffset, equals(completionOffset - 3));
diff --git a/pkg/analysis_server/test/domain_edit_dartfix_test.dart b/pkg/analysis_server/test/domain_edit_dartfix_test.dart
index 059d4ec..5f889d9 100644
--- a/pkg/analysis_server/test/domain_edit_dartfix_test.dart
+++ b/pkg/analysis_server/test/domain_edit_dartfix_test.dart
@@ -132,7 +132,7 @@
class A<T> {
A.from(Object obj);
}
-main() {
+void f() {
print(A.from<String>([]));
}
''');
@@ -140,12 +140,12 @@
var result = await performFix(
includedFixes: ['wrong_number_of_type_arguments_constructor']);
expect(result.suggestions, hasLength(1));
- expectSuggestion(result.suggestions[0], 'type arguments', 60, 8);
+ expectSuggestion(result.suggestions[0], 'type arguments', 62, 8);
expectEdits(result.edits, '''
class A<T> {
A.from(Object obj);
}
-main() {
+void f() {
print(A<String>.from([]));
}
''');
@@ -200,13 +200,13 @@
}
Future<void> test_pedantic() async {
- addTestFile('main(List args) { if (args.length == 0) { } }');
+ addTestFile('void f(List args) { if (args.length == 0) { } }');
createProject();
var result = await performFix(pedantic: true);
expect(result.suggestions, hasLength(1));
- expectSuggestion(result.suggestions[0], "Replace with 'isEmpty'", 22, 16);
+ expectSuggestion(result.suggestions[0], "Replace with 'isEmpty'", 24, 16);
expect(result.hasErrors, isFalse);
- expectEdits(result.edits, 'main(List args) { if (args.isEmpty) { } }');
+ expectEdits(result.edits, 'void f(List args) { if (args.isEmpty) { } }');
}
Future<void> test_preferEqualForDefaultValues() async {
@@ -267,14 +267,14 @@
}
Future<void> test_preferIsEmpty() async {
- addTestFile('main(List<String> args) { if (args.length == 0) { } }');
+ addTestFile('void f(List<String> args) { if (args.length == 0) { } }');
createProject();
var result = await performFix(includedFixes: ['prefer_is_empty']);
expect(result.suggestions, hasLength(1));
- expectSuggestion(result.suggestions[0], "Replace with 'isEmpty'", 30, 16);
+ expectSuggestion(result.suggestions[0], "Replace with 'isEmpty'", 32, 16);
expect(result.hasErrors, isFalse);
expectEdits(
- result.edits, 'main(List<String> args) { if (args.isEmpty) { } }');
+ result.edits, 'void f(List<String> args) { if (args.isEmpty) { } }');
}
Future<void> test_preferMixin() async {
diff --git a/pkg/analysis_server/test/edit/refactoring_test.dart b/pkg/analysis_server/test/edit/refactoring_test.dart
index 9c02d35..3db384d 100644
--- a/pkg/analysis_server/test/edit/refactoring_test.dart
+++ b/pkg/analysis_server/test/edit/refactoring_test.dart
@@ -41,7 +41,7 @@
Future<void> test_function() {
addTestFile('''
int get test => 42;
-main() {
+void f() {
var a = 1 + test;
var b = 2 + test;
}
@@ -50,7 +50,7 @@
return _sendConvertRequest('test =>');
}, '''
int test() => 42;
-main() {
+void f() {
var a = 1 + test();
var b = 2 + test();
}
@@ -60,7 +60,7 @@
Future<void> test_init_fatalError_notExplicit() {
addTestFile('''
int test = 42;
-main() {
+void f() {
var v = test;
}
''');
@@ -88,7 +88,7 @@
class D extends A {
int get test => 4;
}
-main(A a, B b, C c, D d) {
+void f(A a, B b, C c, D d) {
var va = a.test;
var vb = b.test;
var vc = c.test;
@@ -110,7 +110,7 @@
class D extends A {
int test() => 4;
}
-main(A a, B b, C c, D d) {
+void f(A a, B b, C c, D d) {
var va = a.test();
var vb = b.test();
var vc = c.test();
@@ -136,7 +136,7 @@
Future<void> test_function() {
addTestFile('''
int test() => 42;
-main() {
+void f() {
var a = 1 + test();
var b = 2 + test();
}
@@ -145,7 +145,7 @@
return _sendConvertRequest('test() =>');
}, '''
int get test => 42;
-main() {
+void f() {
var a = 1 + test;
var b = 2 + test;
}
@@ -155,7 +155,7 @@
Future<void> test_init_fatalError_hasParameters() {
addTestFile('''
int test(p) => p + 1;
-main() {
+void f() {
var v = test(2);
}
''');
@@ -171,7 +171,7 @@
Future<void> test_init_fatalError_notExecutableElement() {
addTestFile('''
-main() {
+void f() {
int abc = 1;
print(abc);
}
@@ -200,7 +200,7 @@
class D extends A {
int test() => 4;
}
-main(A a, B b, C c, D d) {
+void f(A a, B b, C c, D d) {
var va = a.test();
var vb = b.test();
var vc = c.test();
@@ -222,7 +222,7 @@
class D extends A {
int get test => 4;
}
-main(A a, B b, C c, D d) {
+void f(A a, B b, C c, D d) {
var va = a.test;
var vb = b.test;
var vc = c.test;
@@ -282,7 +282,7 @@
''');
addTestFile('''
import 'other.dart';
-main() {
+void f() {
foo(1 + 2);
}
''');
@@ -297,7 +297,7 @@
Future<void> test_coveringExpressions() {
addTestFile('''
-main() {
+void f() {
var v = 111 + 222 + 333;
}
''');
@@ -317,7 +317,7 @@
Future<void> test_extractAll() {
addTestFile('''
-main() {
+void f() {
print(1 + 2);
print(1 + 2);
}
@@ -325,7 +325,7 @@
return assertSuccessfulRefactoring(() {
return sendStringRequest('1 + 2', 'res', true);
}, '''
-main() {
+void f() {
var res = 1 + 2;
print(res);
print(res);
@@ -335,7 +335,7 @@
Future<void> test_extractOne() {
addTestFile('''
-main() {
+void f() {
print(1 + 2);
print(1 + 2); // marker
}
@@ -343,7 +343,7 @@
return assertSuccessfulRefactoring(() {
return sendStringSuffixRequest('1 + 2', '); // marker', 'res', false);
}, '''
-main() {
+void f() {
print(1 + 2);
var res = 1 + 2;
print(res); // marker
@@ -381,7 +381,7 @@
addTestFile('''
class TreeItem {}
TreeItem getSelectedItem() => null;
-main() {
+void f() {
var a = getSelectedItem();
}
''');
@@ -396,7 +396,7 @@
Future<void> test_nameWarning() async {
addTestFile('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -407,7 +407,7 @@
'Variable name should start with a lowercase letter.');
// ...but there is still a change
assertTestRefactoringResult(result, '''
-main() {
+void f() {
var Name = 1 + 2;
print(Name);
}
@@ -416,7 +416,7 @@
Future<void> test_offsetsLengths() {
addTestFile('''
-main() {
+void f() {
print(1 + 2);
print(1 + 2);
}
@@ -432,7 +432,7 @@
Future<void> test_resetOnAnalysisSetChanged_overlay() async {
addTestFile('''
-main() {
+void f() {
print(1 + 2); // 0
}
''');
@@ -450,7 +450,7 @@
await checkUpdate(() {
server.updateContent('u1', {
testFile: AddContentOverlay('''
-main() {
+void f() {
print(1 + 2); // 1
}
''')
@@ -461,7 +461,7 @@
server.updateContent('u2', {
testFile: ChangeContentOverlay([
SourceEdit(0, 0, '''
-main() {
+void f() {
print(1 + 2); // 2
}
''')
@@ -478,7 +478,7 @@
var otherFile = join(testFolder, 'other.dart');
newFile(otherFile, content: '// other 1');
addTestFile('''
-main() {
+void f() {
foo(1 + 2);
}
foo(int myName) {}
@@ -503,7 +503,7 @@
Future<void> test_resetOnAnalysisSetChanged_watch_thisFile() async {
addTestFile('''
-main() {
+void f() {
foo(1 + 2);
}
foo(int myName) {}
@@ -519,7 +519,7 @@
var initialResetCount = test_resetCount;
// Update the test.dart file.
modifyTestFile('''
-main() {
+void f() {
foo(1 + 2);
}
foo(int otherName) {}
@@ -541,7 +541,7 @@
Future<void> test_serverError_change() {
test_simulateRefactoringException_change = true;
addTestFile('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -556,7 +556,7 @@
Future<void> test_serverError_final() {
test_simulateRefactoringException_final = true;
addTestFile('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -571,7 +571,7 @@
Future<void> test_serverError_init() {
test_simulateRefactoringException_init = true;
addTestFile('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -593,14 +593,14 @@
Future<void> test_expression() {
addTestFile('''
-main() {
+void f() {
print(1 + 2);
print(1 + 2);
}
''');
_setOffsetLengthForString('1 + 2');
return assertSuccessfulRefactoring(_computeChange, '''
-main() {
+void f() {
print(res());
print(res());
}
@@ -611,7 +611,7 @@
Future<void> test_expression_hasParameters() {
addTestFile('''
-main() {
+void f() {
int a = 1;
int b = 2;
print(a + b);
@@ -620,7 +620,7 @@
''');
_setOffsetLengthForString('a + b');
return assertSuccessfulRefactoring(_computeChange, '''
-main() {
+void f() {
int a = 1;
int b = 2;
print(res(a, b));
@@ -633,7 +633,7 @@
Future<void> test_expression_updateParameters() async {
addTestFile('''
-main() {
+void f() {
int a = 1;
int b = 2;
print(a + b);
@@ -650,7 +650,7 @@
parameters.insert(0, parameters.removeLast());
options!.parameters = parameters;
return assertSuccessfulRefactoring(_sendExtractRequest, '''
-main() {
+void f() {
int a = 1;
int b = 2;
print(res(b, a));
@@ -663,7 +663,7 @@
Future<void> test_init_fatalError_invalidStatement() {
addTestFile('''
-main(bool b) {
+void f(bool b) {
// start
if (b) {
print(1);
@@ -685,14 +685,14 @@
Future<void> test_long_expression() {
addTestFile('''
-main() {
+void f() {
print(1 +
2);
}
''');
_setOffsetLengthForString('1 +\n 2');
return assertSuccessfulRefactoring(_computeChange, '''
-main() {
+void f() {
print(res());
}
@@ -707,7 +707,7 @@
addTestFile('''
class TreeItem {}
TreeItem getSelectedItem() => null;
-main() {
+void f() {
var a = getSelectedItem( );
}
''');
@@ -723,7 +723,7 @@
addTestFile('''
class TreeItem {}
TreeItem getSelectedItem() => null;
-main() {
+void f() {
var a = 1 + 2;
var b = 1 + 2;
}
@@ -737,7 +737,7 @@
Future<void> test_statements() {
addTestFile('''
-main() {
+void f() {
int a = 1;
int b = 2;
// start
@@ -748,7 +748,7 @@
''');
_setOffsetLengthForStartEnd();
return assertSuccessfulRefactoring(_computeChange, '''
-main() {
+void f() {
int a = 1;
int b = 2;
// start
@@ -914,7 +914,7 @@
Future test_extractLocal() async {
addTestFile('''
-main() {
+void f() {
var a = 1 + 2;
}
''');
@@ -926,7 +926,7 @@
Future test_extractLocal_withoutSelection() async {
addTestFile('''
-main() {
+void f() {
var a = 1 + 2;
}
''');
@@ -977,7 +977,7 @@
Future test_rename_hasElement_class() {
return assertHasRenameRefactoring('''
class Test {}
-main() {
+void f() {
Test v;
}
''', 'Test v');
@@ -988,7 +988,7 @@
class A {
A.test() {}
}
-main() {
+void f() {
new A.test();
}
''', 'test();');
@@ -996,7 +996,7 @@
Future test_rename_hasElement_function() {
return assertHasRenameRefactoring('''
-main() {
+void f() {
test();
}
test() {}
@@ -1006,7 +1006,7 @@
Future test_rename_hasElement_importElement_directive() {
return assertHasRenameRefactoring('''
import 'dart:math' as math;
-main() {
+void f() {
math.PI;
}
''', 'import ');
@@ -1015,7 +1015,7 @@
Future test_rename_hasElement_importElement_prefixDecl() {
return assertHasRenameRefactoring('''
import 'dart:math' as math;
-main() {
+void f() {
math.PI;
}
''', 'math;');
@@ -1025,7 +1025,7 @@
return assertHasRenameRefactoring('''
import 'dart:async' as test;
import 'dart:math' as test;
-main() {
+void f() {
test.pi;
}
''', 'test.pi;');
@@ -1036,7 +1036,7 @@
class A {
get test => 0;
}
-main(A a) {
+void f(A a) {
a.test;
}
''', 'test;');
@@ -1047,7 +1047,7 @@
class A {
set test(x) {}
}
-main(A a) {
+void f(A a) {
a.test = 2;
}
''', 'test = 2;');
@@ -1061,7 +1061,7 @@
Future test_rename_hasElement_localVariable() {
return assertHasRenameRefactoring('''
-main() {
+void f() {
int test = 0;
print(test);
}
@@ -1073,7 +1073,7 @@
class A {
test() {}
}
-main(A a) {
+void f(A a) {
a.test();
}
''', 'test();');
@@ -1081,7 +1081,7 @@
Future test_rename_noElement() async {
addTestFile('''
-main() {
+void f() {
// not an element
}
''');
@@ -1101,7 +1101,7 @@
''');
addTestFile('''
import 'other.dart';
-main() {
+void f() {
int res = 1 + 2;
foo(res);
foo(res);
@@ -1118,7 +1118,7 @@
Future<void> test_feedback() {
addTestFile('''
-main() {
+void f() {
int test = 42;
print(test);
print(test);
@@ -1134,9 +1134,9 @@
}
Future<void> test_init_fatalError_notVariable() {
- addTestFile('main() {}');
+ addTestFile('void f() {}');
return getRefactoringResult(() {
- return _sendInlineRequest('main() {}');
+ return _sendInlineRequest('void f() {}');
}).then((result) {
assertResultProblemsFatal(result.initialProblems,
'Local variable declaration or reference must be selected to activate this refactoring.');
@@ -1147,7 +1147,7 @@
Future<void> test_OK() {
addTestFile('''
-main() {
+void f() {
int test = 42;
int a = test + 2;
print(test);
@@ -1156,7 +1156,7 @@
return assertSuccessfulRefactoring(() {
return _sendInlineRequest('test + 2');
}, '''
-main() {
+void f() {
int a = 42 + 2;
print(42);
}
@@ -1166,7 +1166,7 @@
Future<void> test_resetOnAnalysisSetChanged() async {
newFile(join(testFolder, 'other.dart'), content: '// other 1');
addTestFile('''
-main() {
+void f() {
int res = 1 + 2;
print(res);
}
@@ -1178,7 +1178,7 @@
var initialResetCount = test_resetCount;
// Update the test.dart file.
modifyTestFile('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -1210,7 +1210,7 @@
test(int p) {
print(f + p);
}
- main() {
+ void f() {
test(1);
}
}
@@ -1244,11 +1244,11 @@
test(int p) {
print(f + p);
}
- main() {
+ void f() {
test(1);
}
}
-main(A a) {
+void f(A a) {
a.test(2);
}
''');
@@ -1257,11 +1257,11 @@
}, '''
class A {
int f;
- main() {
+ void f() {
print(f + 1);
}
}
-main(A a) {
+void f(A a) {
print(a.f + 2);
}
''');
@@ -1272,7 +1272,7 @@
test(a, b) {
print(a + b);
}
-main() {
+void f() {
test(1, 2);
test(10, 20);
}
@@ -1280,7 +1280,7 @@
return assertSuccessfulRefactoring(() {
return _sendInlineRequest('test(a');
}, '''
-main() {
+void f() {
print(1 + 2);
print(10 + 20);
}
@@ -1292,7 +1292,7 @@
test(a, b) {
print(a + b);
}
-main() {
+void f() {
test(1, 2);
test(10, 20);
}
@@ -1305,7 +1305,7 @@
test(a, b) {
print(a + b);
}
-main() {
+void f() {
test(1, 2);
print(10 + 20);
}
@@ -1377,7 +1377,7 @@
Future<void> test_cancelPendingRequest() async {
addTestFile('''
-main() {
+void f() {
int test = 0;
print(test);
}
@@ -1401,7 +1401,7 @@
Test() {}
Test.named() {}
}
-main() {
+void f() {
Test v;
new Test();
new Test.named();
@@ -1414,7 +1414,7 @@
NewName() {}
NewName.named() {}
}
-main() {
+void f() {
NewName v;
new NewName();
new NewName.named();
@@ -1456,7 +1456,7 @@
class Test {
Test() {}
}
-main() {
+void f() {
new Test();
}
''');
@@ -1468,13 +1468,13 @@
class NewName {
NewName() {}
}
-main() {
+void f() {
new NewName();
}
''',
feedbackValidator: (feedback) {
var renameFeedback = feedback as RenameFeedback;
- expect(renameFeedback.offset, 42);
+ expect(renameFeedback.offset, 44);
expect(renameFeedback.length, 4);
},
);
@@ -1485,7 +1485,7 @@
class Test {
Test.named() {}
}
-main() {
+void f() {
new Test.named();
}
''');
@@ -1497,13 +1497,13 @@
class NewName {
NewName.named() {}
}
-main() {
+void f() {
new NewName.named();
}
''',
feedbackValidator: (feedback) {
var renameFeedback = feedback as RenameFeedback;
- expect(renameFeedback.offset, 48);
+ expect(renameFeedback.offset, 50);
expect(renameFeedback.length, 4);
},
);
@@ -1514,7 +1514,7 @@
class Test {
Test() {}
}
-main() {
+void f() {
new Test();
}
''');
@@ -1526,13 +1526,13 @@
class NewName {
NewName() {}
}
-main() {
+void f() {
new NewName();
}
''',
feedbackValidator: (feedback) {
var renameFeedback = feedback as RenameFeedback;
- expect(renameFeedback.offset, 42);
+ expect(renameFeedback.offset, 44);
expect(renameFeedback.length, 4);
},
);
@@ -1543,7 +1543,7 @@
class Test {
Test.named() {}
}
-main() {
+void f() {
new Test.named();
}
''');
@@ -1555,13 +1555,13 @@
class NewName {
NewName.named() {}
}
-main() {
+void f() {
new NewName.named();
}
''',
feedbackValidator: (feedback) {
var renameFeedback = feedback as RenameFeedback;
- expect(renameFeedback.offset, 48);
+ expect(renameFeedback.offset, 50);
expect(renameFeedback.length, 4);
},
);
@@ -1570,7 +1570,7 @@
Future<void> test_class_options_fatalError() {
addTestFile('''
class Test {}
-main() {
+void f() {
Test v;
}
''');
@@ -1587,7 +1587,7 @@
Future<void> test_class_validateOnly() {
addTestFile('''
class Test {}
-main() {
+void f() {
Test v;
}
''');
@@ -1605,7 +1605,7 @@
Future<void> test_class_warning() {
addTestFile('''
class Test {}
-main() {
+void f() {
Test v;
}
''');
@@ -1617,7 +1617,7 @@
// ...but there is still a change
assertTestRefactoringResult(result, '''
class newName {}
-main() {
+void f() {
newName v;
}
''');
@@ -1630,7 +1630,7 @@
// ...and there is a new change
assertTestRefactoringResult(result, '''
class NewName {}
-main() {
+void f() {
NewName v;
}
''');
@@ -1643,7 +1643,7 @@
class A {
var test = 0;
A(this.test);
- main() {
+ void f() {
print(test);
}
}
@@ -1654,7 +1654,7 @@
class A {
var newName = 0;
A(this.newName);
- main() {
+ void f() {
print(newName);
}
}
@@ -1666,7 +1666,7 @@
class A {
var test = 0;
A(this.test);
- main() {
+ void f() {
print(test);
}
}
@@ -1677,7 +1677,7 @@
class A {
var newName = 0;
A(this.newName);
- main() {
+ void f() {
print(newName);
}
}
@@ -1690,7 +1690,7 @@
final int test;
A({this.test: 0});
}
-main() {
+void f() {
new A(test: 42);
}
''');
@@ -1701,7 +1701,7 @@
final int newName;
A({this.newName: 0});
}
-main() {
+void f() {
new A(newName: 42);
}
''');
@@ -1711,7 +1711,7 @@
addTestFile('''
class A {
get test => 0;
- main() {
+ void f() {
print(test);
}
}
@@ -1721,7 +1721,7 @@
}, '''
class A {
get newName => 0;
- main() {
+ void f() {
print(newName);
}
}
@@ -1732,11 +1732,11 @@
addTestFile('''
class A {
test() {}
- main() {
+ void f() {
test();
}
}
-main(A a) {
+void f(A a) {
a.test();
}
''');
@@ -1745,11 +1745,11 @@
}, '''
class A {
newName() {}
- main() {
+ void f() {
newName();
}
}
-main(A a) {
+void f(A a) {
a.newName();
}
''');
@@ -1760,7 +1760,7 @@
class A {
test() {}
}
-main(A a, a2) {
+void f(A a, a2) {
a.test();
a2.test(); // a2
}
@@ -1785,7 +1785,7 @@
addTestFile('''
class A {
set test(x) {}
- main() {
+ void f() {
test = 0;
}
}
@@ -1795,7 +1795,7 @@
}, '''
class A {
set newName(x) {}
- main() {
+ void f() {
newName = 0;
}
}
@@ -1836,7 +1836,7 @@
class A {
A.test() {}
}
-main() {
+void f() {
new A.test();
}
''');
@@ -1848,13 +1848,13 @@
class A {
A.newName() {}
}
-main() {
+void f() {
new A.newName();
}
''',
feedbackValidator: (feedback) {
var renameFeedback = feedback as RenameFeedback;
- expect(renameFeedback.offset, 43);
+ expect(renameFeedback.offset, 45);
expect(renameFeedback.length, 4);
},
);
@@ -1863,7 +1863,7 @@
Future<void> test_feedback() {
addTestFile('''
class Test {}
-main() {
+void f() {
Test v;
}
''');
@@ -1883,7 +1883,7 @@
A({T test});
}
-main() {
+void f() {
A(test: 0);
}
''');
@@ -1894,7 +1894,7 @@
A({T newName});
}
-main() {
+void f() {
A(newName: 0);
}
''');
@@ -1906,7 +1906,7 @@
void foo({T test}) {}
}
-main(A<int> a) {
+void f(A<int> a) {
a.foo(test: 0);
}
''');
@@ -1917,7 +1917,7 @@
void foo({T newName}) {}
}
-main(A<int> a) {
+void f(A<int> a) {
a.foo(newName: 0);
}
''');
@@ -1926,7 +1926,7 @@
Future<void> test_function() {
addTestFile('''
test() {}
-main() {
+void f() {
test();
print(test);
}
@@ -1935,7 +1935,7 @@
return sendRenameRequest('test() {}', 'newName');
}, '''
newName() {}
-main() {
+void f() {
newName();
print(newName);
}
@@ -1946,7 +1946,7 @@
addTestFile('''
import 'dart:math';
import 'dart:async';
-main() {
+void f() {
Random r;
Future f;
}
@@ -1958,7 +1958,7 @@
'''
import 'dart:math';
import 'dart:async' as new_name;
-main() {
+void f() {
Random r;
new_name.Future f;
}
@@ -1974,7 +1974,7 @@
addTestFile('''
import 'dart:math' as test;
import 'dart:async' as test;
-main() {
+void f() {
test.Random r;
test.Future f;
}
@@ -1986,7 +1986,7 @@
'''
import 'dart:math' as test;
import 'dart:async';
-main() {
+void f() {
test.Random r;
Future f;
}
@@ -2060,7 +2060,7 @@
Future<void> test_localVariable() {
addTestFile('''
-main() {
+void f() {
int test = 0;
test = 1;
test += 2;
@@ -2070,7 +2070,7 @@
return assertSuccessfulRefactoring(() {
return sendRenameRequest('test = 1', 'newName');
}, '''
-main() {
+void f() {
int newName = 0;
newName = 1;
newName += 2;
@@ -2081,7 +2081,7 @@
Future<void> test_localVariable_finalCheck_shadowError() {
addTestFile('''
-main() {
+void f() {
var newName;
int test = 0;
print(test);
@@ -2101,7 +2101,7 @@
test_simulateRefactoringReset_afterCreateChange = true;
addTestFile('''
test() {}
-main() {
+void f() {
test();
}
''');
@@ -2116,7 +2116,7 @@
test_simulateRefactoringReset_afterFinalConditions = true;
addTestFile('''
test() {}
-main() {
+void f() {
test();
}
''');
@@ -2131,7 +2131,7 @@
test_simulateRefactoringReset_afterInitialConditions = true;
addTestFile('''
test() {}
-main() {
+void f() {
test();
}
''');
@@ -2144,7 +2144,7 @@
Future<void> test_resetOnAnalysis() async {
addTestFile('''
-main() {
+void f() {
int initialName = 0;
print(initialName);
}
@@ -2156,7 +2156,7 @@
_validateFeedback(result, oldName: 'initialName');
// update the file
modifyTestFile('''
-main() {
+void f() {
int otherName = 0;
print(otherName);
}
diff --git a/pkg/analysis_server/test/lsp/completion_dart_test.dart b/pkg/analysis_server/test/lsp/completion_dart_test.dart
index fee07a1..69de58e 100644
--- a/pkg/analysis_server/test/lsp/completion_dart_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_dart_test.dart
@@ -72,7 +72,7 @@
Future<void> test_comment() async {
final content = '''
// foo ^
- main() {}
+ void f() {}
''';
await initialize();
@@ -118,7 +118,7 @@
);
final content = '''
-main() {
+void f() {
pri^
}
''';
@@ -172,7 +172,7 @@
class Aaaaa {
Aaaaa(int a);
}
- void main(int aaa) {
+ void f(int aaa) {
var a = new [[Aaa^]]
}
''',
@@ -213,7 +213,7 @@
class Aaaaa {
Aaaaa(int a);
}
- void main(int aaa) {
+ void f(int aaa) {
var a = new [[Aaa^]]()
}
''',
@@ -238,7 +238,7 @@
class Aaaaa {
Aaaaa.foo(int a);
}
- void main() {
+ void f() {
var a = new Aaaaa.[[foo^]]()
}
''',
@@ -249,18 +249,18 @@
Future<void> test_completeFunctionCalls_existingArgList_statement() =>
checkCompleteFunctionCallInsertText(
'''
- void main(int a) {
- [[mai^]]()
+ void f(int a) {
+ [[f^]]()
}
''',
- 'main(…)',
- insertText: 'main',
+ 'f(…)',
+ insertText: 'f',
);
Future<void> test_completeFunctionCalls_existingArgList_suggestionSets() =>
checkCompleteFunctionCallInsertText(
'''
- void main(int a) {
+ void f(int a) {
[[pri^]]()
}
''',
@@ -274,7 +274,7 @@
class Aaaaa {
Aaaaa(int a);
}
- void main(int aaa) {
+ void f(int aaa) {
var a = new [[Aaa^]](
}
''',
@@ -347,7 +347,7 @@
class Aaaaa {
Aaaaa.foo(int a);
}
- void main() {
+ void f() {
var a = new Aaaaa.[[foo^]]
}
''',
@@ -360,7 +360,7 @@
final content = '''
void myFunction({int a}) {}
- main() {
+ void f() {
[[myFu^]]
}
''';
@@ -413,19 +413,19 @@
Future<void> test_completeFunctionCalls_statement() =>
checkCompleteFunctionCallInsertText(
'''
- void main(int a) {
- [[mai^]]
+ void f(int a) {
+ [[f^]]
}
''',
- 'main(…)',
+ 'f(…)',
insertTextFormat: InsertTextFormat.Snippet,
- insertText: r'main(${0:a})',
+ insertText: r'f(${0:a})',
);
Future<void> test_completeFunctionCalls_suggestionSets() =>
checkCompleteFunctionCallInsertText(
'''
- void main(int a) {
+ void f(int a) {
[[pri^]]
}
''',
@@ -485,7 +485,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^
}
@@ -626,7 +626,7 @@
Future<void> test_fromPlugin_dartFile() async {
final content = '''
- void main() {
+ void f() {
var x = '';
print(^);
}
@@ -702,7 +702,7 @@
Future<void> test_fromPlugin_tooSlow() async {
final content = '''
- void main() {
+ void f() {
var x = '';
print(^);
}
@@ -752,7 +752,7 @@
String set getterAndSetter(String value) {}
}
- main() {
+ void f() {
MyClass a;
a.^
}
@@ -778,7 +778,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^def
}
@@ -835,7 +835,7 @@
Future<void> test_insertTextMode_singleLine() async {
final content = '''
- main() {
+ void foo() {
^
}
''';
@@ -845,7 +845,7 @@
emptyTextDocumentClientCapabilities));
await openFile(mainFileUri, withoutMarkers(content));
final res = await getCompletion(mainFileUri, positionFromMarker(content));
- final item = res.singleWhere((c) => c.label.startsWith('main'));
+ final item = res.singleWhere((c) => c.label.startsWith('foo'));
// Single line completions should never set insertTextMode.asIs to
// avoid bloating payload size where it wouldn't matter.
@@ -871,7 +871,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^
}
@@ -894,7 +894,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^
}
@@ -919,7 +919,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^
}
@@ -950,19 +950,19 @@
class A { const A({int argOne, int argTwo, String argThree}); }
final varOne = '';
$code
-main() { }
+void f() { }
''';
final expectedReplaced = '''
class A { const A({int argOne, int argTwo, String argThree}); }
final varOne = '';
$expectedReplace
-main() { }
+void f() { }
''';
final expectedInserted = '''
class A { const A({int argOne, int argTwo, String argThree}); }
final varOne = '';
$expectedInsert
-main() { }
+void f() { }
''';
await verifyCompletions(
@@ -1036,7 +1036,7 @@
// other symbol.
// https://github.com/Dart-Code/Dart-Code/issues/2672#issuecomment-666085575
final content = '''
- void main() {
+ void f() {
myFunction(
^
aaaa: '',
@@ -1056,7 +1056,7 @@
final content = '''
class A { const A({int one}); }
@A(^)
- main() { }
+ void f() { }
''';
await initialize();
@@ -1078,7 +1078,7 @@
final content = '''
class A { const A({int one}); }
@A(^)
- main() { }
+ void f() { }
''';
await initialize(
@@ -1106,8 +1106,8 @@
Future<void>
test_namedArgTrailing_snippetStringSelection_insideString() async {
final content = '''
- main({int one, int two}) {
- main(
+ void f({int one, int two}) {
+ f(
^
two: 2,
);
@@ -1148,7 +1148,7 @@
final content = '''
class MyClass {}
- main() {
+ void f() {
MyClass a = new MyCla^
}
''';
@@ -1168,7 +1168,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^
}
@@ -1195,7 +1195,7 @@
class UniqueNamedClassForLspTwo {}
class UniqueNamedClassForLspThree {}
- main() {
+ void f() {
// Should match only Two and Three
UniqueNamedClassForLspT^
}
@@ -1215,7 +1215,7 @@
class UniqueNamedClassForLspTwo {}
class UniqueNamedClassForLspThree {}
- main() {
+ void f() {
// Should match only Two and Three
UniqueNamedClassForLspT^hree
}
@@ -1235,7 +1235,7 @@
class UniqueNamedClassForLspTwo {}
class UniqueNamedClassForLspThree {}
- main() {
+ void f() {
// Should match all three
^UniqueNamedClassForLspT
}
@@ -1259,7 +1259,7 @@
);
final content = '''
-main() {
+void f() {
InOtherF^
}
''';
@@ -1316,7 +1316,7 @@
expect(newContent, equals('''
import '../other_file.dart';
-main() {
+void f() {
InOtherFile
}
'''));
@@ -1349,7 +1349,7 @@
import 'reexport1.dart';
import 'reexport2.dart';
-main() {
+void f() {
MyExported^
}
''';
@@ -1393,7 +1393,7 @@
final content = '''
import 'reexport1.dart';
-main() {
+void f() {
MyExported^
}
''';
@@ -1427,7 +1427,7 @@
);
final content = '''
-main() {
+void f() {
MyDuplicated^
}
''';
@@ -1462,7 +1462,7 @@
);
final content = '''
-main() {
+void f() {
var a = MyExported^
}
''';
@@ -1511,7 +1511,7 @@
expect(newContent, equals('''
import '../source_file.dart';
-main() {
+void f() {
var a = MyExportedEnum.One
}
'''));
@@ -1540,7 +1540,7 @@
final content = '''
import 'reexport1.dart';
-main() {
+void f() {
var a = MyExported^
}
''';
@@ -1584,7 +1584,7 @@
final content = '''
import 'reexport1.dart';
-main() {
+void f() {
MyExported^
}
''';
@@ -1626,7 +1626,7 @@
);
final content = '''
-main() {
+void f() {
MyExported^
}
''';
@@ -1661,7 +1661,7 @@
);
final content = '''
-main() {
+void f() {
InOtherF^il
}
''';
@@ -1729,7 +1729,7 @@
expect(newContentReplaceMode, equals('''
import '../other_file.dart';
-main() {
+void f() {
InOtherFile
}
'''));
@@ -1737,7 +1737,7 @@
expect(newContentInsertMode, equals('''
import '../other_file.dart';
-main() {
+void f() {
InOtherFileil
}
'''));
@@ -1760,7 +1760,7 @@
// File that we're invoking completion in.
final content = '''
part of 'parent.dart';
-main() {
+void f() {
InOtherF^
}
''';
@@ -1794,7 +1794,7 @@
);
expect(newContent, equals('''
part of 'parent.dart';
-main() {
+void f() {
InOtherFile
}
'''));
@@ -1847,7 +1847,7 @@
);
final content = '''
-main() {
+void f() {
var a = MyExported^
}
''';
@@ -1901,7 +1901,7 @@
expect(newContent, equals('''
import '../source_file.dart';
-main() {
+void f() {
var a = MyExportedClass.myStaticDateTimeField
}
'''));
@@ -1954,7 +1954,7 @@
);
final content = '''
-main() {
+void f() {
var a = InOtherF^
}
''';
@@ -1995,7 +1995,7 @@
expect(newContent, equals('''
import '../other_file.dart';
-main() {
+void f() {
var a = InOtherFile.fromJson
}
'''));
@@ -2008,7 +2008,7 @@
);
final content = '''
-main() {
+void f() {
InOtherF^
}
''';
@@ -2039,7 +2039,7 @@
);
final content = '''
-main() {
+void f() {
InOtherF^
}
''';
@@ -2062,7 +2062,7 @@
String abcdefghij;
}
- main() {
+ void f() {
MyClass a;
a.abc^
}
@@ -2108,7 +2108,7 @@
final content = '''
void myFunction(String a, int b, {required String c, String d = ''}) {}
- main() {
+ void f() {
[[myFu^]]
}
''';
@@ -2142,7 +2142,7 @@
"void myFunction(String a, int b, {required String c, String d = ''}) {}",
);
final content = '''
- main() {
+ void f() {
[[myFu^]]
}
''';
@@ -2180,7 +2180,7 @@
final content = '''
String? foo(int? a, [int b = 1]) {}
- main() {
+ void f() {
fo^
}
''';
diff --git a/pkg/analysis_server/test/lsp/format_test.dart b/pkg/analysis_server/test/lsp/format_test.dart
index f00bc9b..741a740 100644
--- a/pkg/analysis_server/test/lsp/format_test.dart
+++ b/pkg/analysis_server/test/lsp/format_test.dart
@@ -37,7 +37,7 @@
}
Future<void> test_alreadyFormatted() async {
- const contents = '''main() {
+ const contents = '''void f() {
print('test');
}
''';
@@ -166,13 +166,13 @@
Future<void> test_formatOnType_simple() async {
const contents = '''
- main ()
+ void f ()
{
print('test');
^}
''';
- final expected = '''main() {
+ final expected = '''void f() {
print('test');
}
''';
@@ -190,7 +190,7 @@
// Only ranges that are fully contained by the range should be applied,
// not those that intersect the start/end.
const contents = '''
-main()
+void f()
{
[[ print('test');
print('test');
@@ -198,7 +198,7 @@
}
''';
final expected = '''
-main()
+void f()
{
print('test');
print('test');
@@ -212,7 +212,7 @@
Future<void> test_formatRange_invalidRange() async {
const contents = '''
-main()
+void f()
{
print('test');
}
@@ -272,7 +272,7 @@
}
Future<void> test_invalidSyntax() async {
- const contents = '''main(((( {
+ const contents = '''void f(((( {
print('test');
}
''';
@@ -285,15 +285,15 @@
Future<void> test_lineLength() async {
const contents = '''
- main() =>
+ void f() =>
print(
'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789'
);
''';
- final expectedDefault = '''main() => print(
+ final expectedDefault = '''void f() => print(
'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789');\n''';
final expectedLongLines =
- '''main() => print('123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789');\n''';
+ '''void f() => print('123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789');\n''';
// Initialize with config support, supplying an empty config when requested.
await provideConfig(
@@ -313,10 +313,10 @@
// Check we only get one edit to add the required whitespace and not
// an entire document replacement.
const contents = '''
-main(){}
+void f(){}
''';
const expected = '''
-main() {}
+void f() {}
''';
await initialize();
await openFile(mainFileUri, contents);
@@ -324,7 +324,7 @@
await expectFormattedContents(mainFileUri, contents, expected);
expect(formatEdits, hasLength(1));
expect(formatEdits[0].newText, ' ');
- expect(formatEdits[0].range.start, equals(Position(line: 0, character: 6)));
+ expect(formatEdits[0].range.start, equals(Position(line: 0, character: 8)));
}
Future<void> test_minimalEdits_removeFileLeadingWhitespace() async {
@@ -333,10 +333,10 @@
-main() {}
+void f() {}
''';
const expected = '''
-main() {}
+void f() {}
''';
await initialize();
await openFile(mainFileUri, contents);
@@ -351,14 +351,14 @@
Future<void> test_minimalEdits_removeFileTrailingWhitespace() async {
// Check whitespace after the last token is handled.
const contents = '''
-main() {}
+void f() {}
''';
const expected = '''
-main() {}
+void f() {}
''';
await initialize();
await openFile(mainFileUri, contents);
@@ -374,10 +374,10 @@
// Check we get an edit only to remove the unnecessary trailing whitespace
// and not to replace the whole whitespace with a single space.
const contents = '''
-main() {}
+void f() {}
''';
const expected = '''
-main() {}
+void f() {}
''';
await initialize();
await openFile(mainFileUri, contents);
@@ -388,8 +388,8 @@
formatEdits[0],
equals(TextEdit(
range: Range(
- start: Position(line: 0, character: 7),
- end: Position(line: 0, character: 13)),
+ start: Position(line: 0, character: 9),
+ end: Position(line: 0, character: 15)),
newText: '',
)));
}
@@ -398,13 +398,13 @@
// Check we get an edit only to remove the unnecessary leading whitespace
// and not to replace the whole whitespace with a single space.
const contents = '''
-main()
+void f()
{}
''';
const expected = '''
-main() {}
+void f() {}
''';
await initialize();
await openFile(mainFileUri, contents);
@@ -415,7 +415,7 @@
formatEdits[0],
equals(TextEdit(
range: Range(
- start: Position(line: 0, character: 6),
+ start: Position(line: 0, character: 8),
end: Position(line: 3, character: 0)),
newText: '',
)));
@@ -425,10 +425,10 @@
// Check we only get two edits to remove the unwanted whitespace and not
// an entire document replacement.
const contents = '''
-main( ) { }
+void f( ) { }
''';
const expected = '''
-main() {}
+void f() {}
''';
await initialize();
await openFile(mainFileUri, contents);
@@ -436,23 +436,24 @@
await expectFormattedContents(mainFileUri, contents, expected);
expect(formatEdits, hasLength(2));
expect(formatEdits[0].newText, isEmpty);
- expect(formatEdits[0].range.start, equals(Position(line: 0, character: 5)));
+ expect(formatEdits[0].range.start, equals(Position(line: 0, character: 7)));
expect(formatEdits[1].newText, isEmpty);
- expect(formatEdits[1].range.start, equals(Position(line: 0, character: 9)));
+ expect(
+ formatEdits[1].range.start, equals(Position(line: 0, character: 11)));
}
Future<void> test_minimalEdits_withComments() async {
// Check we can get edits that span a comment (which does not appear in the
// main token list).
const contents = '''
-main() {
+void f() {
var a = 1;
// Comment
print(a);
}
''';
const expected = '''
-main() {
+void f() {
var a = 1;
// Comment
print(a);
@@ -529,13 +530,13 @@
Future<void> test_simple() async {
const contents = '''
- main ()
+ void f ()
{
print('test');
}
''';
- final expected = '''main() {
+ final expected = '''void f() {
print('test');
}
''';
@@ -546,13 +547,13 @@
Future<void> test_unopenFile() async {
const contents = '''
- main ()
+ void f ()
{
print('test');
}
''';
- final expected = '''main() {
+ final expected = '''void f() {
print('test');
}
''';
@@ -564,11 +565,11 @@
Future<void> test_validSyntax_withErrors() async {
// We should still be able to format syntactically valid code even if it has analysis
// errors.
- const contents = '''main() {
+ const contents = '''void f() {
print(a);
}
''';
- const expected = '''main() {
+ const expected = '''void f() {
print(a);
}
''';
diff --git a/pkg/analysis_server/test/search/element_references_test.dart b/pkg/analysis_server/test/search/element_references_test.dart
index 144cf47..21a4e6b 100644
--- a/pkg/analysis_server/test/search/element_references_test.dart
+++ b/pkg/analysis_server/test/search/element_references_test.dart
@@ -45,7 +45,7 @@
class A {
A.named(p);
}
-main() {
+void f() {
new A.named(1);
new A.named(2);
}
@@ -85,7 +85,7 @@
class A {
A(p);
}
-main() {
+void f() {
new A(1);
new A(2);
}
@@ -114,7 +114,7 @@
k = 3;
}
}
-main() {
+void f() {
new A(1);
new B(2);
}
@@ -132,7 +132,7 @@
void bar() {}
}
-main() {
+void f() {
E.foo();
E(0).bar();
}
@@ -157,11 +157,11 @@
fff(); // in m()
}
}
-main(A a) {
+void f(A a) {
a.fff = 20;
a.fff += 30;
- print(a.fff); // in main()
- a.fff(); // in main()
+ print(a.fff); // in f()
+ a.fff(); // in f()
}
''');
await findElementReferences('fff; // declaration', false);
@@ -174,11 +174,11 @@
assertHasResult(SearchResultKind.WRITE, 'fff += 3;');
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.READ, 'fff(); // in m()');
- // main()
+ // f()
assertHasResult(SearchResultKind.WRITE, 'fff = 20;');
assertHasResult(SearchResultKind.WRITE, 'fff += 30;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
- assertHasResult(SearchResultKind.READ, 'fff(); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
+ assertHasResult(SearchResultKind.READ, 'fff(); // in f()');
}
Future<void> test_field_implicit() async {
@@ -191,8 +191,8 @@
fff = 1;
}
}
-main(A a) {
- print(a.fff); // in main()
+void f(A a) {
+ print(a.fff); // in f()
a.fff = 10;
}
''');
@@ -202,7 +202,7 @@
expect(results, hasLength(4));
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
}
{
@@ -210,7 +210,7 @@
expect(results, hasLength(4));
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
}
}
@@ -247,11 +247,11 @@
}
}
-main() {
+void f() {
E.fff = 20;
E.fff += 30;
- print(E.fff); // in main()
- E.fff(); // in main()
+ print(E.fff); // in f()
+ E.fff(); // in f()
}
''');
await findElementReferences('fff; // declaration', false);
@@ -262,11 +262,11 @@
assertHasResult(SearchResultKind.WRITE, 'fff += 3;');
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.READ, 'fff(); // in m()');
- // main()
+ // f()
assertHasResult(SearchResultKind.WRITE, 'fff = 20;');
assertHasResult(SearchResultKind.WRITE, 'fff += 30;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
- assertHasResult(SearchResultKind.READ, 'fff(); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
+ assertHasResult(SearchResultKind.READ, 'fff(); // in f()');
}
Future<void> test_field_ofExtension_implicit_instance() async {
@@ -279,8 +279,8 @@
fff = 1;
}
}
-main() {
- print(0.fff); // in main()
+void f() {
+ print(0.fff); // in f()
0.fff = 10;
}
''');
@@ -290,7 +290,7 @@
expect(results, hasLength(4));
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
}
{
@@ -298,7 +298,7 @@
expect(results, hasLength(4));
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
}
}
@@ -313,8 +313,8 @@
fff = 1;
}
}
-main() {
- print(E.fff); // in main()
+void f() {
+ print(E.fff); // in f()
E.fff = 10;
}
''');
@@ -324,7 +324,7 @@
expect(results, hasLength(4));
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
}
{
@@ -332,7 +332,7 @@
expect(results, hasLength(4));
assertHasResult(SearchResultKind.READ, 'fff); // in m()');
assertHasResult(SearchResultKind.WRITE, 'fff = 1;');
- assertHasResult(SearchResultKind.READ, 'fff); // in main()');
+ assertHasResult(SearchResultKind.READ, 'fff); // in f()');
assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
}
}
@@ -340,7 +340,7 @@
Future<void> test_function() async {
addTestFile('''
fff(p) {}
-main() {
+void f() {
fff(1);
print(fff);
}
@@ -363,7 +363,7 @@
class C extends B {
int fff; // in C
}
- main(A a, B b, C c) {
+ void f(A a, B b, C c) {
a.fff = 10;
b.fff = 20;
c.fff = 30;
@@ -387,7 +387,7 @@
class C extends B {
mmm(_) {} // in C
}
-main(A a, B b, C c) {
+void f(A a, B b, C c) {
a.mmm(10);
b.mmm(20);
c.mmm(30);
@@ -411,7 +411,7 @@
class C extends B {
static void mmm(_) {} // in C
}
-main() {
+void f() {
A.mmm(10);
B.mmm(20);
C.mmm(30);
@@ -434,7 +434,7 @@
class C extends B {
m({p}) {} // in C
}
-main(A a, B b, C c) {
+void f(A a, B b, C c) {
a.m(p: 1);
b.m(p: 2);
c.m(p: 3);
@@ -449,7 +449,7 @@
Future<void> test_label() async {
addTestFile('''
-main() {
+void f() {
myLabel:
for (int i = 0; i < 10; i++) {
if (i == 2) {
@@ -468,7 +468,7 @@
Future<void> test_localVariable() async {
addTestFile('''
-main() {
+void f() {
var vvv = 1;
print(vvv);
vvv += 3;
@@ -494,9 +494,9 @@
print(mmm); // in m()
}
}
-main(A a) {
+void f(A a) {
a.mmm(10);
- print(a.mmm); // in main()
+ print(a.mmm); // in f()
}
''');
await findElementReferences('mmm(p) {}', false);
@@ -505,7 +505,7 @@
assertHasResult(SearchResultKind.INVOCATION, 'mmm(1);');
assertHasResult(SearchResultKind.REFERENCE, 'mmm); // in m()');
assertHasResult(SearchResultKind.INVOCATION, 'mmm(10);');
- assertHasResult(SearchResultKind.REFERENCE, 'mmm); // in main()');
+ assertHasResult(SearchResultKind.REFERENCE, 'mmm); // in f()');
}
Future<void> test_method_ofExtension() async {
@@ -514,7 +514,7 @@
void foo() {}
}
-main() {
+void f() {
E(0).foo(); // 1
E(0).foo; // 2
0.foo(); // 3
@@ -535,7 +535,7 @@
class A {
mmm(p) {}
}
-main() {
+void f() {
var a = new A();
a.mmm(10);
print(a.mmm);
@@ -561,7 +561,7 @@
Future<void> test_noElement() async {
addTestFile('''
-main() {
+void f() {
print(noElement);
}
''');
@@ -573,7 +573,7 @@
addTestFile('''
part of lib;
fff(p) {}
-main() {
+void f() {
fff(10);
}
''');
@@ -584,7 +584,7 @@
Future<void> test_parameter() async {
addTestFile('''
-main(ppp) {
+void f(ppp) {
print(ppp);
ppp += 3;
ppp = 2;
@@ -692,7 +692,7 @@
addTestFile('''
library my_lib;
class A {}
-main() {
+void f() {
A a = null;
}
''');
@@ -700,7 +700,7 @@
assertHasResult(SearchResultKind.REFERENCE, 'A a = null;');
expect(getPathString(result.path), '''
LOCAL_VARIABLE a
-FUNCTION main
+FUNCTION f
COMPILATION_UNIT test.dart
LIBRARY my_lib''');
}
@@ -710,7 +710,7 @@
class A {
test(p) {}
}
-main(A a, p) {
+void f(A a, p) {
a.test(1);
p.test(2);
}
@@ -725,7 +725,7 @@
class A {
var test; // declaration
}
-main(A a, p) {
+void f(A a, p) {
a.test = 1;
p.test = 2;
print(p.test); // p
@@ -751,7 +751,7 @@
class A {
test(p) {}
}
-main(A a, p) {
+void f(A a, p) {
a.test(1);
p.test(2);
}
@@ -793,7 +793,7 @@
Future<void> test_prefix() async {
addTestFile('''
import 'dart:async' as ppp;
-main() {
+void f() {
ppp.Future a;
ppp.Stream b;
}
@@ -811,7 +811,7 @@
Future<void> test_topLevelVariable_explicit() async {
addTestFile('''
var vvv = 1;
-main() {
+void f() {
print(vvv);
vvv += 3;
vvv = 2;
@@ -831,7 +831,7 @@
addTestFile('''
get vvv => null;
set vvv(x) {}
-main() {
+void f() {
print(vvv);
vvv = 1;
}
@@ -853,7 +853,7 @@
Future<void> test_typeReference_class() async {
addTestFile('''
-main() {
+void f() {
int a = 1;
int b = 2;
}
@@ -867,7 +867,7 @@
Future<void> test_typeReference_typeAlias_functionType() async {
addTestFile('''
typedef F = Function();
-main(F f) {
+void f(F f) {
}
''');
await findElementReferences('F =', false);
@@ -897,7 +897,7 @@
Future<void> test_typeReference_typeAlias_legacy() async {
addTestFile('''
typedef F();
-main(F f) {
+void f(F f) {
}
''');
await findElementReferences('F()', false);
diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
index cf8d182..d37b156 100644
--- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart
@@ -74,7 +74,7 @@
addTestSource('''
import 'b.dart';
-void main() {f^}''');
+void f() {f^}''');
await computeSuggestions();
assertSuggestFunction('foo', 'bool', defaultArgListString: 'bar, baz: baz');
@@ -90,7 +90,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {expect(^)}''');
+ void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -100,7 +100,7 @@
assertSuggestFunction('identical', 'bool');
assertNotSuggested('B');
assertSuggestClass('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -116,7 +116,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {expect(^)}''');
+ void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -126,7 +126,7 @@
assertSuggestFunction('identical', 'bool');
assertNotSuggested('B');
assertSuggestClass('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -144,7 +144,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {new A(^)}''');
+ void f() {new A(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -157,7 +157,7 @@
assertNotSuggested('B');
assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -175,7 +175,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {new A(^)}''');
+ void f() {new A(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -188,7 +188,7 @@
assertNotSuggested('B');
assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -204,7 +204,7 @@
expect(arg) { }
class B { }
String bar() => true;
- void main() {expect(^)}''');
+ void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -214,7 +214,7 @@
assertSuggestFunction('identical', 'bool');
assertNotSuggested('B');
assertSuggestClass('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -240,7 +240,7 @@
assertSuggestFunction('identical', 'bool');
assertNotSuggested('B');
assertSuggestClass('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -257,7 +257,7 @@
import 'a.dart';
class B { }
String bar(f()) => true;
- void main() {bar(^);}''');
+ void f() {bar(^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -270,7 +270,7 @@
assertNotSuggested('B');
assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -286,7 +286,7 @@
import 'dart:async';
import 'a.dart';
class B { String bar(f()) => true; }
- void main() {new B().bar(^);}''');
+ void f() {new B().bar(^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -298,7 +298,7 @@
assertNotSuggested('B');
assertSuggestClass('A', kind: CompletionSuggestionKind.IDENTIFIER);
assertSuggestClass('Object', kind: CompletionSuggestionKind.IDENTIFIER);
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -312,7 +312,7 @@
addTestSource('''
import 'a.dart';
String bar() => true;
- void main() {expect(foo: ^)}''');
+ void f() {expect(foo: ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -324,7 +324,7 @@
// the world (which it should not) and causes the imported library
// to be resolved.
assertSuggestFunction('hasLength', /* null */ 'bool');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_AsExpression() async {
@@ -355,7 +355,7 @@
class X {X.c(); X._d(); z() {}}''');
addTestSource('''
import 'b.dart';
- main(){A a; if (a as ^)}''');
+ void f(){A a; if (a as ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -366,7 +366,7 @@
assertNotSuggested('X');
assertNotSuggested('Object');
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
@failingTest
@@ -382,7 +382,7 @@
class X {X.c(); X._d(); z() {}}''');
addTestSource('''
import 'b.dart';
- main(){A a; if (a as ^)}''');
+ void f(){A a; if (a as ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -393,13 +393,13 @@
assertNotSuggested('X');
assertNotSuggested('Object');
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_AssignmentExpression_name() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
- addTestSource('class A {} main() {int a; int ^b = 1;}');
+ addTestSource('class A {} void f() {int a; int ^b = 1;}');
await computeSuggestions();
assertNoSuggestions();
@@ -408,13 +408,13 @@
Future<void> test_AssignmentExpression_RHS() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
- addTestSource('class A {} main() {int a; int b = ^}');
+ addTestSource('class A {} void f() {int a; int b = ^}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertSuggestClass('Object');
}
@@ -423,7 +423,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
^ b = 1;}''');
@@ -438,7 +438,7 @@
// Consider suggesting only types
// if only spaces separates the 1st and 2nd identifiers.
//assertNotSuggested('a');
- //assertNotSuggested('main');
+ //assertNotSuggested('f');
//assertNotSuggested('identical');
}
@@ -446,7 +446,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
^
b = 1;}''');
@@ -460,7 +460,7 @@
// if newline follows first identifier
// because user is probably starting a new statement
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertSuggestFunction('identical', 'bool');
}
@@ -468,7 +468,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
int^ b = 1;}''');
@@ -483,7 +483,7 @@
// Consider suggesting only types
// if only spaces separates the 1st and 2nd identifiers.
//assertNotSuggested('a');
- //assertNotSuggested('main');
+ //assertNotSuggested('f');
//assertNotSuggested('identical');
}
@@ -491,7 +491,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
i^
b = 1;}''');
@@ -505,7 +505,7 @@
// if newline follows first identifier
// because user is probably starting a new statement
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertSuggestFunction('identical', 'bool');
}
@@ -513,13 +513,13 @@
// SimpleIdentifier AwaitExpression ExpressionStatement
addTestSource('''
class A {int x; int y() => 0;}
- main() async {A a; await ^}''');
+ void f() async {A a; await ^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertSuggestClass('Object');
}
@@ -561,7 +561,7 @@
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertSuggestClass('A');
if (suggestConstructorsWithoutNew) {
assertSuggestConstructor('A');
@@ -573,7 +573,7 @@
Future<void> test_BinaryExpression_LHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
- addTestSource('main() {int a = 1, b = ^ + 2;}');
+ addTestSource('void f() {int a = 1, b = ^ + 2;}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -586,7 +586,7 @@
Future<void> test_BinaryExpression_RHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
- addTestSource('main() {int a = 1, b = 2 + ^;}');
+ addTestSource('void f() {int a = 1, b = 2 + ^;}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -800,14 +800,14 @@
}
Future<void> test_Block_final2() async {
- addTestSource('main() {final S^ v;}');
+ addTestSource('void f() {final S^ v;}');
await computeSuggestions();
assertSuggestClass('String');
}
Future<void> test_Block_final3() async {
- addTestSource('main() {final ^ v;}');
+ addTestSource('void f() {final ^ v;}');
await computeSuggestions();
assertSuggestClass('String');
@@ -1236,7 +1236,7 @@
Future<void> test_Block_unimported() async {
newFile('$testPackageLibPath/a.dart', content: 'class A {}');
- addTestSource('main() { ^ }');
+ addTestSource('void f() { ^ }');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1257,7 +1257,7 @@
class X{}
// looks like a cascade to the parser
// but the user is trying to get completions for a non-cascade
- main() {A a; a.^.z}''');
+ void f() {A a; a.^.z}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1280,7 +1280,7 @@
import 'b.dart';
class A {var b; X _c;}
class X{}
- main() {A a; a..^z}''');
+ void f() {A a; a..^z}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1303,7 +1303,7 @@
import 'b.dart';
class A {var b; X _c;}
class X{}
- main() {A a; a..^ return}''');
+ void f() {A a; a..^ return}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1323,7 +1323,7 @@
addTestSource('''
class A {var b; X _c;}
class X{}
- main() {A a; a^..b}''');
+ void f() {A a; a^..b}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -1699,7 +1699,7 @@
addTestSource('''
import 'b.dart';
var m;
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1724,7 +1724,7 @@
addTestSource('''
import 'b.dart';
var m;
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1742,7 +1742,7 @@
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('''
- main() {new String.fr^omCharCodes([]);}''');
+ void f() {new String.fr^omCharCodes([]);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 2);
@@ -1763,7 +1763,7 @@
int T1;
F1() { }
class X {X.c(); X._d(); z() {}}
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1784,7 +1784,7 @@
int T1;
F1() { }
class X {factory X.c(); factory X._d(); z() {}}
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1825,7 +1825,7 @@
/// Longer description.
class A {}
''');
- addTestSource('import "a.dart"; main() {^}');
+ addTestSource('import "a.dart"; void f() {^}');
await computeSuggestions();
@@ -1847,7 +1847,7 @@
/// Longer description.
int myFunc() {}
''');
- addTestSource('import "a.dart"; main() {^}');
+ addTestSource('import "a.dart"; void f() {^}');
await computeSuggestions();
@@ -1868,7 +1868,7 @@
*/
int myFunc() {}
''');
- addTestSource('import "a.dart"; main() {^}');
+ addTestSource('import "a.dart"; void f() {^}');
await computeSuggestions();
@@ -1880,7 +1880,7 @@
Future<void> test_enum() async {
addSource('/home/test/lib/a.dart', 'library A; enum E { one, two }');
- addTestSource('import "a.dart"; main() {^}');
+ addTestSource('import "a.dart"; void f() {^}');
await computeSuggestions();
assertSuggestEnum('E');
assertNotSuggested('one');
@@ -1890,7 +1890,7 @@
Future<void> test_enum_deprecated() async {
addSource(
'/home/test/lib/a.dart', 'library A; @deprecated enum E { one, two }');
- addTestSource('import "a.dart"; main() {^}');
+ addTestSource('import "a.dart"; void f() {^}');
await computeSuggestions();
// TODO(danrube) investigate why suggestion/element is not deprecated
// when AST node has correct @deprecated annotation
@@ -1909,7 +1909,7 @@
void foo({E e}) {}
-main() {
+void f() {
foo(e: ^);
}
''');
@@ -2122,7 +2122,7 @@
Future<void> test_ForEachStatement_body_typed() async {
// Block ForEachStatement
- addTestSource('main(args) {for (int foo in bar) {^}}');
+ addTestSource('void f(args) {for (int foo in bar) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2134,7 +2134,7 @@
Future<void> test_ForEachStatement_body_untyped() async {
// Block ForEachStatement
- addTestSource('main(args) {for (foo in bar) {^}}');
+ addTestSource('void f(args) {for (foo in bar) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2146,7 +2146,7 @@
Future<void> test_ForEachStatement_iterable() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (int foo in ^) {}}');
+ addTestSource('void f(args) {for (int foo in ^) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2157,7 +2157,7 @@
Future<void> test_ForEachStatement_loopVariable() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (^ in args) {}}');
+ addTestSource('void f(args) {for (^ in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2168,7 +2168,7 @@
Future<void> test_ForEachStatement_loopVariable_type() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (^ foo in args) {}}');
+ addTestSource('void f(args) {for (^ foo in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2180,7 +2180,7 @@
Future<void> test_ForEachStatement_loopVariable_type2() async {
// DeclaredIdentifier ForEachStatement Block
- addTestSource('main(args) {for (S^ foo in args) {}}');
+ addTestSource('void f(args) {for (S^ foo in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2210,7 +2210,7 @@
Future<void> test_ForStatement_body() async {
// Block ForStatement
- addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
+ addTestSource('void f(args) {for (int i; i < 10; ++i) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2221,7 +2221,7 @@
Future<void> test_ForStatement_condition() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; i^)}');
+ addTestSource('void f() {for (int index = 0; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2232,7 +2232,7 @@
Future<void> test_ForStatement_initializer() async {
addTestSource('''
import 'dart:math';
-main() {
+void f() {
List localVar;
for (^) {}
}
@@ -2248,20 +2248,20 @@
}
Future<void> test_ForStatement_initializer_variableName_afterType() async {
- addTestSource('main() { for (String ^) }');
+ addTestSource('void f() { for (String ^) }');
await computeSuggestions();
assertNotSuggested('int');
}
Future<void> test_ForStatement_typing_inKeyword() async {
- addTestSource('main() { for (var v i^) }');
+ addTestSource('void f() { for (var v i^) }');
await computeSuggestions();
assertNotSuggested('int');
}
Future<void> test_ForStatement_updaters() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; index < 10; i^)}');
+ addTestSource('void f() {for (int index = 0; index < 10; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2273,13 +2273,13 @@
// SimpleIdentifier PrefixExpression ForStatement
addTestSource('''
void bar() { }
- main() {for (int index = 0; index < 10; ++i^)}''');
+ void f() {for (int index = 0; index < 10; ++i^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
assertNotSuggested('index');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('bar');
}
@@ -2290,7 +2290,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -2313,7 +2313,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -2336,7 +2336,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -2359,7 +2359,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
@@ -2378,7 +2378,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -2401,7 +2401,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -2534,7 +2534,7 @@
addTestSource(r'''
import 'a.dart';
-main() {
+void f() {
^
}
''');
@@ -2550,7 +2550,7 @@
addTestSource(r'''
import 'a.dart';
-main() {
+void f() {
^
}
''');
@@ -2578,13 +2578,13 @@
// SimpleIdentifier IfStatement Block BlockFunctionBody
addTestSource('''
class A {int x; int y() => 0;}
- main(){var a; if (^)}''');
+ void f(){var a; if (^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertSuggestClass('Object');
}
@@ -2607,7 +2607,7 @@
Future<void> test_IfStatement_invocation() async {
// SimpleIdentifier PrefixIdentifier IfStatement
addTestSource('''
- main() {var a; if (a.^) something}''');
+ void f() {var a; if (a.^) something}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2619,7 +2619,7 @@
}
Future<void> test_IfStatement_typing_isKeyword() async {
- addTestSource('main() { if (v i^) }');
+ addTestSource('void f() { if (v i^) }');
await computeSuggestions();
assertNotSuggested('int');
}
@@ -2649,7 +2649,7 @@
addTestSource('''
import 'a.dart';
-main() {
+void f() {
^;
}
''');
@@ -2668,7 +2668,7 @@
// SimpleStringLiteral ImportDirective
addTestSource('''
import "dart^";
- main() {}''');
+ void f() {}''');
await computeSuggestions();
assertNoSuggestions();
@@ -2731,7 +2731,7 @@
addTestSource('''
import 'a.dart';
import "dart:math" as math;
-main() {new ^ String x = "hello";}''');
+void f() {new ^ String x = "hello";}''');
await computeSuggestions();
CompletionSuggestion suggestion;
@@ -2788,7 +2788,7 @@
addTestSource('''
import 'a.dart';
-main() {
+void f() {
new ^;
}
''');
@@ -2807,7 +2807,7 @@
addTestSource('''
import 'a.dart';
-main() {
+void f() {
new ^;
}
''');
@@ -2826,7 +2826,7 @@
addTestSource('''
import 'a.dart';
-main() {
+void f() {
A a = new ^
}
''');
@@ -2895,7 +2895,7 @@
}
Future<void> test_internal_sdk_libs() async {
- addTestSource('main() {p^}');
+ addTestSource('void f() {p^}');
await computeSuggestions();
assertSuggest('print');
@@ -2918,7 +2918,7 @@
F2() { }
typedef D2();
class C2 { }
- main() {String name; print("hello \$^");}''');
+ void f() {String name; print("hello \$^");}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2952,7 +2952,7 @@
F2() { }
typedef D2();
class C2 { }
- main() {String name; print("hello \${^}");}''');
+ void f() {String name; print("hello \${^}");}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2974,7 +2974,7 @@
Future<void> test_InterpolationExpression_block2() async {
// SimpleIdentifier InterpolationExpression StringInterpolation
- addTestSource('main() {String name; print("hello \${n^}");}');
+ addTestSource('void f() {String name; print("hello \${n^}");}');
await computeSuggestions();
assertNotSuggested('name');
@@ -2984,7 +2984,7 @@
Future<void> test_InterpolationExpression_prefix_selector() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \${name.^}");}');
+ addTestSource('void f() {String name; print("hello \${name.^}");}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2997,7 +2997,7 @@
Future<void> test_InterpolationExpression_prefix_selector2() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \$name.^");}');
+ addTestSource('void f() {String name; print("hello \$name.^");}');
await computeSuggestions();
assertNoSuggestions();
@@ -3005,7 +3005,7 @@
Future<void> test_InterpolationExpression_prefix_target() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \${nam^e.length}");}');
+ addTestSource('void f() {String name; print("hello \${nam^e.length}");}');
await computeSuggestions();
assertNotSuggested('name');
@@ -3023,7 +3023,7 @@
addTestSource('''
import 'b.dart';
class Y {Y.c(); Y._d(); z() {}}
- main() {var x; if (x is ^) { }}''');
+ void f() {var x; if (x is ^) { }}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3031,7 +3031,7 @@
assertSuggestClass('X');
assertNotSuggested('Y');
assertNotSuggested('x');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('foo');
}
@@ -3041,13 +3041,13 @@
foo() { }
void bar() { }
class A {int x; int y() => 0;}
- main(){var a; if (^ is A)}''');
+ void f(){var a; if (^ is A)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('foo');
assertNotSuggested('bar');
assertNotSuggested('A');
@@ -3058,13 +3058,13 @@
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('''
class A {int x; int y() => 0;}
- main(){var a; if (a is ^)}''');
+ void f(){var a; if (a is ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertSuggestClass('Object');
}
@@ -3073,13 +3073,13 @@
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('''
class A {int x; int y() => 0;}
- main(){var a; if (a is Obj^)}''');
+ void f(){var a; if (a is Obj^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 3);
expect(replacementLength, 3);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertSuggestClass('Object');
}
@@ -3097,7 +3097,7 @@
class X {X.c(); X._d(); z() {}}''');
addTestSource('''
import 'b.dart';
- main(){A a; if (a is ^)}''');
+ void f(){A a; if (a is ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3108,7 +3108,7 @@
assertNotSuggested('X');
assertNotSuggested('Object');
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
@failingTest
@@ -3124,7 +3124,7 @@
class X {X.c(); X._d(); z() {}}''');
addTestSource('''
import 'b.dart';
- main(){A a; if (a is ^)}''');
+ void f(){A a; if (a is ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3135,7 +3135,7 @@
assertNotSuggested('X');
assertNotSuggested('Object');
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_keyword() async {
@@ -3149,7 +3149,7 @@
import 'b.dart';
String newer() {}
var m;
- main() {new^ X.c();}''');
+ void f() {new^ X.c();}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 3);
@@ -3167,7 +3167,7 @@
Future<void> test_Literal_list() async {
// ']' ListLiteral ArgumentList MethodInvocation
- addTestSource('main() {var Some; print([^]);}');
+ addTestSource('void f() {var Some; print([^]);}');
await computeSuggestions();
assertNotSuggested('Some');
@@ -3176,7 +3176,7 @@
Future<void> test_Literal_list2() async {
// SimpleIdentifier ListLiteral ArgumentList MethodInvocation
- addTestSource('main() {var Some; print([S^]);}');
+ addTestSource('void f() {var Some; print([S^]);}');
await computeSuggestions();
assertNotSuggested('Some');
@@ -3192,9 +3192,9 @@
}
Future<void> test_localVariableDeclarationName() async {
- addTestSource('main() {String m^}');
+ addTestSource('void f() {String m^}');
await computeSuggestions();
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('min');
}
@@ -3292,7 +3292,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3315,7 +3315,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3338,7 +3338,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3361,7 +3361,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
@@ -3380,7 +3380,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3403,7 +3403,7 @@
addTestSource('''
import 'a.dart';
class B {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3642,7 +3642,7 @@
Future<void> test_MethodInvocation_no_semicolon() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
var b; X _c;
@@ -3693,7 +3693,7 @@
assertSuggestClass('Object');
assertSuggestClass('bool');
// etc.
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_MethodTypeArgumentList_2() async {
@@ -3710,7 +3710,7 @@
assertSuggestClass('Object');
assertSuggestClass('bool');
// etc.
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_mixin_ordering() async {
@@ -3754,7 +3754,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3769,7 +3769,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3784,7 +3784,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3815,7 +3815,7 @@
addTestSource('''
part of libA;
class B { B.bar(int x); }
- main() {new ^}''');
+ void f() {new ^}''');
await resolveFile('$testPackageLibPath/a.dart');
@@ -3851,7 +3851,7 @@
import 'b.dart';
part "a.dart";
class A { A({String boo: 'hoo'}) { } }
- main() {new ^}
+ void f() {new ^}
var m;''');
await computeSuggestions();
@@ -3891,7 +3891,7 @@
class A extends B {
static const String scA = 'foo';
w() { }}
- main() {A.^}''');
+ void f() {A.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3932,7 +3932,7 @@
class X{}''');
addTestSource('''
import 'b.dart';
- main() {A a; a.^}''');
+ void f() {A a; a.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3958,7 +3958,7 @@
Future<void> test_PrefixedIdentifier_class_local() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('''
- main() {A a; a.^}
+ void f() {A a; a.^}
class I {X get f => new A();get _g => new A();}
class A implements I {
static const int sc = 12;
@@ -4008,7 +4008,7 @@
import "b.dart" as b;
var T2;
class A { }
- main() {b.^}''');
+ void f() {b.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -4255,7 +4255,7 @@
Future<void> test_PropertyAccess_noTarget2() async {
// SimpleIdentifier PropertyAccess ExpressionStatement
addSource('/home/test/lib/ab.dart', 'class Foo { }');
- addTestSource('main() {.^}');
+ addTestSource('void f() {.^}');
await computeSuggestions();
assertNoSuggestions();
@@ -4305,7 +4305,7 @@
Future<void> test_ThisExpression_block() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A() {}
@@ -4341,7 +4341,7 @@
Future<void> test_ThisExpression_constructor() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A() {this.^}
@@ -4377,7 +4377,7 @@
Future<void> test_ThisExpression_constructor_param() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.^) {}
@@ -4415,7 +4415,7 @@
Future<void> test_ThisExpression_constructor_param2() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.b^) {}
@@ -4452,7 +4452,7 @@
Future<void> test_ThisExpression_constructor_param3() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.^b) {}
@@ -4489,7 +4489,7 @@
Future<void> test_ThisExpression_constructor_param4() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.b, this.^) {}
@@ -4668,7 +4668,7 @@
F2() => 0;
typedef int T2(int blat);
class C<E> {}
- main() { C<^> c; }''');
+ void f() { C<^> c; }''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -4695,7 +4695,7 @@
F2() => 0;
typedef int T2(int blat);
class C<E> {}
- main() { C<C^> c; }''');
+ void f() { C<C^> c; }''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -4735,7 +4735,7 @@
addTestSource('''
import 'b.dart';
class Y {Y.c(); Y._d(); z() {}}
- main() {var ^}''');
+ void f() {var ^}''');
await computeSuggestions();
assertNoSuggestions();
@@ -4743,7 +4743,7 @@
Future<void> test_VariableDeclarationList_final() async {
// VariableDeclarationList VariableDeclarationStatement Block
- addTestSource('main() {final ^} class C { }');
+ addTestSource('void f() {final ^} class C { }');
await computeSuggestions();
assertSuggestClass('Object');
@@ -4820,7 +4820,7 @@
Future<void> test_YieldStatement() async {
addTestSource('''
-void main() async* {
+void f() async* {
yield ^
}
''');
@@ -4843,7 +4843,7 @@
addTestSource('''
import 'a.dart';
-main() {^}
+void f() {^}
''');
await computeSuggestions();
var suggestion = assertSuggestFunction('m', 'void');
@@ -4867,7 +4867,7 @@
// @dart = 2.8
import 'a.dart';
-main() {^}
+void f() {^}
''');
await computeSuggestions();
var suggestion = assertSuggestFunction('m', 'void');
@@ -4891,7 +4891,7 @@
addTestSource('''
import 'a.dart';
-main() {^}
+void f() {^}
''');
await computeSuggestions();
var suggestion = assertSuggestFunction('m', 'void');
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index 982c6e5..678619f 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -29,7 +29,7 @@
Future<void> test_ArgDefaults_function() async {
addTestSource('''
bool hasLength(int a, bool b) => false;
-void main() {h^}''');
+void f() {h^}''');
await computeSuggestions();
assertSuggestFunction('hasLength', 'bool',
@@ -40,7 +40,7 @@
Future<void> test_ArgDefaults_function_none() async {
addTestSource('''
bool hasLength() => false;
-void main() {h^}''');
+void f() {h^}''');
await computeSuggestions();
assertSuggestFunction('hasLength', 'bool',
@@ -53,7 +53,7 @@
import 'package:meta/meta.dart';
bool foo(int bar, [bool boo, int baz]) => false;
-void main() {h^}''');
+void f() {h^}''');
await computeSuggestions();
assertSuggestFunction('foo', 'bool',
@@ -66,7 +66,7 @@
import 'package:meta/meta.dart';
bool foo(int bar, {bool boo, @required int baz}) => false;
-void main() {h^}''');
+void f() {h^}''');
await computeSuggestions();
assertSuggestFunction('foo', 'bool',
@@ -123,7 +123,7 @@
import 'a.dart';;
class B { }
String bar() => true;
-void main() {expect(^)}''');
+void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -133,7 +133,7 @@
assertNotSuggested('identical');
assertSuggestClass('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -149,7 +149,7 @@
import 'a.dart';
class B { }
String bar() => true;
-void main() {expect(^)}''');
+void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -159,7 +159,7 @@
assertNotSuggested('identical');
assertSuggestClass('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -177,7 +177,7 @@
import 'a.dart';;
class B { }
String bar() => true;
-void main() {new A(^)}''');
+void f() {new A(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -189,7 +189,7 @@
assertSuggestClass('B', kind: CompletionSuggestionKind.IDENTIFIER);
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -207,7 +207,7 @@
import 'a.dart';;
class B { }
String bar() => true;
-void main() {new A(^)}''');
+void f() {new A(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -219,7 +219,7 @@
assertSuggestClass('B', kind: CompletionSuggestionKind.IDENTIFIER);
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -235,7 +235,7 @@
expect(arg) { }
class B { }
String bar() => true;
-void main() {expect(^)}''');
+void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -271,7 +271,7 @@
assertNotSuggested('identical');
assertSuggestClass('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -288,7 +288,7 @@
import 'a.dart';;
class B { }
String bar(f()) => true;
-void main() {boo(){} bar(^);}''');
+void f() {boo(){} bar(^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -302,7 +302,7 @@
assertSuggestClass('B', kind: CompletionSuggestionKind.IDENTIFIER);
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -319,7 +319,7 @@
import 'a.dart';;
class B { }
String bar({inc()}) => true;
-void main() {boo(){} bar(inc: ^);}''');
+void f() {boo(){} bar(inc: ^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -354,7 +354,7 @@
import 'dart:async';
import 'a.dart';;
class B { String bar(f()) => true; }
-void main() {new B().bar(^);}''');
+void f() {new B().bar(^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -364,7 +364,7 @@
assertSuggestClass('B', kind: CompletionSuggestionKind.IDENTIFIER);
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -407,14 +407,14 @@
addTestSource('''
import 'a.dart';
String bar() => true;
-void main() {expect(foo: ^)}''');
+void f() {expect(foo: ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertSuggestFunction('bar', 'String');
assertNotSuggested('hasLength');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_ArgumentList_namedParam_filter() async {
@@ -602,7 +602,7 @@
Future<void> test_AssignmentExpression_name() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
- addTestSource('class A {} main() {int a; int ^b = 1;}');
+ addTestSource('class A {} void f() {int a; int ^b = 1;}');
await computeSuggestions();
assertNoSuggestions();
@@ -611,13 +611,13 @@
Future<void> test_AssignmentExpression_RHS() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
- addTestSource('class A {} main() {int a; int b = ^}');
+ addTestSource('class A {} f() {int a; int b = ^}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertSuggestLocalVariable('a', 'int');
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertSuggestClass('A');
assertNotSuggested('Object');
}
@@ -626,7 +626,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
-class A {} main() {
+class A {} void f() {
int a;
^ b = 1;
}''');
@@ -642,7 +642,7 @@
// Consider suggesting only types
// if only spaces separates the 1st and 2nd identifiers.
//assertNotSuggested('a');
- //assertNotSuggested('main');
+ //assertNotSuggested('f');
//assertNotSuggested('identical');
}
@@ -650,7 +650,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
-class A {} main() {
+class A {} void f() {
int a;
^
b = 1;
@@ -665,7 +665,7 @@
// if newline follows first identifier
// because user is probably starting a new statement
assertSuggestLocalVariable('a', 'int');
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertNotSuggested('identical');
}
@@ -673,7 +673,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
-class A {} main() {
+class A {} void f() {
int a;
int^ b = 1;
}''');
@@ -689,7 +689,7 @@
// Consider suggesting only types
// if only spaces separates the 1st and 2nd identifiers.
//assertNotSuggested('a');
- //assertNotSuggested('main');
+ //assertNotSuggested('f');
//assertNotSuggested('identical');
}
@@ -697,7 +697,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
-class A {} main() {
+class A {} void f() {
int a;
i^
b = 1;
@@ -712,7 +712,7 @@
// if newline follows first identifier
// because user is probably starting a new statement
assertSuggestLocalVariable('a', 'int');
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertNotSuggested('identical');
}
@@ -720,13 +720,13 @@
// SimpleIdentifier AwaitExpression ExpressionStatement
addTestSource('''
class A {int x; int y() => 0;}
-main() async {A a; await ^}''');
+f() async {A a; await ^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertSuggestLocalVariable('a', 'A');
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertSuggestClass('A');
assertNotSuggested('Object');
}
@@ -777,7 +777,7 @@
Future<void> test_BinaryExpression_LHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
- addTestSource('main() {int a = 1, b = ^ + 2;}');
+ addTestSource('void f() {int a = 1, b = ^ + 2;}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -794,7 +794,7 @@
Future<void> test_BinaryExpression_RHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
- addTestSource('main() {int a = 1, b = 2 + ^;}');
+ addTestSource('void f() {int a = 1, b = 2 + ^;}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -998,14 +998,14 @@
}
Future<void> test_Block_final2() async {
- addTestSource('main() {final S^ v;}');
+ addTestSource('void f() {final S^ v;}');
await computeSuggestions();
assertNotSuggested('String');
}
Future<void> test_Block_final3() async {
- addTestSource('main() {final ^ v;}');
+ addTestSource('void f() {final ^ v;}');
await computeSuggestions();
assertNotSuggested('String');
@@ -1497,7 +1497,7 @@
addTestSource('''
set foo() {}
-void main() {
+void f() {
^
}
''');
@@ -1508,7 +1508,7 @@
Future<void> test_Block_unimported() async {
newFile('$testPackageLibPath/a.dart', content: 'class A {}');
- addTestSource('main() { ^ }');
+ addTestSource('void f() { ^ }');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1529,7 +1529,7 @@
class X{}
// looks like a cascade to the parser
// but the user is trying to get completions for a non-cascade
-main() {A a; a.^.z}''');
+void f() {A a; a.^.z}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1552,7 +1552,7 @@
import "b.dart";
class A {var b; X _c;}
class X{}
-main() {A a; a..^z}''');
+void f() {A a; a..^z}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1575,7 +1575,7 @@
import "b.dart";
class A {var b; X _c;}
class X{}
-main() {A a; a..^ return}''');
+void f() {A a; a..^ return}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1595,7 +1595,7 @@
addTestSource('''
class A {var b; X _c;}
class X{}
-main() {A a; a^..b}''');
+void f() {A a; a^..b}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2071,7 +2071,7 @@
addTestSource('''
import "b.dart";
var m;
-main() {new X.^}''');
+void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2096,7 +2096,7 @@
addTestSource('''
import "b.dart";
var m;
-main() {new X.^}''');
+void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2114,7 +2114,7 @@
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('''
- main() {new String.fr^omCharCodes([]);}''');
+ void f() {new String.fr^omCharCodes([]);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 2);
@@ -2135,7 +2135,7 @@
int T1;
F1() { }
class X {X.c(); X._d(); z() {}}
-main() {new X.^}''');
+void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2156,7 +2156,7 @@
int T1;
F1() { }
class X {factory X.c(); factory X._d(); z() {}}
-main() {new X.^}''');
+void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2211,7 +2211,7 @@
$docLines
int get myGetter => 0;
- main() {^}
+ void f() {^}
}''');
await computeSuggestions();
{
@@ -2243,7 +2243,7 @@
/// With an additional line.
int x = 0;
-void main() {^}
+void f() {^}
''');
await computeSuggestions();
var suggestion = assertSuggestTopLevelVar('x', 'int');
@@ -2281,7 +2281,7 @@
$docLines
int myVariable;
-main() {^}
+void f() {^}
''');
await computeSuggestions();
{
@@ -2307,7 +2307,7 @@
}
Future<void> test_enum() async {
- addTestSource('enum E { one, two } main() {^}');
+ addTestSource('enum E { one, two } void f() {^}');
await computeSuggestions();
assertSuggestEnum('E');
assertSuggestEnumConst('E.one');
@@ -2317,7 +2317,7 @@
}
Future<void> test_enum_deprecated() async {
- addTestSource('@deprecated enum E { one, two } main() {^}');
+ addTestSource('@deprecated enum E { one, two } void f() {^}');
await computeSuggestions();
assertSuggestEnum('E', isDeprecated: true);
assertSuggestEnumConst('E.one', isDeprecated: true);
@@ -2333,7 +2333,7 @@
void foo({E e}) {}
-main() {
+void f() {
foo(e: ^);
}
''');
@@ -2353,7 +2353,7 @@
enum E { one, two }
enum F { three, four }
-main() {
+void f() {
E e;
e = ^;
}
@@ -2374,7 +2374,7 @@
enum E { one, two }
enum F { three, four }
-main(E e) {
+void f(E e) {
e == ^;
}
''');
@@ -2394,7 +2394,7 @@
enum E { one, two }
enum F { three, four }
-main(E e) {
+void f(E e) {
switch (e) {
case ^
}
@@ -2416,7 +2416,7 @@
enum E { one, two }
enum F { three, four }
-main() {
+void f() {
E e = ^;
}
''');
@@ -2434,7 +2434,7 @@
Future<void> test_enum_shadowed() async {
addTestSource('''
enum E { one, two }
-main() {
+void f() {
int E = 0;
^
}
@@ -2806,7 +2806,7 @@
addTestSource('''
class C {}
-main() {
+void f() {
for(C in [0, 1, 2]) {
^
}
@@ -2818,7 +2818,7 @@
Future<void> test_forEachPartsWithIdentifier_localLevelVariable() async {
addTestSource('''
-main() {
+void f() {
int v;
for(v in [0, 1, 2]) {
^
@@ -2834,7 +2834,7 @@
Future<void> test_forEachPartsWithIdentifier_topLevelVariable() async {
addTestSource('''
int v;
-main() {
+void f() {
for(v in [0, 1, 2]) {
^
}
@@ -2848,7 +2848,7 @@
Future<void> test_ForEachStatement() async {
// SimpleIdentifier ForEachStatement
- addTestSource('main() {List<int> values; for (int index in ^)}');
+ addTestSource('void f() {List<int> values; for (int index in ^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2859,7 +2859,7 @@
Future<void> test_ForEachStatement2() async {
// SimpleIdentifier ForEachStatement
- addTestSource('main() {List<int> values; for (int index in i^)}');
+ addTestSource('void f() {List<int> values; for (int index in i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2870,7 +2870,7 @@
Future<void> test_ForEachStatement3() async {
// SimpleIdentifier ParenthesizedExpression ForEachStatement
- addTestSource('main() {List<int> values; for (int index in (i^))}');
+ addTestSource('void f() {List<int> values; for (int index in (i^))}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2881,7 +2881,7 @@
Future<void> test_ForEachStatement_body_typed() async {
// Block ForEachStatement
- addTestSource('main(args) {for (int foo in bar) {^}}');
+ addTestSource('void f(args) {for (int foo in bar) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2893,7 +2893,7 @@
Future<void> test_ForEachStatement_body_untyped() async {
// Block ForEachStatement
- addTestSource('main(args) {for (var foo in bar) {^}}');
+ addTestSource('void f(args) {for (var foo in bar) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2905,7 +2905,7 @@
Future<void> test_ForEachStatement_iterable() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (int foo in ^) {}}');
+ addTestSource('void f(args) {for (int foo in ^) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2916,7 +2916,7 @@
Future<void> test_ForEachStatement_loopVariable() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (^ in args) {}}');
+ addTestSource('void f(args) {for (^ in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2927,7 +2927,7 @@
Future<void> test_ForEachStatement_loopVariable_type() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (^ foo in args) {}}');
+ addTestSource('void f(args) {for (^ foo in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2939,7 +2939,7 @@
Future<void> test_ForEachStatement_loopVariable_type2() async {
// DeclaredIdentifier ForEachStatement Block
- addTestSource('main(args) {for (S^ foo in args) {}}');
+ addTestSource('void f(args) {for (S^ foo in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -2952,7 +2952,7 @@
@failingTest
Future<void> test_ForEachStatement_statement_typed() async {
// Statement ForEachStatement
- addTestSource('main(args) {for (int foo in bar) ^}');
+ addTestSource('void f(args) {for (int foo in bar) ^}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -2965,7 +2965,7 @@
@failingTest
Future<void> test_ForEachStatement_statement_untyped() async {
// Statement ForEachStatement
- addTestSource('main(args) {for (var foo in bar) ^}');
+ addTestSource('void f(args) {for (var foo in bar) ^}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3044,7 +3044,7 @@
Future<void> test_ForStatement_body() async {
// Block ForStatement
- addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
+ addTestSource('void f(args) {for (int i; i < 10; ++i) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3055,7 +3055,7 @@
Future<void> test_ForStatement_condition() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; i^)}');
+ addTestSource('void f() {for (int index = 0; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -3065,7 +3065,7 @@
Future<void> test_ForStatement_initializer() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {List a; for (^)}');
+ addTestSource('void f() {List a; for (^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3077,7 +3077,7 @@
Future<void> test_ForStatement_updaters() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; index < 10; i^)}');
+ addTestSource('void f() {for (int index = 0; index < 10; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -3089,13 +3089,13 @@
// SimpleIdentifier PrefixExpression ForStatement
addTestSource('''
void bar() { }
-main() {for (int index = 0; index < 10; ++i^)}''');
+f() {for (int index = 0; index < 10; ++i^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
assertSuggestLocalVariable('index', 'int');
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertNotSuggested('bar');
}
@@ -3103,7 +3103,7 @@
addTestSource('''
void m(x, {int y}) {}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3123,7 +3123,7 @@
addTestSource('''
void m(x, [int y]) {}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3143,7 +3143,7 @@
addTestSource('''
void m({x, int y}) {}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3163,7 +3163,7 @@
addTestSource('''
void m() {}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3178,7 +3178,7 @@
addTestSource('''
void m([x, int y]) {}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3198,7 +3198,7 @@
addTestSource('''
void m(x, int y) {}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -3436,13 +3436,13 @@
// SimpleIdentifier IfStatement Block BlockFunctionBody
addTestSource('''
class A {int x; int y() => 0;}
-main(){var a; if (^)}''');
+f(){var a; if (^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertSuggestLocalVariable('a', null);
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertSuggestClass('A');
assertNotSuggested('Object');
}
@@ -3498,7 +3498,7 @@
Future<void> test_IfStatement_invocation() async {
// SimpleIdentifier PrefixIdentifier IfStatement
addTestSource('''
-main() {var a; if (a.^) something}''');
+void f() {var a; if (a.^) something}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3510,7 +3510,7 @@
}
Future<void> test_ignore_symbol_being_completed() async {
- addTestSource('class MyClass { } main(MC^) { }');
+ addTestSource('class MyClass { } void f(MC^) { }');
await computeSuggestions();
assertSuggestClass('MyClass');
assertNotSuggested('MC');
@@ -3531,7 +3531,7 @@
// SimpleStringLiteral ImportDirective
addTestSource('''
import "dart^";
-main() {}''');
+void f() {}''');
await computeSuggestions();
assertNoSuggestions();
@@ -3540,19 +3540,17 @@
Future<void> test_inDartDoc_reference3() async {
addTestSource('''
/// The [^]
-main(aaa, bbb) {}''');
+void f(aaa, bbb) {}''');
await computeSuggestions();
- assertSuggestFunction('main', null,
- kind: CompletionSuggestionKind.IDENTIFIER);
+ assertSuggestFunction('f', null, kind: CompletionSuggestionKind.IDENTIFIER);
}
Future<void> test_inDartDoc_reference4() async {
addTestSource('''
/// The [m^]
-main(aaa, bbb) {}''');
+void f(aaa, bbb) {}''');
await computeSuggestions();
- assertSuggestFunction('main', null,
- kind: CompletionSuggestionKind.IDENTIFIER);
+ assertSuggestFunction('f', null, kind: CompletionSuggestionKind.IDENTIFIER);
}
Future<void> test_IndexExpression() async {
@@ -3602,7 +3600,7 @@
}
Future<void> test_inferredType() async {
- addTestSource('main() { var v = 42; ^ }');
+ addTestSource('void f() { var v = 42; ^ }');
await computeSuggestions();
assertSuggestLocalVariable('v', 'int');
}
@@ -3653,7 +3651,7 @@
class A {foo(){var f; {var x;}}}
class B {B(this.x, [String boo]) { } int x;}
class C {C.bar({boo: 'hoo', int z: 0}) { } }
-main() {new ^ String x = "hello";}''');
+void f() {new ^ String x = "hello";}''');
await computeSuggestions();
CompletionSuggestion suggestion;
@@ -3703,7 +3701,7 @@
factory A.factory() => A();
}
-main() {
+void f() {
new ^;
}''');
await computeSuggestions();
@@ -3718,7 +3716,7 @@
addTestSource('''
abstract class A {}
-main() {
+void f() {
new ^;
}''');
await computeSuggestions();
@@ -3730,7 +3728,7 @@
test_InstanceCreationExpression_assignment_expression_filter() async {
addTestSource('''
class A {} class B extends A {} class C implements A {} class D {}
-main() {
+void f() {
A a;
a = new ^
}''');
@@ -3746,7 +3744,7 @@
test_InstanceCreationExpression_assignment_expression_filter2() async {
addTestSource('''
class A {} class B extends A {} class C implements A {} class D {}
-main() {
+void f() {
A a;
a = new ^;
}''');
@@ -3793,7 +3791,7 @@
addTestSource('''
class A {} class B extends A {} class C {}
void foo(A a) {}
-main() {
+void f() {
foo(new ^);
}''');
await computeSuggestions();
@@ -3808,7 +3806,7 @@
addTestSource('''
class A {} class B extends A {} class C {}
void foo({A a}) {}
-main() {
+void f() {
foo(a: new ^);
}''');
await computeSuggestions();
@@ -3834,7 +3832,7 @@
test_InstanceCreationExpression_variable_declaration_filter() async {
addTestSource('''
class A {} class B extends A {} class C implements A {} class D {}
-main() {
+void f() {
A a = new ^
}''');
await computeSuggestions();
@@ -3849,7 +3847,7 @@
test_InstanceCreationExpression_variable_declaration_filter2() async {
addTestSource('''
class A {} class B extends A {} class C implements A {} class D {}
-main() {
+void f() {
A a = new ^;
}''');
await computeSuggestions();
@@ -3873,7 +3871,7 @@
F2() { }
typedef D2();
class C2 { }
-main() {String name; print("hello \${^}");}''');
+void f() {String name; print("hello \${^}");}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3893,7 +3891,7 @@
Future<void> test_InterpolationExpression_block2() async {
// SimpleIdentifier InterpolationExpression StringInterpolation
- addTestSource('main() {String name; print("hello \${n^}");}');
+ addTestSource('void f() {String name; print("hello \${n^}");}');
await computeSuggestions();
assertSuggestLocalVariable('name', 'String');
@@ -3903,7 +3901,7 @@
Future<void> test_InterpolationExpression_prefix_selector() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \${name.^}");}');
+ addTestSource('void f() {String name; print("hello \${name.^}");}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3916,7 +3914,7 @@
Future<void> test_InterpolationExpression_prefix_selector2() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \$name.^");}');
+ addTestSource('void f() {String name; print("hello \$name.^");}');
await computeSuggestions();
assertNoSuggestions();
@@ -3924,7 +3922,7 @@
Future<void> test_InterpolationExpression_prefix_target() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \${nam^e.length}");}');
+ addTestSource('void f() {String name; print("hello \${nam^e.length}");}');
await computeSuggestions();
assertSuggestLocalVariable('name', 'String');
@@ -3942,7 +3940,7 @@
addTestSource('''
import "b.dart";
class Y {Y.c(); Y._d(); z() {}}
-main() {var x; if (x is ^) { }}''');
+void f() {var x; if (x is ^) { }}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3950,7 +3948,7 @@
assertNotSuggested('X');
assertSuggestClass('Y');
assertNotSuggested('x');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('foo');
}
@@ -3960,13 +3958,13 @@
foo() { }
void bar() { }
class A {int x; int y() => 0;}
-main(){var a; if (^ is A)}''');
+f(){var a; if (^ is A)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertSuggestLocalVariable('a', null);
- assertSuggestFunction('main', null);
+ assertSuggestFunction('f', null);
assertSuggestFunction('foo', null);
assertNotSuggested('bar');
assertSuggestClass('A');
@@ -3977,13 +3975,13 @@
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('''
class A {int x; int y() => 0;}
-main(){var a; if (a is ^)}''');
+void f(){var a; if (a is ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertSuggestClass('A');
assertNotSuggested('Object');
}
@@ -4046,13 +4044,13 @@
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('''
class A {int x; int y() => 0;}
-main(){var a; if (a is Obj^)}''');
+void f(){var a; if (a is Obj^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 3);
expect(replacementLength, 3);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertSuggestClass('A');
assertNotSuggested('Object');
}
@@ -4068,7 +4066,7 @@
import "b.dart";
String newer() {}
var m;
-main() {new^ X.c();}''');
+void f() {new^ X.c();}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 3);
@@ -4086,7 +4084,7 @@
Future<void> test_Literal_list() async {
// ']' ListLiteral ArgumentList MethodInvocation
- addTestSource('main() {var Some; print([^]);}');
+ addTestSource('void f() {var Some; print([^]);}');
await computeSuggestions();
assertSuggestLocalVariable('Some', null);
@@ -4095,7 +4093,7 @@
Future<void> test_Literal_list2() async {
// SimpleIdentifier ListLiteral ArgumentList MethodInvocation
- addTestSource('main() {var Some; print([S^]);}');
+ addTestSource('void f() {var Some; print([S^]);}');
await computeSuggestions();
assertSuggestLocalVariable('Some', null);
@@ -4127,7 +4125,7 @@
Future<void> test_localConstructor2() async {
writeTestPackageConfig(meta: true);
- addTestSource('''class A {A.named();} main() {^}}''');
+ addTestSource('''class A {A.named();} void f() {^}}''');
await computeSuggestions();
assertSuggestConstructor('A.named');
}
@@ -4147,7 +4145,7 @@
Future<void> test_localConstructor_defaultConstructor() async {
writeTestPackageConfig(meta: true);
- addTestSource('''class A {} main() {^}}''');
+ addTestSource('''class A {} void f() {^}}''');
await computeSuggestions();
assertSuggestConstructor('A');
}
@@ -4186,7 +4184,7 @@
A();
A.named();
}
-main() {
+void f() {
int A = 0;
^
}
@@ -4202,10 +4200,10 @@
}
Future<void> test_localVariableDeclarationName() async {
- addTestSource('main() {String m^}');
+ addTestSource('void f() {String m^}');
await computeSuggestions();
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('min');
}
@@ -4287,7 +4285,7 @@
addTestSource('''
class A {
void m(x, int y) {}
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4298,7 +4296,7 @@
addTestSource('''
mixin A {
void m(x, int y) {}
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4327,7 +4325,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4349,7 +4347,7 @@
void m(x, {int y}) {}
}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4374,7 +4372,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4397,7 +4395,7 @@
void m(x, [int y]) {}
}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4422,7 +4420,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4444,7 +4442,7 @@
void m({x, int y}) {}
}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4469,7 +4467,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4486,7 +4484,7 @@
void m() {}
}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4506,7 +4504,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4528,7 +4526,7 @@
void m([x, int y]) {}
}
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4553,7 +4551,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -4959,7 +4957,7 @@
Future<void> test_MethodInvocation_no_semicolon() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
var b; X _c;
@@ -4990,17 +4988,17 @@
}
Future<void> test_missing_params_constructor() async {
- addTestSource('class C1{C1{} main(){C^}}');
+ addTestSource('class C1{C1{} void f(){C^}}');
await computeSuggestions();
}
Future<void> test_missing_params_function() async {
- addTestSource('int f1{} main(){f^}');
+ addTestSource('int f1{} void f(){f^}');
await computeSuggestions();
}
Future<void> test_missing_params_method() async {
- addTestSource('class C1{int f1{} main(){f^}}');
+ addTestSource('class C1{int f1{} void f(){f^}}');
await computeSuggestions();
}
@@ -5120,7 +5118,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -5137,7 +5135,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -5154,7 +5152,7 @@
addTestSource('''
import 'a.dart';
class B extends A {
- main() {^}
+ void f() {^}
}
''');
await computeSuggestions();
@@ -5268,7 +5266,7 @@
class A extends B {
static const String scA = 'foo';
w() { }}
-main() {A.^}''');
+void f() {A.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -5309,7 +5307,7 @@
class X{}''');
addTestSource('''
import "b.dart";
-main() {A a; a.^}''');
+void f() {A a; a.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -5335,7 +5333,7 @@
Future<void> test_PrefixedIdentifier_class_local() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('''
-main() {A a; a.^}
+void f() {A a; a.^}
class I {X get f => new A();get _g => new A();}
class A implements I {
static const int sc = 12;
@@ -5385,7 +5383,7 @@
import "b.dart" as b;
var T2;
class A { }
-main() {b.^}''');
+void f() {b.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -5604,21 +5602,21 @@
}
Future<void> test_prioritization() async {
- addTestSource('main() {var ab; var _ab; ^}');
+ addTestSource('void f() {var ab; var _ab; ^}');
await computeSuggestions();
assertSuggestLocalVariable('ab', null);
assertSuggestLocalVariable('_ab', null);
}
Future<void> test_prioritization_private() async {
- addTestSource('main() {var ab; var _ab; _^}');
+ addTestSource('void f() {var ab; var _ab; _^}');
await computeSuggestions();
assertSuggestLocalVariable('ab', null);
assertSuggestLocalVariable('_ab', null);
}
Future<void> test_prioritization_public() async {
- addTestSource('main() {var ab; var _ab; a^}');
+ addTestSource('void f() {var ab; var _ab; a^}');
await computeSuggestions();
assertSuggestLocalVariable('ab', null);
assertSuggestLocalVariable('_ab', null);
@@ -5650,7 +5648,7 @@
Future<void> test_PropertyAccess_noTarget2() async {
// SimpleIdentifier PropertyAccess ExpressionStatement
addSource('/home/test/lib/ab.dart', 'class Foo { }');
- addTestSource('main() {.^}');
+ addTestSource('void f() {.^}');
await computeSuggestions();
assertNoSuggestions();
@@ -5815,7 +5813,7 @@
Future<void> test_ThisExpression_block() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A() {}
@@ -5851,7 +5849,7 @@
Future<void> test_ThisExpression_constructor() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A() {this.^}
@@ -5887,7 +5885,7 @@
Future<void> test_ThisExpression_constructor_param() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.^) {}
@@ -5925,7 +5923,7 @@
Future<void> test_ThisExpression_constructor_param2() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.b^) {}
@@ -5962,7 +5960,7 @@
Future<void> test_ThisExpression_constructor_param3() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.^b) {}
@@ -5999,7 +5997,7 @@
Future<void> test_ThisExpression_constructor_param4() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
-main() { }
+void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.b, this.^) {}
@@ -6070,7 +6068,7 @@
Future<void> test_typeAlias_functionType() async {
addTestSource(r'''
typedef F = void Function();
-main() {
+void f() {
^
}
''');
@@ -6082,7 +6080,7 @@
Future<void> test_typeAlias_interfaceType() async {
addTestSource(r'''
typedef F = List<int>;
-main() {
+void f() {
^
}
''');
@@ -6093,7 +6091,7 @@
Future<void> test_typeAlias_legacy() async {
addTestSource(r'''
typedef void F();
-main() {
+void f() {
^
}
''');
@@ -6114,7 +6112,7 @@
F2() => 0;
typedef int T2(int blat);
class C<E> {}
-main() { C<^> c; }''');
+void f() { C<^> c; }''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -6141,7 +6139,7 @@
F2() => 0;
typedef int T2(int blat);
class C<E> {}
-main() { C<C^> c; }''');
+void f() { C<C^> c; }''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
@@ -6185,7 +6183,7 @@
addTestSource('''
import "b.dart";
class Y {Y.c(); Y._d(); z() {}}
-main() {var ^}''');
+void f() {var ^}''');
await computeSuggestions();
assertNoSuggestions();
@@ -6193,7 +6191,7 @@
Future<void> test_VariableDeclarationList_final() async {
// VariableDeclarationList VariableDeclarationStatement Block
- addTestSource('main() {final ^} class C { }');
+ addTestSource('void f() {final ^} class C { }');
await computeSuggestions();
assertNotSuggested('Object');
@@ -6270,7 +6268,7 @@
Future<void> test_YieldStatement() async {
addTestSource('''
-void main() async* {
+void f() async* {
var value;
yield v^
}
diff --git a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
index 8d36d27..c9d8574 100644
--- a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
@@ -58,7 +58,7 @@
bool a(int b, bool c) => false;
}
-void main() {new A().a^}''');
+void f() {new A().a^}''');
await computeSuggestions();
assertSuggestMethod('a', 'A', 'bool', defaultArgListString: 'b, c');
@@ -70,7 +70,7 @@
bool a() => false;
}
-void main() {new A().a^}''');
+void f() {new A().a^}''');
await computeSuggestions();
assertSuggestMethod('a', 'A', 'bool', defaultArgListString: null);
@@ -85,7 +85,7 @@
bool foo(int bar, [bool boo, int baz]) => false;
}
-void main() {new A().f^}''');
+void f() {new A().f^}''');
await computeSuggestions();
assertSuggestMethod('foo', 'A', 'bool', defaultArgListString: 'bar');
@@ -100,7 +100,7 @@
bool foo(int bar, {bool boo, @required int baz}) => false;
}
-void main() {new A().f^}''');
+void f() {new A().f^}''');
await computeSuggestions();
assertSuggestMethod('foo', 'A', 'bool',
@@ -117,7 +117,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {expect(^)}''');
+ void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -126,7 +126,7 @@
assertNotSuggested('identical');
assertNotSuggested('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -142,7 +142,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {expect(^)}''');
+ void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -151,7 +151,7 @@
assertNotSuggested('identical');
assertNotSuggested('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -169,7 +169,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {new A(^)}''');
+ void f() {new A(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -179,7 +179,7 @@
assertNotSuggested('B');
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -197,7 +197,7 @@
import 'a.dart';
class B { }
String bar() => true;
- void main() {new A(^)}''');
+ void f() {new A(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -207,7 +207,7 @@
assertNotSuggested('B');
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -223,7 +223,7 @@
expect(arg) { }
class B { }
String bar() => true;
- void main() {expect(^)}''');
+ void f() {expect(^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -232,7 +232,7 @@
assertNotSuggested('identical');
assertNotSuggested('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -257,7 +257,7 @@
assertNotSuggested('identical');
assertNotSuggested('B');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -274,7 +274,7 @@
import 'a.dart';
class B { }
String bar(f()) => true;
- void main() {bar(^);}''');
+ void f() {bar(^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -284,7 +284,7 @@
assertNotSuggested('B');
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -300,7 +300,7 @@
import 'dart:async';
import 'a.dart';
class B { String bar(f()) => true; }
- void main() {new B().bar(^);}''');
+ void f() {new B().bar(^);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -309,7 +309,7 @@
assertNotSuggested('B');
assertNotSuggested('A');
assertNotSuggested('Object');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('baz');
assertNotSuggested('print');
}
@@ -323,13 +323,13 @@
addTestSource('''
import 'a.dart';
String bar() => true;
- void main() {expect(foo: ^)}''');
+ void f() {expect(foo: ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('bar');
assertNotSuggested('hasLength');
- assertNotSuggested('main');
+ assertNotSuggested('f');
}
Future<void> test_AsExpression() async {
@@ -349,7 +349,7 @@
Future<void> test_AssignmentExpression_name() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
- addTestSource('class A {} main() {int a; int ^b = 1;}');
+ addTestSource('class A {} void f() {int a; int ^b = 1;}');
await computeSuggestions();
assertNoSuggestions();
}
@@ -357,12 +357,12 @@
Future<void> test_AssignmentExpression_RHS() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
- addTestSource('class A {} main() {int a; int b = ^}');
+ addTestSource('class A {} void f() {int a; int b = ^}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertNotSuggested('Object');
}
@@ -371,7 +371,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
^ b = 1;}''');
await computeSuggestions();
@@ -385,7 +385,7 @@
// Consider suggesting only types
// if only spaces separates the 1st and 2nd identifiers.
//assertNotSuggested('a');
- //assertNotSuggested('main');
+ //assertNotSuggested('f');
//assertNotSuggested('identical');
}
@@ -393,7 +393,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
^
b = 1;}''');
@@ -406,7 +406,7 @@
// if newline follows first identifier
// because user is probably starting a new statement
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('identical');
}
@@ -414,7 +414,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
int^ b = 1;}''');
await computeSuggestions();
@@ -428,7 +428,7 @@
// Consider suggesting only types
// if only spaces separates the 1st and 2nd identifiers.
//assertNotSuggested('a');
- //assertNotSuggested('main');
+ //assertNotSuggested('f');
//assertNotSuggested('identical');
}
@@ -436,7 +436,7 @@
// SimpleIdentifier TypeName VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('''
- class A {} main() {
+ class A {} void f() {
int a;
i^
b = 1;}''');
@@ -449,7 +449,7 @@
// if newline follows first identifier
// because user is probably starting a new statement
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('identical');
}
@@ -457,12 +457,12 @@
// SimpleIdentifier AwaitExpression ExpressionStatement
addTestSource('''
class A {int x; int y() => 0;}
- main() async {A a; await ^}''');
+ void f() async {A a; await ^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertNotSuggested('Object');
}
@@ -470,7 +470,7 @@
Future<void> test_BinaryExpression_LHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
- addTestSource('main() {int a = 1, b = ^ + 2;}');
+ addTestSource('void f() {int a = 1, b = ^ + 2;}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -482,7 +482,7 @@
Future<void> test_BinaryExpression_RHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
- addTestSource('main() {int a = 1, b = 2 + ^;}');
+ addTestSource('void f() {int a = 1, b = 2 + ^;}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -683,14 +683,14 @@
}
Future<void> test_Block_final2() async {
- addTestSource('main() {final S^ v;}');
+ addTestSource('void f() {final S^ v;}');
await computeSuggestions();
assertNotSuggested('String');
}
Future<void> test_Block_final3() async {
- addTestSource('main() {final ^ v;}');
+ addTestSource('void f() {final ^ v;}');
await computeSuggestions();
assertNotSuggested('String');
@@ -1075,7 +1075,7 @@
Future<void> test_Block_unimported() async {
newFile('$testPackageLibPath/a.dart', content: 'class A {}');
- addTestSource('main() { ^ }');
+ addTestSource('void f() { ^ }');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -1096,7 +1096,7 @@
class X{}
// looks like a cascade to the parser
// but the user is trying to get completions for a non-cascade
- main() {A a; a.^.z()}''');
+ void f() {A a; a.^.z()}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1120,7 +1120,7 @@
class X{}
// looks like a cascade to the parser
// but the user is trying to get completions for a non-cascade
- main() {A a; a.^.z}''');
+ void f() {A a; a.^.z}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1142,7 +1142,7 @@
import "b.dart";
class A {var b; X _c;}
class X{}
- main() {A a; a..^z}''');
+ void f() {A a; a..^z}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 1);
@@ -1164,7 +1164,7 @@
import "b.dart";
class A {var b; X _c;}
class X{}
- main() {A a; a..^ return}''');
+ void f() {A a; a..^ return}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1183,7 +1183,7 @@
addTestSource('''
class A {var b; X _c;}
class X{}
- main() {A a; a^..b}''');
+ void f() {A a; a^..b}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
@@ -1525,7 +1525,7 @@
addTestSource('''
import "b.dart";
var m;
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1549,7 +1549,7 @@
addTestSource('''
import "b.dart";
var m;
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1566,7 +1566,7 @@
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('''
- main() {new String.fr^omCharCodes([]);}''');
+ void f() {new String.fr^omCharCodes([]);}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 2);
expect(replacementLength, 13);
@@ -1586,7 +1586,7 @@
int T1;
F1() { }
class X {X.c(); X._d(); z() {}}
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1606,7 +1606,7 @@
int T1;
F1() { }
class X {factory X.c(); factory X._d(); z() {}}
- main() {new X.^}''');
+ void f() {new X.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1637,7 +1637,7 @@
}
Future<void> test_enumConst() async {
- addTestSource('enum E { one, two } main() {E.^}');
+ addTestSource('enum E { one, two } void f() {E.^}');
await computeSuggestions();
assertNotSuggested('E');
// Suggested by StaticMemberContributor
@@ -1648,7 +1648,7 @@
}
Future<void> test_enumConst2() async {
- addTestSource('enum E { one, two } main() {E.o^}');
+ addTestSource('enum E { one, two } void f() {E.o^}');
await computeSuggestions();
assertNotSuggested('E');
// Suggested by StaticMemberContributor
@@ -1659,7 +1659,7 @@
}
Future<void> test_enumConst3() async {
- addTestSource('enum E { one, two } main() {E.^ int g;}');
+ addTestSource('enum E { one, two } void f() {E.^ int g;}');
await computeSuggestions();
assertNotSuggested('E');
// Suggested by StaticMemberContributor
@@ -1670,7 +1670,7 @@
}
Future<void> test_enumConst_index() async {
- addTestSource('enum E { one, two } main() {E.one.^}');
+ addTestSource('enum E { one, two } void f() {E.one.^}');
await computeSuggestions();
assertNotSuggested('E');
assertNotSuggested('one');
@@ -1680,7 +1680,7 @@
}
Future<void> test_enumConst_index2() async {
- addTestSource('enum E { one, two } main() {E.one.i^}');
+ addTestSource('enum E { one, two } void f() {E.one.i^}');
await computeSuggestions();
assertNotSuggested('E');
assertNotSuggested('one');
@@ -1690,7 +1690,7 @@
}
Future<void> test_enumConst_index3() async {
- addTestSource('enum E { one, two } main() {E.one.^ int g;}');
+ addTestSource('enum E { one, two } void f() {E.one.^ int g;}');
await computeSuggestions();
assertNotSuggested('E');
assertNotSuggested('one');
@@ -1784,7 +1784,7 @@
Future<void> test_ForEachStatement_body_typed() async {
// Block ForEachStatement
- addTestSource('main(args) {for (int foo in bar) {^}}');
+ addTestSource('void f(args) {for (int foo in bar) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1795,7 +1795,7 @@
Future<void> test_ForEachStatement_body_untyped() async {
// Block ForEachStatement
- addTestSource('main(args) {for (foo in bar) {^}}');
+ addTestSource('void f(args) {for (foo in bar) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1806,7 +1806,7 @@
Future<void> test_ForEachStatement_iterable() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (int foo in ^) {}}');
+ addTestSource('void f(args) {for (int foo in ^) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1816,7 +1816,7 @@
Future<void> test_ForEachStatement_loopVariable() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (^ in args) {}}');
+ addTestSource('void f(args) {for (^ in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1826,7 +1826,7 @@
Future<void> test_ForEachStatement_loopVariable_type() async {
// SimpleIdentifier ForEachStatement Block
- addTestSource('main(args) {for (^ foo in args) {}}');
+ addTestSource('void f(args) {for (^ foo in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1837,7 +1837,7 @@
Future<void> test_ForEachStatement_loopVariable_type2() async {
// DeclaredIdentifier ForEachStatement Block
- addTestSource('main(args) {for (S^ foo in args) {}}');
+ addTestSource('void f(args) {for (S^ foo in args) {}}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
@@ -1865,7 +1865,7 @@
Future<void> test_ForStatement_body() async {
// Block ForStatement
- addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
+ addTestSource('void f(args) {for (int i; i < 10; ++i) {^}}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1875,7 +1875,7 @@
Future<void> test_ForStatement_condition() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; i^)}');
+ addTestSource('void f() {for (int index = 0; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
@@ -1884,7 +1884,7 @@
Future<void> test_ForStatement_initializer() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {List a; for (^)}');
+ addTestSource('void f() {List a; for (^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -1895,7 +1895,7 @@
Future<void> test_ForStatement_updaters() async {
// SimpleIdentifier ForStatement
- addTestSource('main() {for (int index = 0; index < 10; i^)}');
+ addTestSource('void f() {for (int index = 0; index < 10; i^)}');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
@@ -1906,12 +1906,12 @@
// SimpleIdentifier PrefixExpression ForStatement
addTestSource('''
void bar() { }
- main() {for (int index = 0; index < 10; ++i^)}''');
+ void f() {for (int index = 0; index < 10; ++i^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
assertNotSuggested('index');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('bar');
}
@@ -2121,12 +2121,12 @@
// SimpleIdentifier IfStatement Block BlockFunctionBody
addTestSource('''
class A {int x; int y() => 0;}
- main(){var a; if (^)}''');
+ void f(){var a; if (^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertNotSuggested('Object');
}
@@ -2148,7 +2148,7 @@
Future<void> test_IfStatement_invocation() async {
// SimpleIdentifier PrefixIdentifier IfStatement
addTestSource('''
- main() {var a; if (a.^) something}''');
+ void f() {var a; if (a.^) something}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -2162,7 +2162,7 @@
// SimpleStringLiteral ImportDirective
addTestSource('''
import "dart^";
- main() {}''');
+ void f() {}''');
await computeSuggestions();
assertNoSuggestions();
}
@@ -2310,7 +2310,7 @@
F2() { }
typedef D2();
class C2 { }
- main() {String name; print("hello \$^");}''');
+ void f() {String name; print("hello \$^");}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -2339,7 +2339,7 @@
F2() { }
typedef D2();
class C2 { }
- main() {String name; print("hello \${^}");}''');
+ void f() {String name; print("hello \${^}");}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -2356,7 +2356,7 @@
Future<void> test_InterpolationExpression_block2() async {
// SimpleIdentifier InterpolationExpression StringInterpolation
- addTestSource('main() {String name; print("hello \${n^}");}');
+ addTestSource('void f() {String name; print("hello \${n^}");}');
await computeSuggestions();
assertNotSuggested('name');
// top level results are partially filtered
@@ -2365,7 +2365,7 @@
Future<void> test_InterpolationExpression_prefix_selector() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \${name.^}");}');
+ addTestSource('void f() {String name; print("hello \${name.^}");}');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -2377,14 +2377,14 @@
Future<void> test_InterpolationExpression_prefix_selector2() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \$name.^");}');
+ addTestSource('void f() {String name; print("hello \$name.^");}');
await computeSuggestions();
assertNoSuggestions();
}
Future<void> test_InterpolationExpression_prefix_target() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
- addTestSource('main() {String name; print("hello \${nam^e.length}");}');
+ addTestSource('void f() {String name; print("hello \${nam^e.length}");}');
await computeSuggestions();
assertNotSuggested('name');
// top level results are partially filtered
@@ -2401,14 +2401,14 @@
addTestSource('''
import "b.dart";
class Y {Y.c(); Y._d(); z() {}}
- main() {var x; if (x is ^) { }}''');
+ void f() {var x; if (x is ^) { }}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('X');
assertNotSuggested('Y');
assertNotSuggested('x');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('foo');
}
@@ -2418,12 +2418,12 @@
foo() { }
void bar() { }
class A {int x; int y() => 0;}
- main(){var a; if (^ is A)}''');
+ void f(){var a; if (^ is A)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('foo');
assertNotSuggested('bar');
assertNotSuggested('A');
@@ -2434,12 +2434,12 @@
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('''
class A {int x; int y() => 0;}
- main(){var a; if (a is ^)}''');
+ void f(){var a; if (a is ^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertNotSuggested('Object');
}
@@ -2448,18 +2448,19 @@
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('''
class A {int x; int y() => 0;}
- main(){var a; if (a is Obj^)}''');
+ void f(){var a; if (a is Obj^)}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 3);
expect(replacementLength, 3);
assertNotSuggested('a');
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('A');
assertNotSuggested('Object');
}
Future<void> test_keyword() async {
- addTestSource('class C { static C get instance => null; } main() {C.in^}');
+ addTestSource(
+ 'class C { static C get instance => null; } void f() {C.in^}');
await computeSuggestions();
// Suggested by StaticMemberContributor
assertNotSuggested('instance');
@@ -2476,7 +2477,7 @@
import "b.dart";
String newer() {}
var m;
- main() {new^ X.c();}''');
+ void f() {new^ X.c();}''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 3);
expect(replacementLength, 3);
@@ -2528,7 +2529,7 @@
Future<void> test_libraryPrefix_with_exports() async {
addSource('/home/test/lib/a.dart', 'class A { }');
addSource('/home/test/lib/b.dart', 'export "a.dart"; class B { }');
- addTestSource('import "b.dart" as foo; main() {foo.^} class C { }');
+ addTestSource('import "b.dart" as foo; void f() {foo.^} class C { }');
await computeSuggestions();
// Suggested by LibraryMemberContributor
assertNotSuggested('B');
@@ -2537,7 +2538,7 @@
Future<void> test_Literal_list() async {
// ']' ListLiteral ArgumentList MethodInvocation
- addTestSource('main() {var Some; print([^]);}');
+ addTestSource('void f() {var Some; print([^]);}');
await computeSuggestions();
assertNotSuggested('Some');
assertNotSuggested('String');
@@ -2545,7 +2546,7 @@
Future<void> test_Literal_list2() async {
// SimpleIdentifier ListLiteral ArgumentList MethodInvocation
- addTestSource('main() {var Some; print([S^]);}');
+ addTestSource('void f() {var Some; print([S^]);}');
await computeSuggestions();
assertNotSuggested('Some');
assertNotSuggested('String');
@@ -2577,9 +2578,9 @@
}
Future<void> test_localVariableDeclarationName() async {
- addTestSource('main() {String m^}');
+ addTestSource('void f() {String m^}');
await computeSuggestions();
- assertNotSuggested('main');
+ assertNotSuggested('f');
assertNotSuggested('min');
}
@@ -2656,7 +2657,7 @@
void f(int x, void Function(int a, int b) closure, int y) {}
}
-void main() {
+void f() {
new C().^
}
''');
@@ -2676,7 +2677,7 @@
void f(bool Function(int a, int b) closure) {}
}
-void main() {
+void f() {
new C().^
}
''');
@@ -2696,7 +2697,7 @@
void f(Object Function(int a, int b) closure) {}
}
-void main() {
+void f() {
new C().^
}
''');
@@ -2716,7 +2717,7 @@
void f(void Function(int a, int b) closure) {}
}
-void main() {
+void f() {
new C().^
}
''');
@@ -2735,7 +2736,7 @@
class C {
void m(x, {int y}) {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestMethod('m', 'C', 'void');
var parameterNames = suggestion.parameterNames!;
@@ -2754,7 +2755,7 @@
class C {
void m(x, [int y]) {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestMethod('m', 'C', 'void');
var parameterNames = suggestion.parameterNames!;
@@ -2773,7 +2774,7 @@
class C {
void m({x, int y}) {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestMethod('m', 'C', 'void');
var parameterNames = suggestion.parameterNames!;
@@ -2792,7 +2793,7 @@
class C {
void m() {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestMethod('m', 'C', 'void');
expect(suggestion.parameterNames, isEmpty);
@@ -2806,7 +2807,7 @@
class C {
void m([x, int y]) {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestMethod('m', 'C', 'void');
var parameterNames = suggestion.parameterNames!;
@@ -2825,7 +2826,7 @@
class C {
void m(x, int y) {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestMethod('m', 'C', 'void');
var parameterNames = suggestion.parameterNames!;
@@ -3046,7 +3047,7 @@
Future<void> test_MethodInvocation_no_semicolon() async {
// MethodInvocation ExpressionStatement Block
addTestSource(r'''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A(); F $p; void $q(){}}
class A implements I {
var b; X _c;
@@ -3132,7 +3133,7 @@
class C {
int x;
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestField('x', 'int');
assertHasNoParameterInfo(suggestion);
@@ -3143,7 +3144,7 @@
class C {
int get x => null;
}
-void main() {int y = new C().^}''');
+void f() {int y = new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestGetter('x', 'int');
assertHasNoParameterInfo(suggestion);
@@ -3154,7 +3155,7 @@
class C {
set x(int value) {};
}
-void main() {int y = new C().^}''');
+void f() {int y = new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestSetter('x');
assertHasNoParameterInfo(suggestion);
@@ -3165,7 +3166,7 @@
class C {
set x() {};
}
-void main() {int y = new C().^}''');
+void f() {int y = new C().^}''');
await computeSuggestions();
var suggestion = assertSuggestSetter('x');
assertHasNoParameterInfo(suggestion);
@@ -3180,7 +3181,7 @@
m1() {}
static m2() {}
}
-void main() {new C().^}''');
+void f() {new C().^}''');
await computeSuggestions();
assertSuggestField('f1', 'int');
assertNotSuggested('f2');
@@ -3197,7 +3198,7 @@
m1() {}
static m2() {}
}
-void main() {new C().^ print("something");}''');
+void f() {new C().^ print("something");}''');
await computeSuggestions();
assertSuggestField('f1', 'int');
assertNotSuggested('f2');
@@ -3214,7 +3215,7 @@
m1() {}
static m2() {}
}
-void main() {C.^}''');
+void f() {C.^}''');
await computeSuggestions();
assertNotSuggested('f1');
// Suggested by StaticMemberContributor
@@ -3232,7 +3233,7 @@
m1() {}
static m2() {}
}
-void main() {C.^ print("something");}''');
+void f() {C.^ print("something");}''');
await computeSuggestions();
assertNotSuggested('f1');
// Suggested by StaticMemberContributor
@@ -3276,7 +3277,7 @@
addTestSource('''
part of libA;
class B { B.bar(int x); }
- main() {new ^}''');
+ void f() {new ^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -3307,7 +3308,7 @@
import "b.dart";
part "a.dart";
class A { A({String boo: 'hoo'}) { } }
- main() {new ^}
+ void f() {new ^}
var m;''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
@@ -3344,7 +3345,7 @@
class A extends B {
static const String scA = 'foo';
w() { }}
- main() {A.^}''');
+ void f() {A.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -3384,7 +3385,7 @@
class X{}''');
addTestSource('''
import "b.dart";
- main() {A a; a.^}''');
+ void f() {A a; a.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -3409,7 +3410,7 @@
Future<void> test_PrefixedIdentifier_class_local() async {
// SimpleIdentifier PrefixedIdentifier ExpressionStatement
addTestSource('''
- main() {A a; a.^}
+ void f() {A a; a.^}
class I {X get f => new A();get _g => new A();}
class A implements I {
static const int sc = 12;
@@ -3457,7 +3458,7 @@
import "b.dart" as b;
var T2;
class A { }
- main() {b.^}''');
+ void f() {b.^}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -3689,7 +3690,7 @@
Future<void> test_PropertyAccess_noTarget2() async {
// SimpleIdentifier PropertyAccess ExpressionStatement
addSource('/testAB.dart', 'class Foo { }');
- addTestSource('main() {.^}');
+ addTestSource('void f() {.^}');
await computeSuggestions();
assertNoSuggestions();
}
@@ -3913,7 +3914,7 @@
Future<void> test_ThisExpression_block() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A() {}
@@ -3948,7 +3949,7 @@
Future<void> test_ThisExpression_constructor() async {
// MethodInvocation ExpressionStatement Block
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A() {this.^}
@@ -3983,7 +3984,7 @@
Future<void> test_ThisExpression_constructor_param() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.^) {}
@@ -4020,7 +4021,7 @@
Future<void> test_ThisExpression_constructor_param2() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.b^) {}
@@ -4056,7 +4057,7 @@
Future<void> test_ThisExpression_constructor_param3() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.^b) {}
@@ -4092,7 +4093,7 @@
Future<void> test_ThisExpression_constructor_param4() async {
// SimpleIdentifier FieldFormalParameter FormalParameterList
addTestSource('''
- main() { }
+ void f() { }
class I {X get f => new A();get _g => new A();}
class A implements I {
A(this.b, this.^) {}
@@ -4153,7 +4154,7 @@
F2() => 0;
typedef int T2(int blat);
class C<E> {}
- main() { C<^> c; }''');
+ void f() { C<^> c; }''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -4178,7 +4179,7 @@
F2() => 0;
typedef int T2(int blat);
class C<E> {}
- main() { C<C^> c; }''');
+ void f() { C<C^> c; }''');
await computeSuggestions();
expect(replacementOffset, completionOffset - 1);
expect(replacementLength, 1);
@@ -4193,7 +4194,7 @@
Func f;
void a() => f.^;
}
- main() {}''');
+ void f() {}''');
await computeSuggestions();
expect(replacementOffset, completionOffset);
expect(replacementLength, 0);
@@ -4220,14 +4221,14 @@
addTestSource('''
import "b.dart";
class Y {Y.c(); Y._d(); z() {}}
- main() {var ^}''');
+ void f() {var ^}''');
await computeSuggestions();
assertNoSuggestions();
}
Future<void> test_VariableDeclarationList_final() async {
// VariableDeclarationList VariableDeclarationStatement Block
- addTestSource('main() {final ^} class C { }');
+ addTestSource('void f() {final ^} class C { }');
await computeSuggestions();
assertNotSuggested('Object');
assertNotSuggested('C');
diff --git a/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart b/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
index 741715f..ad27bcd 100644
--- a/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
+++ b/pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
@@ -448,7 +448,7 @@
await _prepareCompletion(
'while ()',
'''
-main() {
+void f() {
do {
} while ()
}
@@ -457,7 +457,7 @@
_assertHasChange(
'Complete do-statement',
'''
-main() {
+void f() {
do {
} while ();
}
@@ -469,7 +469,7 @@
await _prepareCompletion(
'do',
'''
-main() {
+void f() {
do ////
}
''',
@@ -477,7 +477,7 @@
_assertHasChange(
'Complete do-statement',
'''
-main() {
+void f() {
do {
////
} while ();
@@ -490,7 +490,7 @@
await _prepareCompletion(
'do',
'''
-main() {
+void f() {
do ////
return;
}
@@ -499,7 +499,7 @@
_assertHasChange(
'Complete do-statement',
'''
-main() {
+void f() {
do {
////
} while ();
@@ -513,7 +513,7 @@
await _prepareCompletion(
'do',
'''
-main() {
+void f() {
do;
while
}
@@ -522,7 +522,7 @@
_assertHasChange(
'Complete do-statement',
'''
-main() {
+void f() {
do {
////
} while ();
@@ -535,7 +535,7 @@
await _prepareCompletion(
'while',
'''
-main() {
+void f() {
do {
} while
}
@@ -544,7 +544,7 @@
_assertHasChange(
'Complete do-statement',
'''
-main() {
+void f() {
do {
} while ();
}
@@ -556,7 +556,7 @@
await _prepareCompletion(
'}',
'''
-main() {
+void f() {
do {
}
}
@@ -565,7 +565,7 @@
_assertHasChange(
'Complete do-statement',
'''
-main() {
+void f() {
do {
} while ();
}
@@ -580,7 +580,7 @@
await _prepareCompletion(
'= ',
'''
-main() {
+void f() {
var x = [1, 2, 3
}
''',
@@ -588,7 +588,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
var x = [1, 2, 3];
////
}
@@ -601,7 +601,7 @@
await _prepareCompletion(
'3',
'''
-main() {
+void f() {
var x = [
1,
2,
@@ -612,7 +612,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
var x = [
1,
2,
@@ -629,7 +629,7 @@
await _prepareCompletion(
'3: 3',
'''
-main() {
+void f() {
var x = {1: 1, 2: 2, 3: 3
}
''',
@@ -637,7 +637,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
var x = {1: 1, 2: 2, 3: 3};
////
}
@@ -650,7 +650,7 @@
await _prepareCompletion(
'3',
'''
-main() {
+void f() {
var x = {1: 1, 2: 2, 3
}
''',
@@ -658,7 +658,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
var x = {1: 1, 2: 2, 3: };
////
}
@@ -670,7 +670,7 @@
await _prepareCompletion(
'text',
'''
-main() {
+void f() {
if (done()) {
return 'text
}
@@ -680,7 +680,7 @@
_assertHasChange(
'Complete control flow block',
'''
-main() {
+void f() {
if (done()) {
return 'text';
}
@@ -694,7 +694,7 @@
await _prepareCompletion(
'= ',
'''
-main() {
+void f() {
var x = '
}
''',
@@ -702,7 +702,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
var x = '';
////
}
@@ -714,7 +714,7 @@
await _prepareCompletion(
'text',
'''
-main() {
+void f() {
print("text
}
''',
@@ -722,7 +722,7 @@
_assertHasChange(
'Insert a newline at the end of the current line',
'''
-main() {
+void f() {
print("text");
////
}
@@ -734,7 +734,7 @@
await _prepareCompletion(
'text',
'''
-main() {
+void f() {
print(r"text
}
''',
@@ -742,7 +742,7 @@
_assertHasChange(
'Insert a newline at the end of the current line',
'''
-main() {
+void f() {
print(r"text");
////
}
@@ -754,7 +754,7 @@
await _prepareCompletion(
'text',
'''
-main() {
+void f() {
print(\'\'\'text
}
''',
@@ -762,7 +762,7 @@
_assertHasChange(
'Insert a newline at the end of the current line',
'''
-main() {
+void f() {
print(\'\'\'text\'\'\');
////
}
@@ -774,7 +774,7 @@
await _prepareCompletion(
'text',
r"""
-main() {
+void f() {
print(r'''text
}
""",
@@ -782,7 +782,7 @@
_assertHasChange(
'Insert a newline at the end of the current line',
r"""
-main() {
+void f() {
print(r'''text''');
////
}
@@ -797,7 +797,7 @@
await _prepareCompletion(
'0;',
'''
-main() {
+void f() {
for (int i = 0;) /**/ ////
}
''',
@@ -805,7 +805,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (int i = 0; ; ) /**/ {
////
}
@@ -818,7 +818,7 @@
await _prepareCompletion(
'0;',
'''
-main() {
+void f() {
for (int i = 0;) {
}
}
@@ -827,7 +827,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (int i = 0; ; ) {
}
}
@@ -840,7 +840,7 @@
await _prepareCompletion(
'r (',
'''
-main() {
+void f() {
for () {
}
}
@@ -849,7 +849,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for () {
}
}
@@ -861,7 +861,7 @@
await _prepareCompletion(
'}',
'''
-main() {
+void f() {
for () {
}
}
@@ -870,7 +870,7 @@
_assertHasChange(
'Insert a newline at the end of the current line',
'''
-main() {
+void f() {
for () {
}
////
@@ -883,7 +883,7 @@
await _prepareCompletion(
'/**/',
'''
-main() {
+void f() {
for (;/**/)
}
''',
@@ -891,7 +891,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (; /**/; ) {
////
}
@@ -904,7 +904,7 @@
await _prepareCompletion(
';)',
'''
-main() {
+void f() {
for (;;)
}
''',
@@ -912,7 +912,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (;;) {
////
}
@@ -925,7 +925,7 @@
await _prepareCompletion(
'/**/',
'''
-main() {
+void f() {
for (int i = 0; i < 10 /**/)
}
''',
@@ -933,7 +933,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (int i = 0; i < 10 /**/; ) {
////
}
@@ -946,7 +946,7 @@
await _prepareCompletion(
'/**/',
'''
-main() {
+void f() {
for (int i = 0; i < 10 /**/) {
}
}
@@ -955,7 +955,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (int i = 0; i < 10 /**/; ) {
}
}
@@ -967,7 +967,7 @@
await _prepareCompletion(
'for',
'''
-main() {
+void f() {
for
}
''',
@@ -975,7 +975,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for () {
////
}
@@ -988,7 +988,7 @@
await _prepareCompletion(
'= 0',
'''
-main() {
+void f() {
for (int i = 0) {
}
}
@@ -997,7 +997,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (int i = 0; ; ) {
}
}
@@ -1009,7 +1009,7 @@
await _prepareCompletion(
';)',
'''
-main() {
+void f() {
for (;;)
return;
}
@@ -1018,7 +1018,7 @@
_assertHasChange(
'Complete for-statement',
'''
-main() {
+void f() {
for (;;) {
////
}
@@ -1035,7 +1035,7 @@
await _prepareCompletion(
'in xs)',
'''
-main() {
+void f() {
for (in xs)
}
''',
@@ -1043,7 +1043,7 @@
_assertHasChange(
'Complete for-each-statement',
'''
-main() {
+void f() {
for ( in xs) {
////
}
@@ -1060,7 +1060,7 @@
await _prepareCompletion(
'in)',
'''
-main() {
+void f() {
for (in)
}
''',
@@ -1068,7 +1068,7 @@
_assertHasChange(
'Complete for-each-statement',
'''
-main() {
+void f() {
for ( in ) {
////
}
@@ -1081,7 +1081,7 @@
await _prepareCompletion(
'in)',
'''
-main() {
+void f() {
for (var x in)
}
''',
@@ -1089,7 +1089,7 @@
_assertHasChange(
'Complete for-each-statement',
'''
-main() {
+void f() {
for (var x in ) {
////
}
@@ -1102,7 +1102,7 @@
await _prepareCompletion(
'])',
'''
-main() {
+void f() {
for (var x in [1,2])
return;
}
@@ -1111,7 +1111,7 @@
_assertHasChange(
'Complete for-each-statement',
'''
-main() {
+void f() {
for (var x in [1,2]) {
////
}
@@ -1128,7 +1128,7 @@
await _prepareCompletion(
'if (true) ', // Trigger completion after space.
'''
-main() {
+void f() {
if (true) ////
}
''',
@@ -1136,7 +1136,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if (true) {
////
}
@@ -1149,7 +1149,7 @@
await _prepareCompletion(
'if ()',
'''
-main() {
+void f() {
if ()
}
''',
@@ -1157,7 +1157,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if () {
////
}
@@ -1170,7 +1170,7 @@
await _prepareCompletion(
'if',
'''
-main() {
+void f() {
if ////
}
''',
@@ -1178,7 +1178,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if () {
////
}
@@ -1191,7 +1191,7 @@
await _prepareCompletion(
'if (true)',
'''
-main() {
+void f() {
if (true)
return;
}
@@ -1200,7 +1200,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if (true) {
////
}
@@ -1214,7 +1214,7 @@
await _prepareCompletion(
'if (tr', // Trigger completion from within expression.
'''
-main() {
+void f() {
if (true)
}
''',
@@ -1222,7 +1222,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if (true) {
////
}
@@ -1235,7 +1235,7 @@
await _prepareCompletion(
'if (true',
'''
-main() {
+void f() {
if (true
}
''',
@@ -1243,7 +1243,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if (true) {
////
}
@@ -1256,7 +1256,7 @@
await _prepareCompletion(
'else',
'''
-main() {
+void f() {
if () {
} else
}
@@ -1265,7 +1265,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if () {
} else {
////
@@ -1279,7 +1279,7 @@
await _prepareCompletion(
'if ()',
'''
-main() {
+void f() {
if ()
else
}
@@ -1289,7 +1289,7 @@
// Note: if-statement completion should not trigger.
'Insert a newline at the end of the current line',
'''
-main() {
+void f() {
if ()
else
}
@@ -1301,7 +1301,7 @@
await _prepareCompletion(
'else',
'''
-main() {
+void f() {
if ()
else
}
@@ -1310,7 +1310,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if ()
else {
////
@@ -1324,7 +1324,7 @@
await _prepareCompletion(
'if (',
'''
-main() {
+void f() {
if ()
}
''',
@@ -1332,7 +1332,7 @@
_assertHasChange(
'Complete if-statement',
'''
-main() {
+void f() {
if () {
////
}
@@ -1348,13 +1348,13 @@
await _prepareCompletion(
'v = 1;',
'''
-main() {
+void f() {
int v = 1;
}
''',
atEnd: true);
_assertHasChange('Insert a newline at the end of the current line', '''
-main() {
+void f() {
int v = 1;
////
}
@@ -1382,7 +1382,7 @@
await _prepareCompletion(
'ing(3',
'''
-main() {
+void f() {
var s = 'sample'.substring(3
}
''',
@@ -1390,7 +1390,7 @@
_assertHasChange(
'Insert a newline at the end of the current line',
'''
-main() {
+void f() {
var s = 'sample'.substring(3);
////
}
@@ -1400,12 +1400,12 @@
Future<void> test_noCloseParenWithSemicolon() async {
var before = '''
-main() {
+void f() {
var s = 'sample'.substring(3;
}
''';
var after = '''
-main() {
+void f() {
var s = 'sample'.substring(3);
////
}
@@ -1423,7 +1423,7 @@
await _prepareCompletion(
'=> 3',
'''
-main() {
+void f() {
int f() => 3
}
''',
@@ -1431,7 +1431,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
int f() => 3;
////
}
@@ -1441,20 +1441,20 @@
Future<void> test_semicolonFnBody() async {
// It would be reasonable to add braces in this case. Unfortunately,
- // the incomplete line parses as two statements ['int;', 'f();'], not one.
+ // the incomplete line parses as two statements ['int;', 'g();'], not one.
await _prepareCompletion(
- 'f()',
+ 'g()',
'''
-main() {
- int f()
+void f() {
+ int g()
}
''',
atEnd: true);
_assertHasChange(
'Insert a newline at the end of the current line',
'''
-main() {
- int f()
+void f() {
+ int g()
}
''',
(s) => _afterLast(s, '()'));
@@ -1475,7 +1475,7 @@
await _prepareCompletion(
'f()',
'''
-main() {
+void f() {
int f()
}
f() {}
@@ -1484,7 +1484,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
int f();
////
}
@@ -1497,7 +1497,7 @@
await _prepareCompletion(
'=>',
'''
-main() {
+void f() {
int f() =>
}
''',
@@ -1505,7 +1505,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
int f() => ;
////
}
@@ -1517,7 +1517,7 @@
await _prepareCompletion(
'=>',
'''
-main() {
+void f() {
int f() => ////
}
''',
@@ -1525,7 +1525,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
int f() => ;
////
}
@@ -1537,7 +1537,7 @@
await _prepareCompletion(
'v = 1',
'''
-main() {
+void f() {
int v = 1
}
''',
@@ -1545,7 +1545,7 @@
_assertHasChange(
'Add a semicolon and newline',
'''
-main() {
+void f() {
int v = 1;
////
}
@@ -1560,7 +1560,7 @@
await _prepareCompletion(
'label',
'''
-main(x) {
+void f(x) {
switch (x) {
case label
}
@@ -1570,7 +1570,7 @@
_assertHasChange(
'Complete switch-statement',
'''
-main(x) {
+void f(x) {
switch (x) {
case label: ////
}
@@ -1583,7 +1583,7 @@
await _prepareCompletion(
'default',
'''
-main(x) {
+void f(x) {
switch (x) {
default
}
@@ -1593,7 +1593,7 @@
_assertHasChange(
'Complete switch-statement',
'''
-main(x) {
+void f(x) {
switch (x) {
default: ////
}
@@ -1606,7 +1606,7 @@
await _prepareCompletion(
'switch',
'''
-main() {
+void f() {
switch ()
}
''',
@@ -1614,7 +1614,7 @@
_assertHasChange(
'Complete switch-statement',
'''
-main() {
+void f() {
switch () {
////
}
@@ -1627,7 +1627,7 @@
await _prepareCompletion(
'switch',
'''
-main() {
+void f() {
switch////
}
''',
@@ -1635,7 +1635,7 @@
_assertHasChange(
'Complete switch-statement',
'''
-main() {
+void f() {
switch () {
////
}
@@ -1648,7 +1648,7 @@
await _prepareCompletion(
'switch',
'''
-main() {
+void f() {
switch ////
}
''',
@@ -1656,7 +1656,7 @@
_assertHasChange(
'Complete switch-statement',
'''
-main() {
+void f() {
switch () {
////
}
@@ -1672,7 +1672,7 @@
await _prepareCompletion(
'{} catch',
'''
-main() {
+void f() {
try {
} catch(e){} catch ////
}
@@ -1681,7 +1681,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} catch(e){} catch () {
////
@@ -1695,7 +1695,7 @@
await _prepareCompletion(
'} catch ',
'''
-main() {
+void f() {
try {
} catch() {
} catch(e){} catch ////
@@ -1705,7 +1705,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} catch() {
} catch(e){} catch () {
@@ -1720,7 +1720,7 @@
await _prepareCompletion(
'finally',
'''
-main() {
+void f() {
try {
} finally
}
@@ -1729,7 +1729,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} finally {
////
@@ -1743,7 +1743,7 @@
await _prepareCompletion(
'try',
'''
-main() {
+void f() {
try////
}
''',
@@ -1751,7 +1751,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
////
}
@@ -1764,7 +1764,7 @@
await _prepareCompletion(
'try',
'''
-main() {
+void f() {
try ////
}
''',
@@ -1772,7 +1772,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
////
}
@@ -1785,7 +1785,7 @@
await _prepareCompletion(
'on',
'''
-main() {
+void f() {
try {
} on catch
}
@@ -1794,7 +1794,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} on catch () {
////
@@ -1808,7 +1808,7 @@
await _prepareCompletion(
'on',
'''
-main() {
+void f() {
try {
} on catch
//
@@ -1818,7 +1818,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} on catch () {
////
@@ -1833,7 +1833,7 @@
await _prepareCompletion(
'on',
'''
-main() {
+void f() {
try {
} on
}
@@ -1842,7 +1842,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} on {
////
@@ -1856,7 +1856,7 @@
await _prepareCompletion(
'on',
'''
-main() {
+void f() {
try {
} on ////
}
@@ -1865,7 +1865,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} on {
////
@@ -1879,7 +1879,7 @@
await _prepareCompletion(
'on',
'''
-main() {
+void f() {
try {
} on ////
}
@@ -1888,7 +1888,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} on {
////
@@ -1902,7 +1902,7 @@
await _prepareCompletion(
'on',
'''
-main() {
+void f() {
try {
} on Exception
}
@@ -1911,7 +1911,7 @@
_assertHasChange(
'Complete try-statement',
'''
-main() {
+void f() {
try {
} on Exception {
////
@@ -1935,7 +1935,7 @@
await _prepareCompletion(
'while',
'''
-main() {
+void f() {
while ////
}
''',
@@ -1943,7 +1943,7 @@
_assertHasChange(
'Complete while-statement',
'''
-main() {
+void f() {
while () {
////
}
diff --git a/pkg/analysis_server/test/services/correction/name_suggestion_test.dart b/pkg/analysis_server/test/services/correction/name_suggestion_test.dart
index d304e5f..631e55e 100644
--- a/pkg/analysis_server/test/services/correction/name_suggestion_test.dart
+++ b/pkg/analysis_server/test/services/correction/name_suggestion_test.dart
@@ -18,7 +18,7 @@
class VariableNameSuggestionTest extends AbstractSingleUnitTest {
Future<void> test_forExpression_cast() async {
await resolveTestCode('''
-main() {
+void f() {
var sortedNodes;
var res = sortedNodes as String;
}
@@ -32,7 +32,7 @@
Future<void> test_forExpression_expectedType() async {
await resolveTestCode('''
class TreeNode {}
-main() {
+void f() {
TreeNode? node = null;
}
''');
@@ -46,7 +46,7 @@
Future<void> test_forExpression_expectedType_double() async {
await resolveTestCode('''
-main() {
+void f() {
double res = 0.0;
}
''');
@@ -66,7 +66,7 @@
Future<void> test_forExpression_expectedType_int() async {
await resolveTestCode('''
-main() {
+void f() {
int res = 0;
}
''');
@@ -86,7 +86,7 @@
Future<void> test_forExpression_expectedType_String() async {
await resolveTestCode('''
-main() {
+void f() {
String res = 'abc';
}
''');
@@ -121,7 +121,7 @@
Future<void> test_forExpression_indexExpression_endsWithE() async {
await resolveTestCode('''
-main() {
+void f() {
var topNodes = [0, 1, 2];
print(topNodes[0]);
}
@@ -136,7 +136,7 @@
verifyNoTestUnitErrors = false;
await resolveTestCode('''
import 'dart:math' as p;
-main(p) {
+void f(p) {
new NoSuchClass();
new p.NoSuchClass();
new NoSuchClass.named();
@@ -164,7 +164,7 @@
Future<void> test_forExpression_invocationArgument_named() async {
await resolveTestCode('''
foo({a, b, c}) {}
-main() {
+void f() {
foo(a: 111, c: 333, b: 222);
}
''');
@@ -189,7 +189,7 @@
Future<void> test_forExpression_invocationArgument_optional() async {
await resolveTestCode('''
foo(a, [b = 2, c = 3]) {}
-main() {
+void f() {
foo(111, 222, 333);
}
''');
@@ -214,7 +214,7 @@
Future<void> test_forExpression_invocationArgument_positional() async {
await resolveTestCode('''
foo(a, b) {}
-main() {
+void f() {
foo(111, 222);
}
''');
@@ -233,7 +233,7 @@
Future<void> test_forExpression_methodInvocation() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
var res = p.getSortedNodes();
}
''');
@@ -245,7 +245,7 @@
Future<void> test_forExpression_methodInvocation_noPrefix() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
var res = p.sortedNodes();
}
''');
@@ -257,7 +257,7 @@
Future<void> test_forExpression_name_get() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
var res = p.get();
}
''');
@@ -269,7 +269,7 @@
Future<void> test_forExpression_prefixedIdentifier() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
var res = p.sortedNodes;
}
''');
@@ -282,7 +282,7 @@
Future<void> test_forExpression_privateName() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p._name;
p._computeSuffix();
}
@@ -300,7 +300,7 @@
Future<void> test_forExpression_propertyAccess() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
var res = p.q.sortedNodes;
}
''');
@@ -312,7 +312,7 @@
Future<void> test_forExpression_simpleName() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
var sortedNodes = null;
var res = sortedNodes;
}
@@ -326,7 +326,7 @@
Future<void> test_forExpression_unqualifiedInvocation() async {
await resolveTestCode('''
getSortedNodes() => [];
-main(p) {
+void f(p) {
var res = getSortedNodes();
}
''');
diff --git a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
index bbe2a84..018abef 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_local_test.dart
@@ -25,7 +25,7 @@
Future<void> test_checkFinalConditions_sameVariable_after() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
var res;
}
@@ -39,7 +39,7 @@
Future<void> test_checkFinalConditions_sameVariable_before() async {
await indexTestUnit('''
-main() {
+void f() {
var res;
int a = 1 + 2;
}
@@ -53,7 +53,7 @@
Future<void> test_checkInitialCondition_false_outOfRange_length() async {
await indexTestUnit('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -64,7 +64,7 @@
Future<void> test_checkInitialCondition_outOfRange_offset() async {
await indexTestUnit('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -75,7 +75,7 @@
Future<void> test_checkInitialConditions_assignmentLeftHandSize() async {
await indexTestUnit('''
-main() {
+void f() {
var v = 0;
v = 1;
}
@@ -90,7 +90,7 @@
Future<void>
test_checkInitialConditions_namePartOfDeclaration_function() async {
await indexTestUnit('''
-void main() {
+void f() {
void foo() {}
}
''');
@@ -104,7 +104,7 @@
Future<void>
test_checkInitialConditions_namePartOfDeclaration_variable() async {
await indexTestUnit('''
-main() {
+void f() {
int vvv = 0;
}
''');
@@ -117,7 +117,7 @@
Future<void> test_checkInitialConditions_noExpression() async {
await indexTestUnit('''
-main() {
+void f() {
// abc
}
''');
@@ -141,14 +141,14 @@
Future<void>
test_checkInitialConditions_stringSelection_leadingQuote() async {
await indexTestUnit('''
-main() {
+void f() {
var vvv = 'abc';
}
''');
_createRefactoringForString("'a");
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 'abc';
var vvv = res;
}
@@ -158,14 +158,14 @@
Future<void>
test_checkInitialConditions_stringSelection_trailingQuote() async {
await indexTestUnit('''
-main() {
+void f() {
var vvv = 'abc';
}
''');
_createRefactoringForString("c'");
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 'abc';
var vvv = res;
}
@@ -174,7 +174,7 @@
Future<void> test_checkInitialConditions_voidExpression() async {
await indexTestUnit('''
-main() {
+void f() {
print(42);
}
''');
@@ -187,7 +187,7 @@
Future<void> test_checkName() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
@@ -205,7 +205,7 @@
Future<void> test_checkName_conflict_withInvokedFunction() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
res();
}
@@ -222,7 +222,7 @@
Future<void> test_checkName_conflict_withOtherLocal() async {
await indexTestUnit('''
-main() {
+void f() {
var res;
int a = 1 + 2;
}
@@ -237,7 +237,7 @@
Future<void> test_checkName_conflict_withTypeName() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
Res? b = null;
}
@@ -254,14 +254,14 @@
Future<void> test_completeStatementExpression() async {
await indexTestUnit('''
-main(p) {
+void f(p) {
p.toString();
}
''');
_createRefactoringForString('p.toString()');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main(p) {
+void f(p) {
var res = p.toString();
}
''');
@@ -272,7 +272,7 @@
class A {
const A(int a, int b);
}
-main() {
+void f() {
const A(1, 2);
}
''');
@@ -282,7 +282,7 @@
class A {
const A(int a, int b);
}
-main() {
+void f() {
const res = 1;
const A(res, 2);
}
@@ -291,14 +291,14 @@
Future<void> test_const_inList() async {
await indexTestUnit('''
-main() {
+void f() {
const [1, 2];
}
''');
_createRefactoringForString('1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = 1;
const [res, 2];
}
@@ -307,14 +307,14 @@
Future<void> test_const_inList_inBinaryExpression() async {
await indexTestUnit('''
-main() {
+void f() {
const [1 + 2, 3];
}
''');
_createRefactoringForString('1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = 1;
const [res + 2, 3];
}
@@ -323,14 +323,14 @@
Future<void> test_const_inList_inConditionalExpression() async {
await indexTestUnit('''
-main() {
+void f() {
const [true ? 1 : 2, 3];
}
''');
_createRefactoringForString('1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = 1;
const [true ? res : 2, 3];
}
@@ -339,14 +339,14 @@
Future<void> test_const_inList_inParenthesis() async {
await indexTestUnit('''
-main() {
+void f() {
const [(1), 2];
}
''');
_createRefactoringForString('1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = 1;
const [(res), 2];
}
@@ -355,14 +355,14 @@
Future<void> test_const_inList_inPrefixExpression() async {
await indexTestUnit('''
-main() {
+void f() {
const [!true, 2];
}
''');
_createRefactoringForString('true');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = true;
const [!res, 2];
}
@@ -371,14 +371,14 @@
Future<void> test_const_inMap_key() async {
await indexTestUnit('''
-main() {
+void f() {
const {1: 2};
}
''');
_createRefactoringForString('1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = 1;
const {res: 2};
}
@@ -387,14 +387,14 @@
Future<void> test_const_inMap_value() async {
await indexTestUnit('''
-main() {
+void f() {
const {1: 2};
}
''');
_createRefactoringForString('2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
const res = 2;
const {1: res};
}
@@ -403,7 +403,7 @@
Future<void> test_coveringExpressions() async {
await indexTestUnit('''
-main() {
+void f() {
int aaa = 1;
int bbb = 2;
var c = aaa + bbb * 2 + 3;
@@ -419,7 +419,7 @@
Future<void> test_coveringExpressions_inArgumentList() async {
await indexTestUnit('''
-main() {
+void f() {
foo(111 + 222);
}
int foo(int x) => x;
@@ -433,7 +433,7 @@
Future<void> test_coveringExpressions_inInvocationOfVoidFunction() async {
await indexTestUnit('''
-main() {
+void f() {
foo(111 + 222);
}
void foo(int x) {}
@@ -447,7 +447,7 @@
Future<void> test_coveringExpressions_namedExpression_value() async {
await indexTestUnit('''
-main() {
+void f() {
foo(ppp: 42);
}
int foo({int ppp: 0}) => ppp + 1;
@@ -461,7 +461,7 @@
Future<void> test_coveringExpressions_skip_assignment() async {
await indexTestUnit('''
-main() {
+void f() {
int v;
foo(v = 111 + 222);
}
@@ -479,7 +479,7 @@
class AAA {
AAA.name() {}
}
-main() {
+void f() {
var v = new AAA.name();
}
''');
@@ -495,7 +495,7 @@
class A {
A.name() {}
}
-main() {
+void f() {
var v = new A.name();
}
''');
@@ -509,7 +509,7 @@
Future<void> test_coveringExpressions_skip_constructorName_type() async {
await indexTestUnit('''
class A {}
-main() {
+void f() {
var v = new A();
}
''');
@@ -524,7 +524,7 @@
test_coveringExpressions_skip_constructorName_typeArgument() async {
await indexTestUnit('''
class A<T> {}
-main() {
+void f() {
var v = new A<String>();
}
''');
@@ -537,7 +537,7 @@
Future<void> test_coveringExpressions_skip_namedExpression() async {
await indexTestUnit('''
-main() {
+void f() {
foo(ppp: 42);
}
int foo({int ppp: 0}) => ppp + 1;
@@ -551,14 +551,14 @@
Future<void> test_fragmentExpression() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 3 + 4;
}
''');
_createRefactoringForString('2 + 3');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2 + 3;
int a = res + 4;
}
@@ -567,14 +567,14 @@
Future<void> test_fragmentExpression_leadingNotWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 3 + 4;
}
''');
_createRefactoringForString('+ 2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2;
int a = res + 3 + 4;
}
@@ -583,14 +583,14 @@
Future<void> test_fragmentExpression_leadingPartialSelection() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 111 + 2 + 3 + 4;
}
''');
_createRefactoringForString('11 + 2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 111 + 2;
int a = res + 3 + 4;
}
@@ -599,14 +599,14 @@
Future<void> test_fragmentExpression_leadingWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 3 + 4;
}
''');
_createRefactoringForString(' 2 + 3');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2 + 3;
int a = res + 4;
}
@@ -615,14 +615,14 @@
Future<void> test_fragmentExpression_notAssociativeOperator() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 - 2 - 3 - 4;
}
''');
_createRefactoringForString('2 - 3');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 - 2 - 3;
int a = res - 4;
}
@@ -631,14 +631,14 @@
Future<void> test_fragmentExpression_trailingNotWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 3 + 4;
}
''');
_createRefactoringForString('1 + 2 +');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2 + 3;
int a = res + 4;
}
@@ -647,14 +647,14 @@
Future<void> test_fragmentExpression_trailingPartialSelection() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 333 + 4;
}
''');
_createRefactoringForString('2 + 33');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2 + 333;
int a = res + 4;
}
@@ -663,14 +663,14 @@
Future<void> test_fragmentExpression_trailingWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 3 + 4;
}
''');
_createRefactoringForString('2 + 3 ');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2 + 3;
int a = res + 4;
}
@@ -679,7 +679,7 @@
Future<void> test_guessNames_fragmentExpression() async {
await indexTestUnit('''
-main() {
+void f() {
var a = 111 + 222 + 333 + 444;
}
''');
@@ -694,7 +694,7 @@
class TreeItem {}
TreeItem? getSelectedItem() => null;
process(my) {}
-main() {
+void f() {
process(getSelectedItem()); // marker
}
''');
@@ -707,7 +707,7 @@
Future<void> test_guessNames_stringPart() async {
await indexTestUnit('''
-main() {
+void f() {
var s = 'Hello Bob... welcome to Dart!';
}
''');
@@ -727,7 +727,7 @@
Future<void> test_isAvailable_true() async {
await indexTestUnit('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -738,14 +738,14 @@
Future<void> test_lint_prefer_final_locals() async {
createAnalysisOptionsFile(lints: [LintNames.prefer_final_locals]);
await indexTestUnit('''
-main() {
+void f() {
print(1 + 2);
}
''');
_createRefactoringForString('1 + 2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
final res = 1 + 2;
print(res);
}
@@ -784,7 +784,7 @@
Future<void> test_occurrences_differentVariable() async {
await indexTestUnit('''
-main() {
+void f() {
{
int v = 1;
print(v + 1); // marker
@@ -799,7 +799,7 @@
_createRefactoringWithSuffix('v + 1', '); // marker');
// apply refactoring
await _assertSuccessfulRefactoring('''
-main() {
+void f() {
{
int v = 1;
var res = v + 1;
@@ -813,13 +813,13 @@
}
''');
_assertSingleLinkedEditGroup(
- length: 3, offsets: [36, 59, 85], names: ['object', 'i']);
+ length: 3, offsets: [38, 61, 87], names: ['object', 'i']);
}
Future<void> test_occurrences_disableOccurrences() async {
await indexTestUnit('''
int foo() => 42;
-main() {
+void f() {
int a = 1 + foo();
int b = 2 + foo(); // marker
}
@@ -829,7 +829,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
int foo() => 42;
-main() {
+void f() {
int a = 1 + foo();
var res = foo();
int b = 2 + res; // marker
@@ -839,7 +839,7 @@
Future<void> test_occurrences_ignore_assignmentLeftHandSize() async {
await indexTestUnit('''
-main() {
+void f() {
int v = 1;
v = 2;
print(() {v = 2;});
@@ -850,7 +850,7 @@
_createRefactoringWithSuffix('v', '); // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v = 1;
v = 2;
print(() {v = 2;});
@@ -863,7 +863,7 @@
Future<void> test_occurrences_ignore_nameOfVariableDeclaration() async {
await indexTestUnit('''
-main() {
+void f() {
int v = 1;
print(v); // marker
}
@@ -871,7 +871,7 @@
_createRefactoringWithSuffix('v', '); // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v = 1;
var res = v;
print(res); // marker
@@ -882,7 +882,7 @@
Future<void> test_occurrences_singleExpression() async {
await indexTestUnit('''
int foo() => 42;
-main() {
+void f() {
int a = 1 + foo();
int b = 2 + foo(); // marker
}
@@ -891,7 +891,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
int foo() => 42;
-main() {
+void f() {
var res = foo();
int a = 1 + res;
int b = 2 + res; // marker
@@ -901,7 +901,7 @@
Future<void> test_occurrences_useDominator() async {
await indexTestUnit('''
-main() {
+void f() {
if (true) {
print(42);
} else {
@@ -912,7 +912,7 @@
_createRefactoringForString('42');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 42;
if (true) {
print(res);
@@ -926,7 +926,7 @@
Future<void> test_occurrences_whenComment() async {
await indexTestUnit('''
int foo() => 42;
-main() {
+void f() {
/*int a = 1 + foo();*/
int b = 2 + foo(); // marker
}
@@ -935,7 +935,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
int foo() => 42;
-main() {
+void f() {
/*int a = 1 + foo();*/
var res = foo();
int b = 2 + res; // marker
@@ -946,7 +946,7 @@
Future<void> test_occurrences_withSpace() async {
await indexTestUnit('''
int foo(String s) => 42;
-main() {
+void f() {
int a = 1 + foo('has space');
int b = 2 + foo('has space'); // marker
}
@@ -955,7 +955,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
int foo(String s) => 42;
-main() {
+void f() {
var res = foo('has space');
int a = 1 + res;
int b = 2 + res; // marker
@@ -966,7 +966,7 @@
Future<void> test_offsets_lengths() async {
await indexTestUnit('''
int foo() => 42;
-main() {
+void f() {
int a = 1 + foo(); // marker
int b = 2 + foo( );
}
@@ -981,14 +981,14 @@
Future<void> test_singleExpression() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
_createRefactoringForString('1 + 2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2;
int a = res;
}
@@ -1000,7 +1000,7 @@
class A {
int get foo => 42;
}
-main() {
+void f() {
A a = new A();
int b = 1 + a.foo; // marker
}
@@ -1011,7 +1011,7 @@
class A {
int get foo => 42;
}
-main() {
+void f() {
A a = new A();
var res = a.foo;
int b = 1 + res; // marker
@@ -1023,7 +1023,7 @@
Future<void> test_singleExpression_hasParseError_expectedSemicolon() async {
verifyNoTestUnitErrors = false;
await indexTestUnit('''
-main(p) {
+void f(p) {
foo
p.bar.baz;
}
@@ -1031,7 +1031,7 @@
_createRefactoringForString('p.bar');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main(p) {
+void f(p) {
foo
var res = p.bar;
res.baz;
@@ -1041,14 +1041,14 @@
Future<void> test_singleExpression_inExpressionBody_ofClosure() async {
await indexTestUnit('''
-main() {
+void f() {
print((x) => x.y * x.y + 1);
}
''');
_createRefactoringForString('x.y');
// apply refactoring
await _assertSuccessfulRefactoring('''
-main() {
+void f() {
print((x) {
var res = x.y;
return res * res + 1;
@@ -1056,7 +1056,7 @@
}
''');
_assertSingleLinkedEditGroup(
- length: 3, offsets: [31, 53, 59], names: ['y']);
+ length: 3, offsets: [33, 55, 61], names: ['y']);
}
Future<void> test_singleExpression_inExpressionBody_ofFunction() async {
@@ -1126,7 +1126,7 @@
Future<void> test_singleExpression_inMethod() async {
await indexTestUnit('''
class A {
- main() {
+ void f() {
print(1 + 2);
}
}
@@ -1135,7 +1135,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
class A {
- main() {
+ void f() {
var res = 1 + 2;
print(res);
}
@@ -1145,14 +1145,14 @@
Future<void> test_singleExpression_leadingNotWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 12 + 345;
}
''');
_createRefactoringForString('+ 345');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 12 + 345;
int a = res;
}
@@ -1161,14 +1161,14 @@
Future<void> test_singleExpression_leadingWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 /*abc*/ + 2 + 345;
}
''');
_createRefactoringForString('1 /*abc*/');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 /*abc*/ + 2;
int a = res + 345;
}
@@ -1177,7 +1177,7 @@
Future<void> test_singleExpression_methodName_reference() async {
await indexTestUnit('''
-main() {
+void f() {
var v = foo().length;
}
String foo() => '';
@@ -1185,7 +1185,7 @@
_createRefactoringWithSuffix('foo', '().');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = foo();
var v = res.length;
}
@@ -1195,14 +1195,14 @@
Future<void> test_singleExpression_nameOfProperty_prefixedIdentifier() async {
await indexTestUnit('''
-main(p) {
+void f(p) {
var v = p.value; // marker
}
''');
_createRefactoringWithSuffix('value', '; // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main(p) {
+void f(p) {
var res = p.value;
var v = res; // marker
}
@@ -1211,7 +1211,7 @@
Future<void> test_singleExpression_nameOfProperty_propertyAccess() async {
await indexTestUnit('''
-main() {
+void f() {
var v = foo().length; // marker
}
String foo() => '';
@@ -1219,7 +1219,7 @@
_createRefactoringWithSuffix('length', '; // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = foo().length;
var v = res; // marker
}
@@ -1232,14 +1232,14 @@
/// handled as a single expression.
Future<void> test_singleExpression_partOfBinaryExpression() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 + 3 + 4;
}
''');
_createRefactoringForString('1 + 2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2;
int a = res + 3 + 4;
}
@@ -1248,14 +1248,14 @@
Future<void> test_singleExpression_string() async {
await indexTestUnit('''
-void main() {
+void f() {
print("1234");
}
''');
_createRefactoringAtString('34"');
// apply refactoring
return _assertSuccessfulRefactoring('''
-void main() {
+void f() {
var res = "1234";
print(res);
}
@@ -1264,14 +1264,14 @@
Future<void> test_singleExpression_trailingNotWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 12 + 345;
}
''');
_createRefactoringForString('12 +');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 12 + 345;
int a = res;
}
@@ -1280,14 +1280,14 @@
Future<void> test_singleExpression_trailingWhitespace() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2 ;
}
''');
_createRefactoringForString('1 + 2 ');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 1 + 2;
int a = res ;
}
@@ -1296,42 +1296,42 @@
Future<void> test_stringLiteral_part() async {
await indexTestUnit('''
-main() {
+void f() {
print('abcdefgh');
}
''');
_createRefactoringForString('cde');
// apply refactoring
await _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
var res = 'cde';
print('ab${res}fgh');
}
''');
- _assertSingleLinkedEditGroup(length: 3, offsets: [15, 41], names: ['cde']);
+ _assertSingleLinkedEditGroup(length: 3, offsets: [17, 43], names: ['cde']);
}
Future<void> test_stringLiteral_whole() async {
await indexTestUnit('''
-main() {
+void f() {
print('abc');
}
''');
_createRefactoringForString("'abc'");
// apply refactoring
await _assertSuccessfulRefactoring('''
-main() {
+void f() {
var res = 'abc';
print(res);
}
''');
_assertSingleLinkedEditGroup(
- length: 3, offsets: [15, 36], names: ['object', 's']);
+ length: 3, offsets: [17, 38], names: ['object', 's']);
}
Future<void> test_stringLiteralPart() async {
await indexTestUnit(r'''
-main() {
+void f() {
int x = 1;
int y = 2;
print('$x+$y=${x+y}');
@@ -1340,14 +1340,14 @@
_createRefactoringForString(r'$x+$y');
// apply refactoring
await _assertSuccessfulRefactoring(r'''
-main() {
+void f() {
int x = 1;
int y = 2;
var res = '$x+$y';
print('${res}=${x+y}');
}
''');
- _assertSingleLinkedEditGroup(length: 3, offsets: [41, 67], names: ['xy']);
+ _assertSingleLinkedEditGroup(length: 3, offsets: [43, 69], names: ['xy']);
}
Future _assertInitialConditions_fatal_selection() async {
diff --git a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
index e530fd5..66861c0 100644
--- a/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/extract_method_test.dart
@@ -22,7 +22,7 @@
Future<void> test_bad_assignmentLeftHandSide() async {
await indexTestUnit('''
-main() {
+void f() {
int aaa;
aaa = 0;
}
@@ -34,7 +34,7 @@
Future<void> test_bad_comment_selectionEndsInside() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(0);
/*
@@ -48,7 +48,7 @@
Future<void> test_bad_comment_selectionStartsInside() async {
await indexTestUnit('''
-main() {
+void f() {
/*
// start
*/
@@ -64,7 +64,7 @@
await indexTestUnit('''
class A {
void res() {}
- main() {
+ void f() {
// start
print(0);
// end
@@ -82,7 +82,7 @@
void res() {} // marker
}
class B extends A {
- main() {
+ void f() {
res();
// start
print(0);
@@ -99,7 +99,7 @@
library my.lib;
void res() {}
-main() {
+void f() {
// start
print(0);
// end
@@ -120,7 +120,7 @@
res(); // marker
}
}
-main() {
+void f() {
// start
print(0);
// end
@@ -169,7 +169,7 @@
Future<void> test_bad_doWhile_body() async {
await indexTestUnit('''
-main() {
+void f() {
do
// start
{
@@ -185,7 +185,7 @@
Future<void> test_bad_emptySelection() async {
await indexTestUnit('''
-main() {
+void f() {
// start
// end
print(0);
@@ -198,7 +198,7 @@
Future<void> test_bad_forLoop_conditionAndUpdaters() async {
await indexTestUnit('''
-main() {
+void f() {
for (
int i = 0;
// start
@@ -215,7 +215,7 @@
Future<void> test_bad_forLoop_init() async {
await indexTestUnit('''
-main() {
+void f() {
for (
// start
int i = 0
@@ -232,7 +232,7 @@
Future<void> test_bad_forLoop_initAndCondition() async {
await indexTestUnit('''
-main() {
+void f() {
for (
// start
int i = 0;
@@ -249,7 +249,7 @@
Future<void> test_bad_forLoop_updaters() async {
await indexTestUnit('''
-main() {
+void f() {
for (
int i = 0;
i < 10;
@@ -266,7 +266,7 @@
Future<void> test_bad_forLoop_updatersAndBody() async {
await indexTestUnit('''
-main() {
+void f() {
for (
int i = 0;
i < 10;
@@ -283,27 +283,27 @@
Future<void> test_bad_methodName_reference() async {
await indexTestUnit('''
-main() {
- main();
+void f() {
+ f();
}
''');
- _createRefactoringWithSuffix('main', '();');
+ _createRefactoringWithSuffix('f', '();');
return _assertConditionsFatal('Cannot extract a single method name.');
}
Future<void> test_bad_namePartOfDeclaration_function() async {
await indexTestUnit('''
-void main() {
+void f() {
}
''');
- _createRefactoringForString('main');
+ _createRefactoringForString('f');
return _assertConditionsFatal(
'Cannot extract the name part of a declaration.');
}
Future<void> test_bad_namePartOfDeclaration_variable() async {
await indexTestUnit('''
-main() {
+void f() {
int vvv = 0;
}
''');
@@ -329,7 +329,7 @@
Future<void> test_bad_newMethodName_notIdentifier() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(0);
// end
@@ -343,7 +343,7 @@
Future<void> test_bad_notSameParent() async {
await indexTestUnit('''
-main() {
+void f() {
while (false)
// start
{
@@ -359,7 +359,7 @@
Future<void> test_bad_parameterName_duplicate() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
// start
@@ -382,7 +382,7 @@
Future<void> test_bad_parameterName_inUse_function() async {
await indexTestUnit('''
-main() {
+void g() {
int v1 = 1;
int v2 = 2;
// start
@@ -406,7 +406,7 @@
Future<void> test_bad_parameterName_inUse_localVariable() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
// start
@@ -430,7 +430,7 @@
Future<void> test_bad_parameterName_inUse_method() async {
await indexTestUnit('''
class A {
- main() {
+ void f() {
int v1 = 1;
int v2 = 2;
// start
@@ -455,7 +455,7 @@
Future<void> test_bad_selectionEndsInSomeNode() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(0);
print(1);
@@ -485,7 +485,7 @@
Future<void> test_bad_statements_return_andAssignsVariable() async {
await indexTestUnit('''
-main() {
+int f() {
// start
var v = 0;
return 42;
@@ -501,7 +501,7 @@
Future<void> test_bad_switchCase() async {
await indexTestUnit('''
-main() {
+void f() {
switch (1) {
// start
case 0: break;
@@ -517,7 +517,7 @@
Future<void> test_bad_tokensBetweenLastNodeAndSelectionEnd() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(0);
print(1);
@@ -531,7 +531,7 @@
Future<void> test_bad_tokensBetweenSelectionStartAndFirstNode() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(0); // marker
print(1);
@@ -545,7 +545,7 @@
Future<void> test_bad_try_catchBlock_block() async {
await indexTestUnit('''
-main() {
+void f() {
try
{}
catch (e)
@@ -562,7 +562,7 @@
Future<void> test_bad_try_catchBlock_complete() async {
await indexTestUnit('''
-main() {
+void f() {
try
{}
// start
@@ -579,7 +579,7 @@
Future<void> test_bad_try_catchBlock_exception() async {
await indexTestUnit('''
-main() {
+void f() {
try {
} catch (
// start
@@ -596,7 +596,7 @@
Future<void> test_bad_try_finallyBlock() async {
await indexTestUnit('''
-main() {
+void f() {
try
{}
finally
@@ -613,7 +613,7 @@
Future<void> test_bad_try_tryBlock() async {
await indexTestUnit('''
-main() {
+void f() {
try
// start
{}
@@ -630,7 +630,7 @@
Future<void> test_bad_typeReference() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 0;
}
''');
@@ -640,7 +640,7 @@
Future<void> test_bad_variableDeclarationFragment() async {
await indexTestUnit('''
-main() {
+void f() {
int
// start
a = 1
@@ -655,7 +655,7 @@
Future<void> test_bad_while_conditionAndBody() async {
await indexTestUnit('''
-main() {
+void f() {
while
// start
(false)
@@ -671,7 +671,7 @@
Future<void> test_canExtractGetter_false_closure() async {
await indexTestUnit('''
-main() {
+void f() {
useFunction((_) => true);
}
useFunction(filter(String p)) {}
@@ -687,7 +687,7 @@
await indexTestUnit('''
class A {
var f;
- main() {
+ void m() {
// start
f = 1;
// end
@@ -731,7 +731,7 @@
Future<void> test_canExtractGetter_false_returnNotUsed_noReturn() async {
await indexTestUnit('''
var topVar = 0;
-main() {
+void f() {
// start
int a = 1;
int b = 2;
@@ -748,7 +748,7 @@
Future<void> test_canExtractGetter_true() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
@@ -761,7 +761,7 @@
Future<void> test_checkInitialCondition_false_outOfRange_length() async {
await indexTestUnit('''
-main() {
+void f() {
1 + 2;
}
''');
@@ -772,7 +772,7 @@
Future<void> test_checkInitialCondition_outOfRange_offset() async {
await indexTestUnit('''
-main() {
+void f() {
1 + 2;
}
''');
@@ -783,7 +783,7 @@
Future<void> test_checkName() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
@@ -817,7 +817,7 @@
Future<void> test_closure_asFunction_singleExpression() async {
await indexTestUnit('''
process(f(x)) {}
-main() {
+void f() {
process((x) => x * 2);
}
''');
@@ -825,7 +825,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
process(f(x)) {}
-main() {
+void f() {
process(res);
}
@@ -836,7 +836,7 @@
Future<void> test_closure_asFunction_statements() async {
await indexTestUnit('''
process(f(x)) {}
-main() {
+void f() {
process((x) {
print(x);
return x * 2;
@@ -847,7 +847,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
process(f(x)) {}
-main() {
+void f() {
process(res); // marker
}
@@ -863,7 +863,7 @@
process(f(x)) {}
class A {
int k = 2;
- main() {
+ void f() {
process((x) {
print(x);
return x * k;
@@ -877,7 +877,7 @@
process(f(x)) {}
class A {
int k = 2;
- main() {
+ void f() {
process(res); // marker
}
@@ -893,7 +893,7 @@
await indexTestUnit('''
void process({int fff(int x)?}) {}
class C {
- main() {
+ void f() {
process(fff: (int x) => x * 2);
}
}
@@ -903,7 +903,7 @@
return _assertSuccessfulRefactoring('''
void process({int fff(int x)?}) {}
class C {
- main() {
+ void f() {
process(fff: res);
}
@@ -916,7 +916,7 @@
await indexTestUnit('''
void process(num f(int x)) {}
class C {
- main() {
+ void f() {
process((int x) => x * 2);
}
}
@@ -926,7 +926,7 @@
return _assertSuccessfulRefactoring('''
void process(num f(int x)) {}
class C {
- main() {
+ void f() {
process(res);
}
@@ -938,7 +938,7 @@
Future<void> test_closure_bad_referencesLocalVariable() async {
await indexTestUnit('''
process(f(x)) {}
-main() {
+void f() {
int k = 2;
process((x) => x * k);
}
@@ -989,7 +989,7 @@
Future<void> test_getExtractGetter_expression_true_binaryExpression() async {
await indexTestUnit('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -1001,7 +1001,7 @@
Future<void> test_getExtractGetter_expression_true_literal() async {
await indexTestUnit('''
-main() {
+void f() {
print(42);
}
''');
@@ -1014,7 +1014,7 @@
Future<void>
test_getExtractGetter_expression_true_prefixedExpression() async {
await indexTestUnit('''
-main() {
+void f() {
print(!true);
}
''');
@@ -1027,7 +1027,7 @@
Future<void>
test_getExtractGetter_expression_true_prefixedIdentifier() async {
await indexTestUnit('''
-main() {
+void f() {
print(myValue.isEven);
}
int get myValue => 42;
@@ -1040,7 +1040,7 @@
Future<void> test_getExtractGetter_expression_true_propertyAccess() async {
await indexTestUnit('''
-main() {
+void f() {
print(1.isEven);
}
''');
@@ -1052,7 +1052,7 @@
Future<void> test_getExtractGetter_statements() async {
await indexTestUnit('''
-main() {
+void f() {
// start
int v = 0;
// end
@@ -1067,7 +1067,7 @@
Future<void> test_getRefactoringName_function() async {
await indexTestUnit('''
-main() {
+void f() {
print(1 + 2);
}
''');
@@ -1078,7 +1078,7 @@
Future<void> test_getRefactoringName_method() async {
await indexTestUnit('''
class A {
- main() {
+ void f() {
print(1 + 2);
}
}
@@ -1089,15 +1089,15 @@
Future<void> test_isAvailable_false_functionName() async {
await indexTestUnit('''
-void main() {}
+void f() {}
''');
- _createRefactoringForString('main');
+ _createRefactoringForString('f');
expect(refactoring.isAvailable(), isFalse);
}
Future<void> test_isAvailable_true() async {
await indexTestUnit('''
-main() {
+void f() {
1 + 2;
}
''');
@@ -1110,7 +1110,7 @@
class TreeItem {}
TreeItem getSelectedItem() => throw 0;
process(my) {}
-main() {
+void f() {
process(getSelectedItem()); // marker
int treeItem = 0;
}
@@ -1124,7 +1124,7 @@
Future<void> test_offsets_lengths() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
int b = 1 + 2;
}
@@ -1140,7 +1140,7 @@
Future<void> test_returnType_closure() async {
await indexTestUnit('''
process(f(x)) {}
-main() {
+void f() {
process((x) => x * 2);
}
''');
@@ -1152,7 +1152,7 @@
Future<void> test_returnType_expression() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
@@ -1164,7 +1164,7 @@
Future<void> test_returnType_mixInterfaceFunction() async {
await indexTestUnit('''
-main() {
+Object f() {
// start
if (true) {
return 1;
@@ -1182,7 +1182,7 @@
Future<void> test_returnType_statements() async {
await indexTestUnit('''
-main() {
+void f() {
// start
double v = 5.0;
// end
@@ -1214,7 +1214,7 @@
Future<void> test_returnType_statements_void() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(42);
// end
@@ -1228,7 +1228,7 @@
Future<void> test_setExtractGetter() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
@@ -1239,7 +1239,7 @@
expect(refactoring.createGetter, true);
refactoringChange = await refactoring.createChange();
assertTestChangeResult('''
-main() {
+void f() {
int a = res;
}
@@ -1249,14 +1249,14 @@
Future<void> test_singleExpression() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1 + 2;
}
''');
_createRefactoringForString('1 + 2');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int a = res();
}
@@ -1266,7 +1266,7 @@
Future<void> test_singleExpression_cascade() async {
await indexTestUnit('''
-main() {
+void f() {
String s = '';
var v = s..length;
}
@@ -1274,7 +1274,7 @@
_createRefactoringForString('s..length');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
String s = '';
var v = res(s);
}
@@ -1310,7 +1310,7 @@
Future<void> test_singleExpression_dynamic() async {
await indexTestUnit('''
dynaFunction() {}
-main() {
+void f() {
var v = dynaFunction(); // marker
}
''');
@@ -1318,7 +1318,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
dynaFunction() {}
-main() {
+void f() {
var v = res(); // marker
}
@@ -1330,7 +1330,7 @@
await indexTestUnit('''
import 'dart:async';
Future<int> getValue() async => 42;
-main() async {
+void f() async {
int v = await getValue();
print(v);
}
@@ -1340,7 +1340,7 @@
return _assertSuccessfulRefactoring('''
import 'dart:async';
Future<int> getValue() async => 42;
-main() async {
+void f() async {
int v = await res();
print(v);
}
@@ -1351,7 +1351,7 @@
Future<void> test_singleExpression_ignore_assignmentLeftHandSize() async {
await indexTestUnit('''
-main() {
+void f() {
getButton().text = 'txt';
print(getButton().text); // marker
}
@@ -1360,7 +1360,7 @@
_createRefactoringWithSuffix('getButton().text', '); // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
getButton().text = 'txt';
print(res()); // marker
}
@@ -1372,7 +1372,7 @@
Future<void> test_singleExpression_occurrences() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1389,7 +1389,7 @@
_createRefactoringWithSuffix('v1 + v2', '; // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1409,7 +1409,7 @@
Future<void> test_singleExpression_occurrences_disabled() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1421,7 +1421,7 @@
refactoring.extractAll = false;
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1442,7 +1442,7 @@
int positiveA = v1 + v2; // marker
}
}
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int negA = v1 + v2;
@@ -1460,7 +1460,7 @@
int res(int v1, int v2) => v1 + v2;
}
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int negA = v1 + v2;
@@ -1470,7 +1470,7 @@
Future<void> test_singleExpression_occurrences_incompatibleTypes() async {
await indexTestUnit('''
-main() {
+void f() {
int x = 1;
String y = 'foo';
print(x.toString());
@@ -1480,7 +1480,7 @@
_createRefactoringForString('x.toString()');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int x = 1;
String y = 'foo';
print(res(x));
@@ -1493,7 +1493,7 @@
Future<void> test_singleExpression_occurrences_inWholeUnit() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int positiveA = v1 + v2; // marker
@@ -1509,7 +1509,7 @@
_createRefactoringWithSuffix('v1 + v2', '; // marker');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int positiveA = res(v1, v2); // marker
@@ -1549,7 +1549,7 @@
_addLibraryReturningAsync();
await indexTestUnit('''
import 'asyncLib.dart';
-main() {
+void f() {
var a = newCompleter();
}
''');
@@ -1558,7 +1558,7 @@
return _assertSuccessfulRefactoring('''
import 'asyncLib.dart';
import 'dart:async';
-main() {
+void f() {
var a = res();
}
@@ -1568,14 +1568,14 @@
Future<void> test_singleExpression_returnTypeGeneric() async {
await indexTestUnit('''
-main() {
+void f() {
var v = <String>[];
}
''');
_createRefactoringForString('<String>[]');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var v = res();
}
@@ -1586,7 +1586,7 @@
Future<void> test_singleExpression_returnTypePrefix() async {
await indexTestUnit('''
import 'dart:math' as pref;
-main() {
+void f() {
var v = new pref.Random();
}
''');
@@ -1594,7 +1594,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
import 'dart:math' as pref;
-main() {
+void f() {
var v = res();
}
@@ -1774,7 +1774,7 @@
Future<void> test_singleExpression_withVariables() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int a = v1 + v2 + v1;
@@ -1783,7 +1783,7 @@
_createRefactoringForString('v1 + v2 + v1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int a = res(v1, v2);
@@ -1795,7 +1795,7 @@
Future<void> test_singleExpression_withVariables_doRename() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1818,7 +1818,7 @@
await assertRefactoringFinalConditionsOK();
refactoring.createGetter = false;
return _assertRefactoringChange('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1832,7 +1832,7 @@
Future<void> test_singleExpression_withVariables_doReorder() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1855,7 +1855,7 @@
await assertRefactoringFinalConditionsOK();
refactoring.createGetter = false;
return _assertRefactoringChange('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1869,7 +1869,7 @@
Future<void> test_singleExpression_withVariables_namedExpression() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int a = process(arg: v1 + v2);
@@ -1879,7 +1879,7 @@
_createRefactoringForString('process(arg: v1 + v2)');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int a = res(v1, v2);
@@ -1892,7 +1892,7 @@
Future<void> test_singleExpression_withVariables_newType() async {
await indexTestUnit('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1916,7 +1916,7 @@
await assertRefactoringFinalConditionsOK();
refactoring.createGetter = false;
return _assertRefactoringChange('''
-main() {
+void f() {
int v1 = 1;
int v2 = 2;
int v3 = 3;
@@ -1929,7 +1929,7 @@
Future<void> test_singleExpression_withVariables_useBestType() async {
await indexTestUnit('''
-main() {
+void f() {
var v1 = 1;
var v2 = 2;
var a = v1 + v2 + v1; // marker
@@ -1938,7 +1938,7 @@
_createRefactoringForString('v1 + v2 + v1');
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
var v1 = 1;
var v2 = 2;
var a = res(v1, v2); // marker
@@ -1950,7 +1950,7 @@
Future<void> test_statements_assignment() async {
await indexTestUnit('''
-main() {
+void f() {
int v;
// start
v = 5;
@@ -1961,7 +1961,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int v;
// start
v = res(v);
@@ -1978,7 +1978,7 @@
Future<void> test_statements_changeIndentation() async {
await indexTestUnit('''
-main() {
+void f() {
{
// start
if (true) {
@@ -1991,7 +1991,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
{
// start
res();
@@ -2009,7 +2009,7 @@
Future<void> test_statements_changeIndentation_multilineString() async {
await indexTestUnit('''
-main() {
+void f() {
{
// start
print("""
@@ -2023,7 +2023,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
{
// start
res();
@@ -2042,7 +2042,7 @@
Future<void> test_statements_definesVariable_notUsedOutside() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1;
int b = 1;
// start
@@ -2054,7 +2054,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int a = 1;
int b = 1;
// start
@@ -2153,7 +2153,7 @@
Future<void> test_statements_definesVariable_twoUsedOutside() async {
await indexTestUnit('''
-main() {
+void f() {
// start
int varA = 1;
int varB = 2;
@@ -2235,7 +2235,7 @@
Future<void> test_statements_dynamic() async {
await indexTestUnit('''
dynaFunction(p) => 0;
-main() {
+void f() {
// start
var a = 1;
var v = dynaFunction(a);
@@ -2247,7 +2247,7 @@
// apply refactoring
return _assertSuccessfulRefactoring('''
dynaFunction(p) => 0;
-main() {
+void f() {
// start
var v = res();
// end
@@ -2265,7 +2265,7 @@
/// We should always add ";" when invoke method with extracted statements.
Future<void> test_statements_endsWithBlock() async {
await indexTestUnit('''
-main() {
+void f() {
// start
if (true) {
print(0);
@@ -2276,7 +2276,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
// start
res();
// end
@@ -2309,7 +2309,7 @@
await indexTestUnit('''
import 'dart:async';
Future getValue() async => 42;
-main() async {
+void f() async {
// start
var v = await getValue();
// end
@@ -2321,7 +2321,7 @@
return _assertSuccessfulRefactoring('''
import 'dart:async';
Future getValue() async => 42;
-main() async {
+void f() async {
// start
var v = await res();
// end
@@ -2339,7 +2339,7 @@
await indexTestUnit('''
import 'dart:async';
Future<int> getValue() async => 42;
-main() async {
+void f() async {
// start
int v = await getValue();
v += 2;
@@ -2352,7 +2352,7 @@
return _assertSuccessfulRefactoring('''
import 'dart:async';
Future<int> getValue() async => 42;
-main() async {
+void f() async {
// start
int v = await res();
// end
@@ -2371,7 +2371,7 @@
await indexTestUnit('''
import 'dart:async';
Stream<int> getValueStream() => throw 0;
-main() async {
+void f() async {
// start
int sum = 0;
await for (int v in getValueStream()) {
@@ -2386,7 +2386,7 @@
return _assertSuccessfulRefactoring('''
import 'dart:async';
Stream<int> getValueStream() => throw 0;
-main() async {
+void f() async {
// start
int sum = await res();
// end
@@ -2407,7 +2407,7 @@
await indexTestUnit('''
import 'dart:async';
Future<int> getValue() async => 42;
-main() async {
+void f() async {
// start
int v = await getValue();
print(v);
@@ -2419,7 +2419,7 @@
return _assertSuccessfulRefactoring('''
import 'dart:async';
Future<int> getValue() async => 42;
-main() async {
+void f() async {
// start
await res();
// end
@@ -2500,7 +2500,7 @@
Future<void> test_statements_noDuplicates() async {
await indexTestUnit('''
-main() {
+void f() {
int a = 1;
int b = 1;
// start
@@ -2511,7 +2511,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
int a = 1;
int b = 1;
// start
@@ -2527,7 +2527,7 @@
Future<void> test_statements_parameters_ignoreInnerPropagatedType() async {
await indexTestUnit('''
-main(Object x) {
+void f(Object x) {
// start
if (x is int) {
print('int');
@@ -2541,7 +2541,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main(Object x) {
+void f(Object x) {
// start
res(x);
// end
@@ -2562,7 +2562,7 @@
_addLibraryReturningAsync();
await indexTestUnit('''
import 'asyncLib.dart';
-main() {
+void f() {
var v = newCompleter();
// start
print(v);
@@ -2574,7 +2574,7 @@
return _assertSuccessfulRefactoring('''
import 'asyncLib.dart';
import 'dart:async';
-main() {
+void f() {
var v = newCompleter();
// start
res(v);
@@ -2641,7 +2641,7 @@
Future<void> test_statements_return_last() async {
await indexTestUnit('''
-main() {
+int f() {
// start
int v = 5;
return v + 1;
@@ -2651,7 +2651,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+int f() {
// start
return res();
// end
@@ -2726,7 +2726,7 @@
Future<void> test_statements_return_multiple_ignoreInFunction() async {
await indexTestUnit('''
-int main() {
+int f() {
// start
localFunction() {
return 'abc';
@@ -2738,7 +2738,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-int main() {
+int f() {
// start
return res();
// end
@@ -2820,7 +2820,7 @@
Future<void> test_statements_return_single() async {
await indexTestUnit('''
-main() {
+int f() {
// start
return 42;
// end
@@ -2829,7 +2829,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+int f() {
// start
return res();
// end
@@ -2845,7 +2845,7 @@
/// This should not cause problems.
Future<void> test_statements_twoOfThree() async {
await indexTestUnit('''
-main() {
+void f() {
// start
print(0);
print(0);
@@ -2856,7 +2856,7 @@
_createRefactoringForStartEndComments();
// apply refactoring
return _assertSuccessfulRefactoring('''
-main() {
+void f() {
// start
res();
// end
diff --git a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
index 74a2fee..872fe9d 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_class_member_test.dart
@@ -113,7 +113,7 @@
test() {}
}
class C extends A {
- main() {
+ void f() {
print(newName);
}
}
@@ -202,7 +202,7 @@
await indexTestUnit('''
class A {
test() {}
- main() {
+ void f() {
newName() {}
test(); // marker
}
@@ -223,7 +223,7 @@
await indexTestUnit('''
class A {
test() {}
- main() {
+ void f() {
var newName;
test(); // marker
}
@@ -246,7 +246,7 @@
test() {}
}
class B extends A {
- main() {
+ void f() {
var newName;
test(); // marker
}
@@ -267,7 +267,7 @@
await indexTestUnit('''
class A {
test() {}
- main() {
+ void f() {
var newName;
this.test(); // marker
}
@@ -285,7 +285,7 @@
await indexTestUnit('''
class A {
test() {}
- main() {
+ void f() {
var newName;
}
}
@@ -302,7 +302,7 @@
await indexTestUnit('''
class A {
test() {}
- main(newName) {
+ void f(newName) {
test(); // marker
}
}
@@ -324,7 +324,7 @@
}
class B extends A {
newName() {} // marker
- main() {
+ void f() {
test();
}
}
@@ -348,7 +348,7 @@
test() {}
}
class C extends B {
- main() {
+ void f() {
print(newName);
}
}
@@ -406,7 +406,7 @@
Future<void> test_checkInitialConditions_inSDK() async {
await indexTestUnit('''
-main() {
+void f() {
'abc'.toUpperCase();
}
''');
@@ -471,7 +471,7 @@
await indexTestUnit('''
class A {
int test = 0; // marker
- main() {
+ void f() {
print(test);
test = 1;
test += 2;
@@ -483,7 +483,7 @@
get test => 1;
set test(x) {}
}
-main() {
+void f() {
A a = new A();
B b = new B();
C c = new C();
@@ -506,7 +506,7 @@
return assertSuccessfulRefactoring('''
class A {
int newName = 0; // marker
- main() {
+ void f() {
print(newName);
newName = 1;
newName += 2;
@@ -518,7 +518,7 @@
get newName => 1;
set newName(x) {}
}
-main() {
+void f() {
A a = new A();
B b = new B();
C c = new C();
@@ -583,7 +583,7 @@
final test;
A({this.test});
}
-main() {
+void f() {
new A(test: 42);
}
''');
@@ -598,7 +598,7 @@
final newName;
A({this.newName});
}
-main() {
+void f() {
new A(newName: 42);
}
''');
@@ -610,7 +610,7 @@
class A {
final F test;
A(this.test);
- main() {
+ void f() {
test(1);
}
}
@@ -629,7 +629,7 @@
class A {
final F newName;
A(this.newName);
- main() {
+ void f() {
newName(1);
}
}
@@ -656,7 +656,7 @@
class E {
test() {}
}
-main() {
+void f() {
A a = new A();
B b = new B();
C c = new C();
@@ -692,7 +692,7 @@
class E {
test() {}
}
-main() {
+void f() {
A a = new A();
B b = new B();
C c = new C();
@@ -712,7 +712,7 @@
class A {
test() {}
}
-main(var a) {
+void f(var a) {
a.test(); // 1
new A().test();
a.test(); // 2
@@ -728,7 +728,7 @@
class A {
newName() {}
}
-main(var a) {
+void f(var a) {
a.newName(); // 1
new A().newName();
a.newName(); // 2
@@ -757,7 +757,7 @@
test() {}
}
-main(var a) {
+void f(var a) {
a.test();
}
''');
@@ -774,7 +774,7 @@
newName() {}
}
-main(var a) {
+void f(var a) {
a.newName();
}
''');
@@ -786,7 +786,7 @@
test_createChange_MethodElement_potential_private_otherLibrary() async {
await indexUnit('/lib.dart', '''
library lib;
-main(p) {
+void f(p) {
p._test();
}
''');
@@ -794,7 +794,7 @@
class A {
_test() {}
}
-main(var a) {
+void f(var a) {
a._test();
new A()._test();
}
@@ -809,7 +809,7 @@
class A {
newName() {}
}
-main(var a) {
+void f(var a) {
a.newName();
new A().newName();
}
@@ -916,7 +916,7 @@
class A {
get test {} // marker
set test(x) {}
- main() {
+ void f() {
print(test);
test = 1;
}
@@ -925,7 +925,7 @@
get test {}
set test(x) {}
}
-main() {
+void f() {
A a = new A();
print(a.test);
a.test = 2;
@@ -945,7 +945,7 @@
class A {
get newName {} // marker
set newName(x) {}
- main() {
+ void f() {
print(newName);
newName = 1;
}
@@ -954,7 +954,7 @@
get newName {}
set newName(x) {}
}
-main() {
+void f() {
A a = new A();
print(a.newName);
a.newName = 2;
@@ -971,7 +971,7 @@
class A {
get test {}
set test(x) {} // marker
- main() {
+ void f() {
print(test);
test = 1;
}
@@ -980,7 +980,7 @@
get test {}
set test(x) {}
}
-main() {
+void f() {
A a = new A();
print(a.test);
a.test = 2;
@@ -1000,7 +1000,7 @@
class A {
get newName {}
set newName(x) {} // marker
- main() {
+ void f() {
print(newName);
newName = 1;
}
@@ -1009,7 +1009,7 @@
get newName {}
set newName(x) {}
}
-main() {
+void f() {
A a = new A();
print(a.newName);
a.newName = 2;
diff --git a/pkg/analysis_server/test/services/refactoring/rename_extension_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_extension_member_test.dart
index 32dfb0f..a9bf0a6 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_extension_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_extension_member_test.dart
@@ -51,7 +51,7 @@
await indexTestUnit('''
extension E on int {
test() {}
- main() {
+ void f() {
newName() {}
test(); // marker
}
@@ -75,7 +75,7 @@
await indexTestUnit('''
extension E on int {
test() {}
- main() {
+ void f() {
var newName;
test(); // marker
}
@@ -99,7 +99,7 @@
await indexTestUnit('''
extension E on int {
test() {}
- main(newName) {
+ void f(newName) {
test(); // marker
}
}
@@ -187,7 +187,7 @@
test() {} // marker
}
-main() {
+void f() {
var a = A();
a.test();
E(a).test();
@@ -207,7 +207,7 @@
newName() {} // marker
}
-main() {
+void f() {
var a = A();
a.newName();
E(a).newName();
@@ -220,12 +220,12 @@
extension E on int {
get test {} // marker
set test(x) {}
- main() {
+ void f() {
test;
test = 1;
}
}
-main() {
+void f() {
0.test;
0.test = 2;
@@ -243,12 +243,12 @@
extension E on int {
get newName {} // marker
set newName(x) {}
- main() {
+ void f() {
newName;
newName = 1;
}
}
-main() {
+void f() {
0.newName;
0.newName = 2;
@@ -263,12 +263,12 @@
extension E on int {
get test {}
set test(x) {} // marker
- main() {
+ void f() {
test;
test = 1;
}
}
-main() {
+void f() {
0.test;
0.test = 2;
@@ -286,12 +286,12 @@
extension E on int {
get newName {}
set newName(x) {} // marker
- main() {
+ void f() {
newName;
newName = 1;
}
}
-main() {
+void f() {
0.newName;
0.newName = 2;
@@ -331,7 +331,7 @@
void test() {} // marker
}
-main() {
+void f() {
0.test();
}
''');
@@ -347,7 +347,7 @@
void newName() {} // marker
}
-main() {
+void f() {
0.newName();
}
''');
diff --git a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
index c0ea209..5c43032 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_local_test.dart
@@ -18,7 +18,7 @@
class RenameLocalTest extends RenameRefactoringTest {
Future<void> test_checkFinalConditions_hasLocalFunction_after() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 0;
newName() => 1;
}
@@ -34,7 +34,7 @@
Future<void> test_checkFinalConditions_hasLocalFunction_before() async {
await indexTestUnit('''
-main() {
+void f() {
newName() => 1;
int test = 0;
}
@@ -49,7 +49,7 @@
Future<void> test_checkFinalConditions_hasLocalVariable_after() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 0;
var newName = 1;
print(newName);
@@ -67,7 +67,7 @@
Future<void> test_checkFinalConditions_hasLocalVariable_before() async {
await indexTestUnit('''
-main() {
+void f() {
var newName = 1;
int test = 0;
}
@@ -83,7 +83,7 @@
Future<void> test_checkFinalConditions_hasLocalVariable_otherBlock() async {
await indexTestUnit('''
-main() {
+void f() {
{
var newName = 1;
}
@@ -101,7 +101,7 @@
Future<void>
test_checkFinalConditions_hasLocalVariable_otherForEachLoop() async {
await indexTestUnit('''
-main() {
+void f() {
for (int newName in []) {}
for (int test in []) {}
}
@@ -114,7 +114,7 @@
Future<void> test_checkFinalConditions_hasLocalVariable_otherForLoop() async {
await indexTestUnit('''
-main() {
+void f() {
for (int newName = 0; newName < 10; newName++) {}
for (int test = 0; test < 10; test++) {}
}
@@ -128,10 +128,10 @@
Future<void>
test_checkFinalConditions_hasLocalVariable_otherFunction() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 0;
}
-main2() {
+void g() {
var newName = 1;
}
''');
@@ -145,7 +145,7 @@
await indexTestUnit('''
class A {
var newName = 1;
- main() {
+ void f() {
var test = 0;
print(newName);
}
@@ -190,7 +190,7 @@
await indexTestUnit('''
class A {
var newName = 1;
- main() {
+ void f() {
var test = 0;
print(this.newName);
}
@@ -206,7 +206,7 @@
test_checkFinalConditions_shadows_OK_namedParameterReference() async {
await indexTestUnit('''
void f({newName}) {}
-main() {
+void g() {
var test = 0;
f(newName: test);
}
@@ -220,7 +220,7 @@
Future<void> test_checkFinalConditions_shadows_topLevelFunction() async {
await indexTestUnit('''
newName() {}
-main() {
+void f() {
var test = 0;
newName(); // ref
}
@@ -235,7 +235,7 @@
Future<void> test_checkNewName_FunctionElement() async {
await indexTestUnit('''
-main() {
+void f() {
int test() => 0;
}
''');
@@ -252,7 +252,7 @@
Future<void> test_checkNewName_LocalVariableElement() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 0;
}
''');
@@ -269,7 +269,7 @@
Future<void> test_checkNewName_ParameterElement() async {
await indexTestUnit('''
-main(test) {
+void f(test) {
}
''');
createRenameRefactoringAtString('test) {');
@@ -285,7 +285,7 @@
Future<void> test_createChange_localFunction() async {
await indexTestUnit('''
-main() {
+void f() {
int test() => 0;
print(test);
print(test());
@@ -298,7 +298,7 @@
refactoring.newName = 'newName';
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
int newName() => 0;
print(newName);
print(newName());
@@ -309,7 +309,7 @@
Future<void>
test_createChange_localFunction_sameNameDifferenceScopes() async {
await indexTestUnit('''
-main() {
+void f() {
{
int test() => 0;
print(test);
@@ -330,7 +330,7 @@
refactoring.newName = 'newName';
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
{
int test() => 0;
print(test);
@@ -349,7 +349,7 @@
Future<void> test_createChange_localVariable() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 0;
test = 1;
test += 2;
@@ -363,7 +363,7 @@
refactoring.newName = 'newName';
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
int newName = 0;
newName = 1;
newName += 2;
@@ -375,7 +375,7 @@
Future<void>
test_createChange_localVariable_sameNameDifferenceScopes() async {
await indexTestUnit('''
-main() {
+void f() {
{
int test = 0;
print(test);
@@ -396,7 +396,7 @@
refactoring.newName = 'newName';
// validate change
return assertSuccessfulRefactoring('''
-main() {
+void f() {
{
int test = 0;
print(test);
@@ -420,7 +420,7 @@
test += 2;
print(test);
}
-main() {
+void f() {
myFunction(test: 2);
}
''');
@@ -436,7 +436,7 @@
newName += 2;
print(newName);
}
-main() {
+void f() {
myFunction(newName: 2);
}
''');
@@ -454,7 +454,7 @@
newFile(b, content: r'''
import 'a.dart';
-main() {
+void f() {
new A(test: 2);
}
''');
@@ -475,7 +475,7 @@
assertFileChangeResult(b, '''
import 'a.dart';
-main() {
+void f() {
new A(newName: 2);
}
''');
@@ -488,7 +488,7 @@
A({required T test});
}
-main() {
+void f() {
A(test: 0);
}
''');
@@ -503,7 +503,7 @@
A({required T newName});
}
-main() {
+void f() {
A(newName: 0);
}
''');
@@ -552,7 +552,7 @@
''');
await indexTestUnit('''
import 'test2.dart';
-main() {
+void f() {
new A().foo(test: 10);
new B().foo(test: 20);
new C().foo(test: 30);
@@ -570,7 +570,7 @@
// validate change
await assertSuccessfulRefactoring('''
import 'test2.dart';
-main() {
+void f() {
new A().foo(newName: 10);
new B().foo(newName: 20);
new C().foo(newName: 30);
@@ -603,7 +603,7 @@
test += 2;
print(test);
}
-main() {
+void f() {
myFunction(2);
}
''');
@@ -619,7 +619,7 @@
newName += 2;
print(newName);
}
-main() {
+void f() {
myFunction(2);
}
''');
@@ -627,7 +627,7 @@
Future<void> test_oldName() async {
await indexTestUnit('''
-main() {
+void f() {
int test = 0;
}
''');
diff --git a/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart b/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart
index 1fd730e..a65f922 100644
--- a/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/rename_unit_member_test.dart
@@ -54,7 +54,7 @@
NewName() {}
}
class B extends A {
- main() {
+ void f() {
super.NewName(); // super-ref
}
}
@@ -75,7 +75,7 @@
library my.lib;
import 'test.dart';
-main() {
+void f() {
new Test();
}
''');
@@ -93,7 +93,7 @@
class Test {}
class A {
void NewName() {}
- main() {
+ void f() {
new Test();
}
}
@@ -119,7 +119,7 @@
NewName() {}
}
class B extends A {
- main() {
+ void f() {
NewName(); // super-ref
}",
}
@@ -144,7 +144,7 @@
NewName() {}
}
class B extends A {
- main() {
+ void f() {
NewName(); // super-ref
}",
}
@@ -164,7 +164,7 @@
NewName() {}
}
class B extends A {
- main() {
+ void f() {
NewName(); // super-ref
}
}
@@ -186,7 +186,7 @@
NewName() {}
}
class B extends A {
- main() {
+ void f() {
NewName(); // super-ref
}",
}
@@ -208,7 +208,7 @@
NewName() {}
}
class B {
- main(A a) {
+ void f(A a) {
a.NewName();
}
}
@@ -222,7 +222,7 @@
Future<void> test_checkInitialConditions_inSDK() async {
await indexTestUnit('''
-main() {
+void f() {
String s;
}
''');
@@ -247,7 +247,7 @@
await indexTestUnit('''
import "package:aaa/a.dart";
-main() {
+void f() {
A a;
}
''');
@@ -366,7 +366,7 @@
factory Other.a() = Test;
factory Other.b() = Test.named;
}
-main() {
+void f() {
Test t1 = new Test();
Test t2 = new Test.named();
}
@@ -387,7 +387,7 @@
factory Other.a() = NewName;
factory Other.b() = NewName.named;
}
-main() {
+void f() {
NewName t1 = new NewName();
NewName t2 = new NewName.named();
}
@@ -524,7 +524,7 @@
await indexTestUnit('''
class Test {
}
-main() {
+void f() {
Test(); // invalid code, but still a reference
}
''');
@@ -538,7 +538,7 @@
return assertSuccessfulRefactoring('''
class NewName {
}
-main() {
+void f() {
NewName(); // invalid code, but still a reference
}
''');
@@ -585,7 +585,7 @@
await indexTestUnit('''
test() {}
foo() {}
-main() {
+void f() {
print(test);
print(test());
foo();
@@ -601,7 +601,7 @@
return assertSuccessfulRefactoring('''
newName() {}
foo() {}
-main() {
+void f() {
print(newName);
print(newName());
foo();
@@ -616,7 +616,7 @@
''');
await indexTestUnit('''
import 'foo.dart';
-main() {
+void f() {
print(test);
print(test());
foo();
@@ -631,7 +631,7 @@
// validate change
await assertSuccessfulRefactoring('''
import 'foo.dart';
-main() {
+void f() {
print(newName);
print(newName());
foo();
@@ -775,7 +775,7 @@
await indexTestUnit('''
get test {}
set test(x) {}
-main() {
+void f() {
print(test);
test = 1;
test += 2;
@@ -790,7 +790,7 @@
return assertSuccessfulRefactoring('''
get newName {}
set newName(x) {}
-main() {
+void f() {
print(newName);
newName = 1;
newName += 2;
@@ -801,7 +801,7 @@
Future<void> _test_createChange_TopLevelVariableElement(String search) async {
await indexTestUnit('''
int test = 0;
-main() {
+void f() {
print(test);
test = 1;
test += 2;
@@ -816,7 +816,7 @@
// validate change
return assertSuccessfulRefactoring('''
int newName = 0;
-main() {
+void f() {
print(newName);
newName = 1;
newName += 2;
diff --git a/pkg/analysis_server/test/src/cider/completion_test.dart b/pkg/analysis_server/test/src/cider/completion_test.dart
index d96e72b..b83e4ef 100644
--- a/pkg/analysis_server/test/src/cider/completion_test.dart
+++ b/pkg/analysis_server/test/src/cider/completion_test.dart
@@ -35,7 +35,7 @@
int a = 0;
-main(int b) {
+void f(int b) {
int c = 0;
^
}
@@ -52,7 +52,7 @@
Future<void> test_compute_performance_operations() async {
await _compute(r'''
-main() {
+void f() {
^
}
''');
@@ -93,7 +93,7 @@
String foobar;
}
-main(A a) {
+void f(A a) {
a.foo^
}
''');
@@ -234,7 +234,7 @@
Future<void> test_filterSort_byPattern_location_statement() async {
await _compute(r'''
-main() {
+void f() {
F^
0;
}
@@ -302,7 +302,7 @@
Future<void> test_filterSort_preferLocal() async {
await _compute(r'''
var a = 0;
-main() {
+void f() {
var b = 0;
var v = ^;
}
@@ -316,7 +316,7 @@
Future<void> test_filterSort_sortByName() async {
await _compute(r'''
-main() {
+void f() {
var a = 0;
var b = 0;
var v = ^;
diff --git a/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart b/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
index eff0c79..37057d0 100644
--- a/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/closing_labels_computer_test.dart
@@ -45,7 +45,7 @@
/// don't end up with lots of unwanted labels on each line here.
Future<void> test_chainedConstructorOverManyLines() async {
var content = '''
-main() {
+void f() {
return new thing
.whatIsSplit
.acrossManyLines(1, 2);
@@ -185,7 +185,7 @@
/// it isn't obvious which closing bracket goes with the label.
Future<void> test_mixedLineSpanning() async {
var content = '''
-main() {
+void f() {
/*1*/new Foo((m) {
/*2*/new Bar(
labels,
@@ -270,7 +270,7 @@
Future<void> test_NoLabelsFromInterpolatedStrings() async {
var content = """
-void main(HighlightRegionType type, int offset, int length) {
+void f(HighlightRegionType type, int offset, int length) {
/*1*/new Wrapper(
/*2*/new Fail(
'Not expected to find (offset=\$offset; length=\$length; type=\$type) in\\n'
diff --git a/pkg/analysis_server/test/src/computer/outline_computer_test.dart b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
index 6829836..6db141d 100644
--- a/pkg/analysis_server/test/src/computer/outline_computer_test.dart
+++ b/pkg/analysis_server/test/src/computer/outline_computer_test.dart
@@ -543,7 +543,7 @@
var outline = await _computeOutline('''
void group(name, closure) {}
void test(name) {}
-void main() {
+void f() {
group('group1', () {
group('group1_1', () {
test('test1_1_1');
@@ -562,18 +562,18 @@
// unit
var unit_children = outline.children!;
expect(unit_children, hasLength(3));
- // main
- var main_outline = unit_children[2];
- _expect(main_outline,
+ // f
+ var f_outline = unit_children[2];
+ _expect(f_outline,
kind: ElementKind.FUNCTION,
- name: 'main',
- offset: testCode.indexOf('main() {'),
+ name: 'f',
+ offset: testCode.indexOf('f() {'),
parameters: '()',
returnType: 'void');
- var main_children = main_outline.children!;
- expect(main_children, hasLength(2));
+ var f_children = f_outline.children!;
+ expect(f_children, hasLength(2));
// group1
- var group1_outline = main_children[0];
+ var group1_outline = f_children[0];
_expect(group1_outline,
kind: ElementKind.UNIT_TEST_GROUP,
length: 5,
@@ -624,7 +624,7 @@
name: 'test("test1_2_1")',
offset: testCode.indexOf("test('test1_2_1'"));
// group2
- var group2_outline = main_children[1];
+ var group2_outline = f_children[1];
_expect(group2_outline,
kind: ElementKind.UNIT_TEST_GROUP,
length: 5,
@@ -671,7 +671,7 @@
/// https://github.com/dart-lang/sdk/issues/33228
Future<void> test_invocation_ofParameter() async {
var outline = await _computeOutline('''
-main(p()) {
+void f(p()) {
p();
}
''');
@@ -689,7 +689,7 @@
@isTest
void myTest(name) {}
-void main() {
+void f() {
myGroup('group1', () {
myGroup('group1_1', () {
myTest('test1_1_1');
@@ -708,18 +708,18 @@
// unit
var unit_children = outline.children!;
expect(unit_children, hasLength(3));
- // main
- var main_outline = unit_children[2];
- _expect(main_outline,
+ // f
+ var f_outline = unit_children[2];
+ _expect(f_outline,
kind: ElementKind.FUNCTION,
- name: 'main',
- offset: testCode.indexOf('main() {'),
+ name: 'f',
+ offset: testCode.indexOf('f() {'),
parameters: '()',
returnType: 'void');
- var main_children = main_outline.children!;
- expect(main_children, hasLength(2));
+ var f_children = f_outline.children!;
+ expect(f_children, hasLength(2));
// group1
- var group1_outline = main_children[0];
+ var group1_outline = f_children[0];
_expect(group1_outline,
kind: ElementKind.UNIT_TEST_GROUP,
length: 7,
@@ -770,7 +770,7 @@
name: 'myTest("test1_2_1")',
offset: testCode.indexOf("myTest('test1_2_1'"));
// group2
- var group2_outline = main_children[1];
+ var group2_outline = f_children[1];
_expect(group2_outline,
kind: ElementKind.UNIT_TEST_GROUP,
length: 7,
diff --git a/pkg/analysis_server/test/src/domains/execution/completion_test.dart b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
index 8553bad..81d2594 100644
--- a/pkg/analysis_server/test/src/domains/execution/completion_test.dart
+++ b/pkg/analysis_server/test/src/domains/execution/completion_test.dart
@@ -136,7 +136,7 @@
String c;
-void main() {
+void f() {
// context line
}
''');
@@ -170,7 +170,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_locals_block_codeWithClosure() async {
addContextFile(r'''
-main() {
+void f() {
var items = <String>[];
// context line
}
@@ -182,7 +182,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_locals_block_nested() async {
addContextFile(r'''
-void main() {
+void f() {
var a = 0;
var b = 0.0;
{
@@ -203,7 +203,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_locals_for() async {
addContextFile(r'''
-void main(List<int> intItems, List<double> doubleItems) {
+void f(List<int> intItems, List<double> doubleItems) {
for (var a = 0, b = 0.0; a < 5; a++) {
// context line
}
@@ -217,7 +217,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_locals_forEach() async {
addContextFile(r'''
-void main(List<int> intItems, List<double> doubleItems) {
+void f(List<int> intItems, List<double> doubleItems) {
for (var a in intItems) {
for (var b in doubleItems) {
// context line
@@ -247,7 +247,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_parameters_function() async {
addContextFile(r'''
-void main(int a, double b) {
+void f(int a, double b) {
// context line
}
''');
@@ -259,7 +259,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_parameters_function_locals() async {
addContextFile(r'''
-void main(int a, int b) {
+void f(int a, int b) {
String a;
double c;
// context line
@@ -289,7 +289,7 @@
@FailingTest(reason: 'No support for OverlayResourceProvider')
Future<void> test_parameters_functionExpression() async {
addContextFile(r'''
-void main(List<int> intItems, List<double> doubleItems) {
+void f(List<int> intItems, List<double> doubleItems) {
intItems.forEach((a) {
doubleItems.forEach((b) {
// context line
@@ -306,7 +306,7 @@
Future<void> test_parameters_method() async {
addContextFile(r'''
class C {
- void main(int a, double b) {
+ void f(int a, double b) {
// context line
}
}
@@ -320,7 +320,7 @@
Future<void> test_parameters_method_locals() async {
addContextFile(r'''
class C {
- void main(int a, int b) {
+ void f(int a, int b) {
String a;
double c;
// context line
@@ -340,7 +340,7 @@
addContextFile(r'''
import 'a.dart';
impoty 'b.dart';
-main() {
+void f() {
var a = new A();
var b = new B();
// context line
@@ -357,7 +357,7 @@
addContextFile(r'''
int a() => null;
double b() => null;
-void main() {
+void f() {
// context line
}
''');
@@ -372,7 +372,7 @@
int a;
double b;
-void main() {
+void f() {
// context line
}
''');
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 d6aca70..9f5043b 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
@@ -21,7 +21,7 @@
Future<void> test_bodyNotBlock() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) print(item);
}
''');
@@ -30,7 +30,7 @@
Future<void> test_doesNotDeclareVariable() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
String item;
for (item in items) {
print(item);
@@ -42,7 +42,7 @@
Future<void> test_iterableIsNotVariable() async {
await resolveTestCode('''
-main() {
+void f() {
for (String item in ['a', 'b', 'c']) {
print(item);
}
@@ -53,7 +53,7 @@
Future<void> test_iterableNotList() async {
await resolveTestCode('''
-main(Iterable<String> items) {
+void f(Iterable<String> items) {
for (String item in items) {
print(item);
}
@@ -64,14 +64,14 @@
Future<void> test_onDeclaredIdentifier_name() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) {
print(item);
}
}
''');
await assertHasAssistAt('item in', '''
-main(List<String> items) {
+void f(List<String> items) {
for (int i = 0; i < items.length; i++) {
String item = items[i];
print(item);
@@ -82,14 +82,14 @@
Future<void> test_onDeclaredIdentifier_type() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) {
print(item);
}
}
''');
await assertHasAssistAt('tring item', '''
-main(List<String> items) {
+void f(List<String> items) {
for (int i = 0; i < items.length; i++) {
String item = items[i];
print(item);
@@ -100,14 +100,14 @@
Future<void> test_onFor() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) {
print(item);
}
}
''');
await assertHasAssistAt('for (String', '''
-main(List<String> items) {
+void f(List<String> items) {
for (int i = 0; i < items.length; i++) {
String item = items[i];
print(item);
@@ -118,14 +118,14 @@
Future<void> test_usesI() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) {
int i = 0;
}
}
''');
await assertHasAssistAt('for (String', '''
-main(List<String> items) {
+void f(List<String> items) {
for (int j = 0; j < items.length; j++) {
String item = items[j];
int i = 0;
@@ -136,7 +136,7 @@
Future<void> test_usesIJ() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) {
print(item);
int i = 0, j = 1;
@@ -144,7 +144,7 @@
}
''');
await assertHasAssistAt('for (String', '''
-main(List<String> items) {
+void f(List<String> items) {
for (int k = 0; k < items.length; k++) {
String item = items[k];
print(item);
@@ -156,7 +156,7 @@
Future<void> test_usesIJK() async {
await resolveTestCode('''
-main(List<String> items) {
+void f(List<String> items) {
for (String item in items) {
print(item);
int i, j, k;
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 5a68942..9c3260d 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
@@ -21,12 +21,12 @@
Future<void> test_childOfIs_left() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is String);
}
''');
await assertHasAssistAt('p is', '''
-main(p) {
+void f(p) {
p is! String;
}
''');
@@ -34,12 +34,12 @@
Future<void> test_childOfIs_right() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is String);
}
''');
await assertHasAssistAt('String)', '''
-main(p) {
+void f(p) {
p is! String;
}
''');
@@ -47,12 +47,12 @@
Future<void> test_is() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is String);
}
''');
await assertHasAssistAt('is String', '''
-main(p) {
+void f(p) {
p is! String;
}
''');
@@ -60,7 +60,7 @@
Future<void> test_is_alreadyIsNot() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p is! String;
}
''');
@@ -69,12 +69,12 @@
Future<void> test_is_higherPrecedencePrefix() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!!(p is String);
}
''');
await assertHasAssistAt('is String', '''
-main(p) {
+void f(p) {
!(p is! String);
}
''');
@@ -82,7 +82,7 @@
Future<void> test_is_noEnclosingParenthesis() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p is String;
}
''');
@@ -91,7 +91,7 @@
Future<void> test_is_noPrefix() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
(p is String);
}
''');
@@ -100,12 +100,12 @@
Future<void> test_is_not_higherPrecedencePrefix() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!!(p is String);
}
''');
await assertHasAssistAt('!(p', '''
-main(p) {
+void f(p) {
!(p is! String);
}
''');
@@ -113,7 +113,7 @@
Future<void> test_is_notIsExpression() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
123 + 456;
}
''');
@@ -123,7 +123,7 @@
Future<void> test_is_notTheNotOperator() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-main(p) {
+void f(p) {
++(p is String);
}
''');
@@ -132,12 +132,12 @@
Future<void> test_not() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is String);
}
''');
await assertHasAssistAt('!(p', '''
-main(p) {
+void f(p) {
p is! String;
}
''');
@@ -145,7 +145,7 @@
Future<void> test_not_alreadyIsNot() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is! String);
}
''');
@@ -154,7 +154,7 @@
Future<void> test_not_noEnclosingParenthesis() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!p;
}
''');
@@ -163,7 +163,7 @@
Future<void> test_not_notIsExpression() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p == null);
}
''');
@@ -173,7 +173,7 @@
Future<void> test_not_notTheNotOperator() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-main(p) {
+void f(p) {
++(p is String);
}
''');
@@ -182,12 +182,12 @@
Future<void> test_parentheses() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is String);
}
''');
await assertHasAssistAt('(p is', '''
-main(p) {
+void f(p) {
p is! String;
}
''');
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 fc3f755..f55670e 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
@@ -175,7 +175,7 @@
class A {
int; // marker
}
-main(A a) {
+void f(A a) {
print(a.test);
}
''');
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 a3075a8..d1ca238 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
@@ -40,12 +40,12 @@
Future<void> test_extended_mixOperator_1() async {
await resolveTestCode('''
-main() {
+void f() {
1 * 2 * 3 + 4;
}
''');
await assertHasAssistAt('* 2', '''
-main() {
+void f() {
2 * 3 * 1 + 4;
}
''');
@@ -53,12 +53,12 @@
Future<void> test_extended_mixOperator_2() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2 - 3 + 4;
}
''');
await assertHasAssistAt('+ 2', '''
-main() {
+void f() {
2 + 1 - 3 + 4;
}
''');
@@ -66,12 +66,12 @@
Future<void> test_extended_sameOperator_afterFirst() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2 + 3;
}
''');
await assertHasAssistAt('+ 2', '''
-main() {
+void f() {
2 + 3 + 1;
}
''');
@@ -79,12 +79,12 @@
Future<void> test_extended_sameOperator_afterSecond() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2 + 3;
}
''');
await assertHasAssistAt('+ 3', '''
-main() {
+void f() {
3 + 1 + 2;
}
''');
@@ -92,7 +92,7 @@
Future<void> test_extraLength() async {
await resolveTestCode('''
-main() {
+void f() {
111 + 222;
}
''');
@@ -101,7 +101,7 @@
Future<void> test_onOperand() async {
await resolveTestCode('''
-main() {
+void f() {
111 + 222;
}
''');
@@ -110,7 +110,7 @@
Future<void> test_selectionWithBinary() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2 + 3;
}
''');
@@ -119,12 +119,12 @@
Future<void> test_simple_afterOperator() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2;
}
''');
await assertHasAssistAt(' 2', '''
-main() {
+void f() {
2 + 1;
}
''');
@@ -132,12 +132,12 @@
Future<void> test_simple_beforeOperator() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2;
}
''');
await assertHasAssistAt('+ 2', '''
-main() {
+void f() {
2 + 1;
}
''');
@@ -145,14 +145,14 @@
Future<void> test_simple_fullSelection() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2;
}
''');
await assertHasAssistAt(
'1 + 2',
'''
-main() {
+void f() {
2 + 1;
}
''',
@@ -161,14 +161,14 @@
Future<void> test_simple_withLength() async {
await resolveTestCode('''
-main() {
+void f() {
1 + 2;
}
''');
await assertHasAssistAt(
'+ 2',
'''
-main() {
+void f() {
2 + 1;
}
''',
diff --git a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart
index 914d806..893bd93 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/flutter_wrap_generic_test.dart
@@ -95,7 +95,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
return Container(
child: /*caret*/DefaultTextStyle(
child: Row(
@@ -112,7 +112,7 @@
await assertHasAssist('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
return Container(
child: widget(
child: DefaultTextStyle(
@@ -134,7 +134,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
class FakeFlutter {\r
- main() {\r
+ Widget f() {\r
return Container(\r
child: /*caret*/DefaultTextStyle(\r
child: Row(\r
@@ -151,7 +151,7 @@
await assertHasAssist('''
import 'package:flutter/widgets.dart';
class FakeFlutter {\r
- main() {\r
+ Widget f() {\r
return Container(\r
child: widget(\r
child: DefaultTextStyle(\r
@@ -223,8 +223,8 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
- var obj;
+ Widget f() {
+ var obj;
return Row(children: [/*caret*/ Container()]);
}
}
@@ -236,7 +236,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
return /*caret*/Container();
}
}
@@ -244,7 +244,7 @@
await assertHasAssist('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
return widget(child: Container());
}
}
@@ -255,7 +255,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
return ClipRect./*caret*/rect();
}
}
@@ -263,7 +263,7 @@
await assertHasAssist('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
return widget(child: ClipRect.rect());
}
}
@@ -274,7 +274,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
var container = Container();
return /*caret*/container;
}
@@ -283,7 +283,7 @@
await assertHasAssist('''
import 'package:flutter/widgets.dart';
class FakeFlutter {
- main() {
+ Widget f() {
var container = Container();
return widget(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 e00ee78..58b527a 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
@@ -22,7 +22,7 @@
Future<void> test_hasShow() async {
await resolveTestCode('''
import 'dart:math' show pi;
-main() {
+void f() {
pi;
}
''');
@@ -32,14 +32,14 @@
Future<void> test_hasUnresolvedIdentifier() async {
await resolveTestCode('''
import 'dart:math';
-main(x) {
+void f(x) {
pi;
return x.foo();
}
''');
await assertHasAssistAt('import ', '''
import 'dart:math' show pi;
-main(x) {
+void f(x) {
pi;
return x.foo();
}
@@ -49,7 +49,7 @@
Future<void> test_onDirective() async {
await resolveTestCode('''
import 'dart:math';
-main() {
+void f() {
pi;
e;
max(1, 2);
@@ -57,7 +57,7 @@
''');
await assertHasAssistAt('import ', '''
import 'dart:math' show e, max, pi;
-main() {
+void f() {
pi;
e;
max(1, 2);
@@ -68,7 +68,7 @@
Future<void> test_onUri() async {
await resolveTestCode('''
import 'dart:math';
-main() {
+void f() {
pi;
e;
max(1, 2);
@@ -76,7 +76,7 @@
''');
await assertHasAssistAt('art:math', '''
import 'dart:math' show e, max, pi;
-main() {
+void f() {
pi;
e;
max(1, 2);
@@ -91,14 +91,14 @@
await resolveTestCode('''
import 'a.dart';
-main() {
+void f() {
setter = 42;
}
''');
await assertHasAssistAt('import ', '''
import 'a.dart' show setter;
-main() {
+void f() {
setter = 42;
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/assist/introduce_local_cast_type_test.dart b/pkg/analysis_server/test/src/services/correction/assist/introduce_local_cast_type_test.dart
index 784efb9..3981fc9 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/introduce_local_cast_type_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/introduce_local_cast_type_test.dart
@@ -23,7 +23,7 @@
Future<void> test_introduceLocalTestedType_if_is() async {
await resolveTestCode('''
class MyTypeName {}
-main(p) {
+void f(p) {
if (p is MyTypeName) {
}
p = null;
@@ -31,7 +31,7 @@
''');
var expected = '''
class MyTypeName {}
-main(p) {
+void f(p) {
if (p is MyTypeName) {
MyTypeName myTypeName = p;
}
@@ -51,7 +51,7 @@
Future<void> test_introduceLocalTestedType_if_isNot() async {
await resolveTestCode('''
class MyTypeName {}
-main(p) {
+void f(p) {
if (p is! MyTypeName) {
return;
}
@@ -59,7 +59,7 @@
''');
var expected = '''
class MyTypeName {}
-main(p) {
+void f(p) {
if (p is! MyTypeName) {
return;
}
@@ -78,7 +78,7 @@
Future<void> test_introduceLocalTestedType_notBlock() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
if (p is String)
print('not a block');
}
@@ -88,7 +88,7 @@
Future<void> test_introduceLocalTestedType_notIsExpression() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
if (p == null) {
}
}
@@ -107,14 +107,14 @@
Future<void> test_introduceLocalTestedType_while() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
while (p is String) {
}
p = null;
}
''');
var expected = '''
-main(p) {
+void f(p) {
while (p is String) {
String s = p;
}
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 8b885c8..54cce7b 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
@@ -21,13 +21,13 @@
Future<void> test_onAssignment() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
v = 1;
}
''');
await assertHasAssistAt('v =', '''
-main() {
+void f() {
var v = 1;
}
''');
@@ -35,7 +35,7 @@
Future<void> test_onAssignment_hasInitializer() async {
await resolveTestCode('''
-main() {
+void f() {
var v = 1;
v = 2;
}
@@ -45,7 +45,7 @@
Future<void> test_onAssignment_notAdjacent() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
var bar;
v = 1;
@@ -56,7 +56,7 @@
Future<void> test_onAssignment_notAssignment() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
v += 1;
}
@@ -66,7 +66,7 @@
Future<void> test_onAssignment_notDeclaration() async {
await resolveTestCode('''
-main(var v) {
+void f(var v) {
v = 1;
}
''');
@@ -75,7 +75,7 @@
Future<void> test_onAssignment_notLeftArgument() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
1 + v; // marker
}
@@ -85,7 +85,7 @@
Future<void> test_onAssignment_notOneVariable() async {
await resolveTestCode('''
-main() {
+void f() {
var v, v2;
v = 1;
}
@@ -96,7 +96,7 @@
Future<void> test_onAssignment_notResolved() async {
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-main() {
+void f() {
var v;
x = 1;
}
@@ -106,7 +106,7 @@
Future<void> test_onAssignment_notSameBlock() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
{
v = 1;
@@ -118,7 +118,7 @@
Future<void> test_onDeclaration_hasInitializer() async {
await resolveTestCode('''
-main() {
+void f() {
var v = 1;
v = 2;
}
@@ -128,7 +128,7 @@
Future<void> test_onDeclaration_lastStatement() async {
await resolveTestCode('''
-main() {
+void f() {
if (true)
var v;
}
@@ -138,7 +138,7 @@
Future<void> test_onDeclaration_nextNotAssignmentExpression() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
42;
}
@@ -148,7 +148,7 @@
Future<void> test_onDeclaration_nextNotExpressionStatement() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
if (true) return;
}
@@ -158,7 +158,7 @@
Future<void> test_onDeclaration_nextNotPureAssignment() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
v += 1;
}
@@ -168,7 +168,7 @@
Future<void> test_onDeclaration_notOneVariable() async {
await resolveTestCode('''
-main() {
+void f() {
var v, v2;
v = 1;
}
@@ -178,13 +178,13 @@
Future<void> test_onDeclaration_onName() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
v = 1;
}
''');
await assertHasAssistAt('v;', '''
-main() {
+void f() {
var v = 1;
}
''');
@@ -192,13 +192,13 @@
Future<void> test_onDeclaration_onType() async {
await resolveTestCode('''
-main() {
+void f() {
int v;
v = 1;
}
''');
await assertHasAssistAt('int v', '''
-main() {
+void f() {
int v = 1;
}
''');
@@ -206,13 +206,13 @@
Future<void> test_onDeclaration_onVar() async {
await resolveTestCode('''
-main() {
+void f() {
var v;
v = 1;
}
''');
await assertHasAssistAt('var v', '''
-main() {
+void f() {
var v = 1;
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/assist/use_curly_braces_test.dart b/pkg/analysis_server/test/src/services/correction/assist/use_curly_braces_test.dart
index 27f62f9..21961e5 100644
--- a/pkg/analysis_server/test/src/services/correction/assist/use_curly_braces_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/assist/use_curly_braces_test.dart
@@ -22,7 +22,7 @@
Future<void> test_do_block() async {
await resolveTestCode('''
-main() {
+void f() {
/*caret*/do {
print(0);
} while (true);
@@ -33,12 +33,12 @@
Future<void> test_do_body_middle() async {
await resolveTestCode('''
-main() {
+void f() {
do print/*caret*/(0); while (true);
}
''');
await assertHasAssist('''
-main() {
+void f() {
do {
print(0);
} while (true);
@@ -48,12 +48,12 @@
Future<void> test_do_body_start() async {
await resolveTestCode('''
-main() {
+void f() {
do /*caret*/print(0); while (true);
}
''');
await assertHasAssist('''
-main() {
+void f() {
do {
print(0);
} while (true);
@@ -63,12 +63,12 @@
Future<void> test_do_condition() async {
await resolveTestCode('''
-main() {
+void f() {
do print(0); while (/*caret*/true);
}
''');
await assertHasAssist('''
-main() {
+void f() {
do {
print(0);
} while (true);
@@ -78,12 +78,12 @@
Future<void> test_do_end() async {
await resolveTestCode('''
-main() {
+void f() {
do print(0); while (true);/*caret*/
}
''');
await assertHasAssist('''
-main() {
+void f() {
do {
print(0);
} while (true);
@@ -93,12 +93,12 @@
Future<void> test_do_keyword_do() async {
await resolveTestCode('''
-main() {
+void f() {
/*caret*/do print(0); while (true);
}
''');
await assertHasAssist('''
-main() {
+void f() {
do {
print(0);
} while (true);
@@ -108,12 +108,12 @@
Future<void> test_do_keyword_while() async {
await resolveTestCode('''
-main() {
+void f() {
do print(0); /*caret*/while (true);
}
''');
await assertHasAssist('''
-main() {
+void f() {
do {
print(0);
} while (true);
@@ -123,12 +123,12 @@
Future<void> test_for_body_end() async {
await resolveTestCode('''
-main() {
+void f() {
for (;;) print(0);/*caret*/
}
''');
await assertHasAssist('''
-main() {
+void f() {
for (;;) {
print(0);
}
@@ -138,12 +138,12 @@
Future<void> test_for_body_middle() async {
await resolveTestCode('''
-main() {
+void f() {
for (;;) print/*caret*/(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
for (;;) {
print(0);
}
@@ -153,12 +153,12 @@
Future<void> test_for_body_start() async {
await resolveTestCode('''
-main() {
+void f() {
for (;;) /*caret*/print(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
for (;;) {
print(0);
}
@@ -168,12 +168,12 @@
Future<void> test_for_condition() async {
await resolveTestCode('''
-main() {
+void f() {
for (/*caret*/;;) print(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
for (;;) {
print(0);
}
@@ -183,12 +183,12 @@
Future<void> test_for_keyword() async {
await resolveTestCode('''
-main() {
+void f() {
/*caret*/for (;;) print(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
for (;;) {
print(0);
}
@@ -198,7 +198,7 @@
Future<void> test_for_keyword_block() async {
await resolveTestCode('''
-main() {
+void f() {
/*caret*/for (;;) {
print(0);
}
@@ -361,7 +361,7 @@
lints: [LintNames.curly_braces_in_flow_control_structures]);
verifyNoTestUnitErrors = false;
await resolveTestCode('''
-main() {
+void f() {
do print/*caret*/(0); while (true);
}
''');
@@ -370,12 +370,12 @@
Future<void> test_while_body_end() async {
await resolveTestCode('''
-main() {
+void f() {
while (true) print(0);/*caret*/
}
''');
await assertHasAssist('''
-main() {
+void f() {
while (true) {
print(0);
}
@@ -385,12 +385,12 @@
Future<void> test_while_body_middle() async {
await resolveTestCode('''
-main() {
+void f() {
while (true) print/*caret*/(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
while (true) {
print(0);
}
@@ -400,12 +400,12 @@
Future<void> test_while_body_start() async {
await resolveTestCode('''
-main() {
+void f() {
while (true) /*caret*/print(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
while (true) {
print(0);
}
@@ -415,12 +415,12 @@
Future<void> test_while_condition() async {
await resolveTestCode('''
-main() {
+void f() {
while (/*caret*/true) print(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
while (true) {
print(0);
}
@@ -430,12 +430,12 @@
Future<void> test_while_keyword() async {
await resolveTestCode('''
-main() {
+void f() {
/*caret*/while (true) print(0);
}
''');
await assertHasAssist('''
-main() {
+void f() {
while (true) {
print(0);
}
@@ -445,7 +445,7 @@
Future<void> test_while_keyword_block() async {
await resolveTestCode('''
-main() {
+void f() {
/*caret*/while (true) {
print(0);
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart
index b12dab0..6825440 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart
@@ -44,13 +44,13 @@
Future<void> test_blockFunctionBody_function() async {
await resolveTestCode('''
foo() {}
-main() {
+f() {
await foo();
}
''');
await assertHasFix('''
foo() {}
-main() async {
+f() async {
await foo();
}
''');
@@ -93,11 +93,11 @@
Future<void> test_expressionFunctionBody() async {
await resolveTestCode('''
foo() {}
-main() => await foo();
+f() => await foo();
''');
await assertHasFix('''
foo() {}
-main() async => await foo();
+f() async => await foo();
''');
}
@@ -147,14 +147,14 @@
Future<void> test_returnFuture_alreadyFuture() async {
await resolveTestCode('''
foo() {}
-Future<int> main() {
+Future<int> f() {
await foo();
return 42;
}
''');
await assertHasFix('''
foo() {}
-Future<int> main() async {
+Future<int> f() async {
await foo();
return 42;
}
@@ -166,14 +166,14 @@
Future<void> test_returnFuture_dynamic() async {
await resolveTestCode('''
foo() {}
-dynamic main() {
+dynamic f() {
await foo();
return 42;
}
''');
await assertHasFix('''
foo() {}
-dynamic main() async {
+dynamic f() async {
await foo();
return 42;
}
@@ -183,14 +183,14 @@
Future<void> test_returnFuture_nonFuture() async {
await resolveTestCode('''
foo() {}
-int main() {
+int f() {
await foo();
return 42;
}
''');
await assertHasFix('''
foo() {}
-Future<int> main() async {
+Future<int> f() async {
await foo();
return 42;
}
@@ -200,14 +200,14 @@
Future<void> test_returnFuture_noType() async {
await resolveTestCode('''
foo() {}
-main() {
+f() {
await foo();
return 42;
}
''');
await assertHasFix('''
foo() {}
-main() async {
+f() async {
await foo();
return 42;
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart
index 31ce0c6..a33a9b8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(AddAwaitBulkTest);
defineReflectiveTests(AddAwaitTest);
});
}
@reflectiveTest
+class AddAwaitBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unawaited_futures;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+Future doSomething() => new Future.value('');
+Future doSomethingElse() => new Future.value('');
+
+void f() async {
+ doSomething();
+ doSomethingElse();
+}
+''');
+ await assertHasFix('''
+Future doSomething() => new Future.value('');
+Future doSomethingElse() => new Future.value('');
+
+void f() async {
+ await doSomething();
+ await doSomethingElse();
+}
+''');
+ }
+}
+
+@reflectiveTest
class AddAwaitTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_AWAIT;
@@ -23,18 +52,18 @@
@override
String get lintCode => LintNames.unawaited_futures;
- Future<void> test_intLiteral() async {
+ Future<void> test_methodInvocation() async {
await resolveTestCode('''
Future doSomething() => new Future.value('');
-void main() async {
+void f() async {
doSomething();
}
''');
await assertHasFix('''
Future doSomething() => new Future.value('');
-void main() async {
+void f() async {
await doSomething();
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
index bcb2893..486e950 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
@@ -7,61 +7,77 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
- defineReflectiveTests(AddConstTest);
- defineReflectiveTests(AddConstToImmutableConstructorTest);
+ defineReflectiveTests(AddConst_PreferConstConstructorsBulkTest);
+ defineReflectiveTests(AddConst_PreferConstConstructorsInImmutablesBulkTest);
+ defineReflectiveTests(AddConst_PreferConstConstructorsInImmutablesTest);
+ defineReflectiveTests(AddConst_PreferConstConstructorsTest);
});
}
@reflectiveTest
-class AddConstTest extends FixProcessorLintTest {
- @override
- FixKind get kind => DartFixKind.ADD_CONST;
-
+class AddConst_PreferConstConstructorsBulkTest extends BulkFixProcessorTest {
@override
String get lintCode => LintNames.prefer_const_constructors;
- Future<void> test_new() async {
- await resolveTestCode('''
-class C {
- const C();
-}
-main() {
- var c = new C();
- print(c);
-}
-''');
- // handled by REPLACE_NEW_WITH_CONST
- await assertNoFix();
- }
-
+ /// Disabled in BulkFixProcessor.
+ @failingTest
Future<void> test_noKeyword() async {
- await resolveTestCode('''
+ writeTestPackageConfig(meta: true);
+ await resolveTestCode(r'''
class C {
- const C();
+ const C([C c]);
}
-main() {
- var c = C();
- print(c);
+var c = C(C());
+''');
+ // TODO (pq): results are incompatible w/ `unnecessary_const`
+ await assertHasFix(r'''
+class C {
+ const C([C c]);
+}
+var c = const C(const C());
+''');
+ }
+}
+
+@reflectiveTest
+class AddConst_PreferConstConstructorsInImmutablesBulkTest
+ extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_const_constructors_in_immutables;
+
+ Future<void> test_multipleConstructors() async {
+ writeTestPackageConfig(meta: true);
+ await resolveTestCode('''
+import 'package:meta/meta.dart';
+
+@immutable
+class A {
+ A();
+ /// Comment.
+ A.a();
}
''');
await assertHasFix('''
-class C {
- const C();
-}
-main() {
- var c = const C();
- print(c);
+import 'package:meta/meta.dart';
+
+@immutable
+class A {
+ const A();
+ /// Comment.
+ const A.a();
}
''');
}
}
@reflectiveTest
-class AddConstToImmutableConstructorTest extends FixProcessorLintTest {
+class AddConst_PreferConstConstructorsInImmutablesTest
+ extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_CONST;
@@ -76,7 +92,7 @@
);
}
- Future<void> test_constConstructor() async {
+ Future<void> test_default() async {
await resolveTestCode('''
import 'package:meta/meta.dart';
@@ -95,7 +111,7 @@
''');
}
- Future<void> test_constConstructorWithComment() async {
+ Future<void> test_default_withComment() async {
await resolveTestCode('''
import 'package:meta/meta.dart';
@@ -116,3 +132,47 @@
''');
}
}
+
+@reflectiveTest
+class AddConst_PreferConstConstructorsTest extends FixProcessorLintTest {
+ @override
+ FixKind get kind => DartFixKind.ADD_CONST;
+
+ @override
+ String get lintCode => LintNames.prefer_const_constructors;
+
+ Future<void> test_new() async {
+ await resolveTestCode('''
+class C {
+ const C();
+}
+void f() {
+ var c = new C();
+ print(c);
+}
+''');
+ // handled by REPLACE_NEW_WITH_CONST
+ await assertNoFix();
+ }
+
+ Future<void> test_noKeyword() async {
+ await resolveTestCode('''
+class C {
+ const C();
+}
+void f() {
+ var c = C();
+ print(c);
+}
+''');
+ await assertHasFix('''
+class C {
+ const C();
+}
+void f() {
+ var c = const C();
+ print(c);
+}
+''');
+ }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
index 1d3b180..5ed1d1d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
@@ -8,15 +8,73 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(AddDiagnosticPropertyReferenceBulkTest);
defineReflectiveTests(AddDiagnosticPropertyReferenceTest);
});
}
@reflectiveTest
+class AddDiagnosticPropertyReferenceBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.diagnostic_describe_all_properties;
+
+ Future<void> test_singleFile() async {
+ writeTestPackageConfig(flutter: true);
+ await resolveTestCode('''
+import 'package:flutter/foundation.dart';
+import 'package:flutter/widgets.dart';
+
+class C extends Widget with Diagnosticable {
+ bool get absorbing => _absorbing;
+ bool _absorbing;
+ bool ignoringSemantics;
+ @override
+ void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ super.debugFillProperties(properties);
+ properties.add(DiagnosticsProperty<bool>('absorbing', absorbing));
+ }
+}
+
+class D extends Widget with Diagnosticable {
+ bool ignoringSemantics;
+ @override
+ void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ }
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/foundation.dart';
+import 'package:flutter/widgets.dart';
+
+class C extends Widget with Diagnosticable {
+ bool get absorbing => _absorbing;
+ bool _absorbing;
+ bool ignoringSemantics;
+ @override
+ void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ super.debugFillProperties(properties);
+ properties.add(DiagnosticsProperty<bool>('absorbing', absorbing));
+ properties.add(DiagnosticsProperty<bool>('ignoringSemantics', ignoringSemantics));
+ }
+}
+
+class D extends Widget with Diagnosticable {
+ bool ignoringSemantics;
+ @override
+ void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+ properties.add(DiagnosticsProperty<bool>('ignoringSemantics', ignoringSemantics));
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class AddDiagnosticPropertyReferenceTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_DIAGNOSTIC_PROPERTY_REFERENCE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_key_to_constructors_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_key_to_constructors_test.dart
new file mode 100644
index 0000000..ff5317c
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_key_to_constructors_test.dart
@@ -0,0 +1,184 @@
+// Copyright (c) 2019, 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:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
+import 'package:analyzer/src/dart/error/lint_codes.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'fix_processor.dart';
+
+void main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(AddKeyToConstructorsTest);
+ });
+}
+
+@reflectiveTest
+class AddKeyToConstructorsTest extends FixProcessorLintTest {
+ @override
+ FixKind get kind => DartFixKind.ADD_KEY_TO_CONSTRUCTORS;
+
+ @override
+ String get lintCode => LintNames.use_key_in_widget_constructors;
+
+ @override
+ void setUp() {
+ super.setUp();
+ writeTestPackageConfig(
+ flutter: true,
+ );
+ }
+
+ Future<void> test_class_newline() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ const MyWidget({Key? key}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_class_noNewline() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ const MyWidget({Key? key}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_namedParameters_withoutSuper() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({required String s});
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({Key? key, required String s}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_namedParameters_withSuper() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({required String s}) : super();
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({Key? key, required String s}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_noNamedParameters_withoutSuper() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget(String s);
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget(String s, {Key? key}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_noNamedParameters_withSuper() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget(String s) : super();
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget(String s, {Key? key}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_noParameters_withoutSuper() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget();
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({Key? key}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_noParameters_withSuper_empty() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget() : super();
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({Key? key}) : super(key: key);
+}
+''');
+ }
+
+ Future<void> test_constructor_noParameters_withSuper_nonEmpty() async {
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget() : super(text: '');
+}
+''');
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+
+class MyWidget extends StatelessWidget {
+ MyWidget({Key? key}) : super(key: key, text: '');
+}
+''', errorFilter: (error) => error.errorCode is LintCode);
+ }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_case_clauses_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_case_clauses_test.dart
index f23da1c..2d950bd 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_case_clauses_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_case_clauses_test.dart
@@ -64,10 +64,34 @@
''');
}
+ Future<void> test_empty_singleLine() async {
+ await resolveTestCode('''
+enum E {a, b, c}
+void f(E e) {
+ switch (e) {}
+}
+''');
+ await assertHasFixWithFilter('''
+enum E {a, b, c}
+void f(E e) {
+ switch (e) {
+ case E.a:
+ // TODO: Handle this case.
+ break;
+ case E.b:
+ // TODO: Handle this case.
+ break;
+ case E.c:
+ // TODO: Handle this case.
+ break;
+ }
+}
+''');
+ }
+
Future<void> test_incomplete_switchStatement() async {
await resolveTestCode(r'''
enum E {a, b, c}
-
void f(E e) {
switch(e
}
@@ -75,7 +99,7 @@
await assertNoFix(errorFilter: _filter);
}
- Future<void> test_nonEmpty() async {
+ Future<void> test_notEmpty() async {
await resolveTestCode('''
enum E {a, b, c}
void f(E e) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_like_case_clauses_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_like_case_clauses_test.dart
index 6c299ca..87b75db 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_like_case_clauses_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_missing_enum_like_case_clauses_test.dart
@@ -4,6 +4,8 @@
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analysis_server/src/services/linter/lint_names.dart';
+import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -23,7 +25,94 @@
@override
String get lintCode => LintNames.exhaustive_cases;
- Future<void> test_missing() async {
+ bool Function(AnalysisError) get _filter {
+ var hasError = false;
+ return (error) {
+ var errorCode = error.errorCode;
+ if (!hasError && errorCode is LintCode && errorCode.name == lintCode) {
+ hasError = true;
+ return true;
+ }
+ return false;
+ };
+ }
+
+ Future<void> assertHasFixWithFilter(String expected) async {
+ await assertHasFix(expected, errorFilter: _filter);
+ }
+
+ Future<void> test_empty() async {
+ await resolveTestCode('''
+void f(E e) {
+ switch (e) {
+ }
+}
+class E {
+ static const E a = E._(0);
+ static const E b = E._(1);
+ static const E c = E._(2);
+ const E._(int x);
+}
+''');
+ await assertHasFixWithFilter('''
+void f(E e) {
+ switch (e) {
+ case E.a:
+ // TODO: Handle this case.
+ break;
+ case E.b:
+ // TODO: Handle this case.
+ break;
+ case E.c:
+ // TODO: Handle this case.
+ break;
+ }
+}
+class E {
+ static const E a = E._(0);
+ static const E b = E._(1);
+ static const E c = E._(2);
+ const E._(int x);
+}
+''');
+ }
+
+ Future<void> test_empty_singleLine() async {
+ await resolveTestCode('''
+void f(E e) {
+ switch (e) {}
+}
+class E {
+ static const E a = E._(0);
+ static const E b = E._(1);
+ static const E c = E._(2);
+ const E._(int x);
+}
+''');
+ await assertHasFixWithFilter('''
+void f(E e) {
+ switch (e) {
+ case E.a:
+ // TODO: Handle this case.
+ break;
+ case E.b:
+ // TODO: Handle this case.
+ break;
+ case E.c:
+ // TODO: Handle this case.
+ break;
+ }
+}
+class E {
+ static const E a = E._(0);
+ static const E b = E._(1);
+ static const E c = E._(2);
+ const E._(int x);
+}
+''');
+ }
+
+ Future<void> test_notEmpty() async {
await resolveTestCode('''
void f(E e) {
switch (e) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart
index 9131f4f..cc2d0c8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart
@@ -7,15 +7,50 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(AddOverrideBulkTest);
defineReflectiveTests(AddOverrideTest);
});
}
@reflectiveTest
+class AddOverrideBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.annotate_overrides;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class A {
+ void a() {}
+ void aa() {}
+}
+
+class B extends A {
+ void a() {}
+ void aa() {}
+}
+''');
+ await assertHasFix('''
+class A {
+ void a() {}
+ void aa() {}
+}
+
+class B extends A {
+ @override
+ void a() {}
+ @override
+ void aa() {}
+}
+''');
+ }
+}
+
+@reflectiveTest
class AddOverrideTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_OVERRIDE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
index 35a6973..9708adb 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
@@ -8,16 +8,43 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(AddRequiredBulkTest);
defineReflectiveTests(AddRequiredTest);
defineReflectiveTests(AddRequiredWithNullSafetyTest);
});
}
@reflectiveTest
+class AddRequiredBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.always_require_non_null_named_parameters;
+
+ @override
+ // Note that this lint does not fire w/ NNBD.
+ String? get testPackageLanguageVersion => '2.9';
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void function({String p1, int p2}) {
+ assert(p1 != null);
+ assert(p2 != null);
+}
+''');
+ await assertHasFix('''
+void function({@required String p1, @required int p2}) {
+ assert(p1 != null);
+ assert(p2 != null);
+}
+''');
+ }
+}
+
+@reflectiveTest
class AddRequiredTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_REQUIRED;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_await_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_await_test.dart
deleted file mode 100644
index dc61da4..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_await_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(AddAwaitTest);
- });
-}
-
-@reflectiveTest
-class AddAwaitTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unawaited_futures;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-Future doSomething() => new Future.value('');
-Future doSomethingElse() => new Future.value('');
-
-void main() async {
- doSomething();
- doSomethingElse();
-}
-''');
- await assertHasFix('''
-Future doSomething() => new Future.value('');
-Future doSomethingElse() => new Future.value('');
-
-void main() async {
- await doSomething();
- await doSomethingElse();
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart
deleted file mode 100644
index d20eaf8..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_const_test.dart
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(AddConstToConstructorTest);
- defineReflectiveTests(AddConstToImmutableConstructorTest);
- });
-}
-
-@reflectiveTest
-class AddConstToConstructorTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_const_constructors;
-
- /// Disabled in BulkFixProcessor.
- @failingTest
- Future<void> test_singleFile() async {
- writeTestPackageConfig(meta: true);
- await resolveTestCode(r'''
-class C {
- const C([C c]);
-}
-var c = C(C());
-''');
- // TODO (pq): results are incompatible w/ `unnecessary_const`
- await assertHasFix(r'''
-class C {
- const C([C c]);
-}
-var c = const C(const C());
-''');
- }
-}
-
-@reflectiveTest
-class AddConstToImmutableConstructorTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_const_constructors_in_immutables;
-
- Future<void> test_singleFile() async {
- writeTestPackageConfig(meta: true);
- await resolveTestCode('''
-import 'package:meta/meta.dart';
-
-@immutable
-class A {
- A();
- /// Comment.
- A.a();
-}
-''');
- await assertHasFix('''
-import 'package:meta/meta.dart';
-
-@immutable
-class A {
- const A();
- /// Comment.
- const A.a();
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart
deleted file mode 100644
index 0fead9f..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_diagnostic_property_reference_test.dart
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(AddDiagnosticPropertyReferenceTest);
- });
-}
-
-@reflectiveTest
-class AddDiagnosticPropertyReferenceTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.diagnostic_describe_all_properties;
-
- Future<void> test_singleFile() async {
- writeTestPackageConfig(flutter: true);
- await resolveTestCode('''
-import 'package:flutter/foundation.dart';
-import 'package:flutter/widgets.dart';
-
-class C extends Widget with Diagnosticable {
- bool get absorbing => _absorbing;
- bool _absorbing;
- bool ignoringSemantics;
- @override
- void debugFillProperties(DiagnosticPropertiesBuilder properties) {
- super.debugFillProperties(properties);
- properties.add(DiagnosticsProperty<bool>('absorbing', absorbing));
- }
-}
-
-class D extends Widget with Diagnosticable {
- bool ignoringSemantics;
- @override
- void debugFillProperties(DiagnosticPropertiesBuilder properties) {
- }
-}
-''');
- await assertHasFix('''
-import 'package:flutter/foundation.dart';
-import 'package:flutter/widgets.dart';
-
-class C extends Widget with Diagnosticable {
- bool get absorbing => _absorbing;
- bool _absorbing;
- bool ignoringSemantics;
- @override
- void debugFillProperties(DiagnosticPropertiesBuilder properties) {
- super.debugFillProperties(properties);
- properties.add(DiagnosticsProperty<bool>('absorbing', absorbing));
- properties.add(DiagnosticsProperty<bool>('ignoringSemantics', ignoringSemantics));
- }
-}
-
-class D extends Widget with Diagnosticable {
- bool ignoringSemantics;
- @override
- void debugFillProperties(DiagnosticPropertiesBuilder properties) {
- properties.add(DiagnosticsProperty<bool>('ignoringSemantics', ignoringSemantics));
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_override_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_override_test.dart
deleted file mode 100644
index b62d97e..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_override_test.dart
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(AddOverrideTest);
- });
-}
-
-@reflectiveTest
-class AddOverrideTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.annotate_overrides;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class A {
- void a() {}
- void aa() {}
-}
-
-class B extends A {
- void a() {}
- void aa() {}
-}
-''');
- await assertHasFix('''
-class A {
- void a() {}
- void aa() {}
-}
-
-class B extends A {
- @override
- void a() {}
- @override
- void aa() {}
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/add_required_test.dart
deleted file mode 100644
index 07fd254..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/add_required_test.dart
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2021, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- // Note that this lint does not fire w/ NNBD.
- defineReflectiveTests(AddRequiredTest);
- });
-}
-
-@reflectiveTest
-class AddRequiredTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.always_require_non_null_named_parameters;
-
- @override
- String? get testPackageLanguageVersion => '2.9';
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void function({String p1, int p2}) {
- assert(p1 != null);
- assert(p2 != null);
-}
-''');
- await assertHasFix('''
-void function({@required String p1, @required int p2}) {
- assert(p1 != null);
- assert(p2 != null);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_documentation_into_line_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_documentation_into_line_test.dart
deleted file mode 100644
index 2094c37..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_documentation_into_line_test.dart
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertDocumentationIntoLineTest);
- });
-}
-
-@reflectiveTest
-class ConvertDocumentationIntoLineTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.slash_for_doc_comments;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-/**
- * C
- */
-class C {
- /**
- * f
- */
- int f;
-
- /**
- * m
- */
- m() {}
-}
-
-/**
- * f
- */
-void f() {}
-''');
- await assertHasFix('''
-/// C
-class C {
- /// f
- int f;
-
- /// m
- m() {}
-}
-
-/// f
-void f() {}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_for_each_to_for_loop_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_for_each_to_for_loop_test.dart
deleted file mode 100644
index 2514ae0..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_for_each_to_for_loop_test.dart
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertForEachToForLoop);
- });
-}
-
-@reflectiveTest
-class ConvertForEachToForLoop extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_function_literals_in_foreach_calls;
-
- Future<void> test_blockBody_blockBody() async {
- await resolveTestCode(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- a.forEach((ea) {
- b.forEach((eb) {
- result.add('$ea $eb');
- });
- });
-}
-''');
- await assertHasFix(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- for (var ea in a) {
- for (var eb in b) {
- result.add('$ea $eb');
- }
- }
-}
-''');
- }
-
- Future<void> test_blockBody_expressionBody() async {
- await resolveTestCode(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- a.forEach((ea) {
- b.forEach((eb) => result.add('$ea $eb'));
- });
-}
-''');
- await assertHasFix(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- for (var ea in a) {
- for (var eb in b) {
- result.add('$ea $eb');
- }
- }
-}
-''');
- }
-
- Future<void> test_expressionBody_blockBody() async {
- await resolveTestCode(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- a.forEach((ea) => b.forEach((eb) {
- result.add('$ea $eb');
- }));
-}
-''');
- await assertHasFix(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- for (var ea in a) {
- b.forEach((eb) {
- result.add('$ea $eb');
- });
- }
-}
-''');
- }
-
- Future<void> test_expressionBody_expressionBody() async {
- await resolveTestCode(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- a.forEach((ea) => b.forEach((eb) => result.add('$ea $eb')));
-}
-''');
- await assertHasFix(r'''
-void f(List<String> a, List<String> b) {
- var result = <String>[];
- for (var ea in a) {
- b.forEach((eb) => result.add('$ea $eb'));
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_map_from_iterable_to_for_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_map_from_iterable_to_for_literal_test.dart
deleted file mode 100644
index d9e3834..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_map_from_iterable_to_for_literal_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToForElementTest);
- });
-}
-
-@reflectiveTest
-class ConvertToForElementTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_for_elements_to_map_fromIterable;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-f(Iterable<int> i) {
- var k = 3;
- return Map.fromIterable(i, key: (k) => k * 2, value: (v) => k);
-}
-
-f2(Iterable<int> i) {
- return Map.fromIterable(i, key: (k) => k * 2, value: (v) => 0);
-}
-''');
- await assertHasFix('''
-f(Iterable<int> i) {
- var k = 3;
- return { for (var e in i) e * 2 : k };
-}
-
-f2(Iterable<int> i) {
- return { for (var k in i) k * 2 : 0 };
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_contains_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_contains_test.dart
deleted file mode 100644
index eacb1cc..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_contains_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToContainsTest);
- });
-}
-
-@reflectiveTest
-class ConvertToContainsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_contains;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-bool f(List<int> list, int value) {
- return -1 != list.indexOf(value);
-}
-
-bool f2(List<int> list, int value) {
- return 0 > list.indexOf(value);
-}
-''');
- await assertHasFix('''
-bool f(List<int> list, int value) {
- return list.contains(value);
-}
-
-bool f2(List<int> list, int value) {
- return !list.contains(value);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_generic_function_syntax_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_generic_function_syntax_test.dart
deleted file mode 100644
index e279e12..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_generic_function_syntax_test.dart
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(PreferGenericFunctionTypeAliasesTest);
- defineReflectiveTests(UseFunctionTypeSyntaxForParametersTest);
- });
-}
-
-@reflectiveTest
-class PreferGenericFunctionTypeAliasesTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_generic_function_type_aliases;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-typedef String F(int x);
-typedef F2<P, R>(P x);
-''');
- await assertHasFix('''
-typedef F = String Function(int x);
-typedef F2<P, R> = Function(P x);
-''');
- }
-}
-
-@reflectiveTest
-class UseFunctionTypeSyntaxForParametersTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.use_function_type_syntax_for_parameters;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-g(String f(int x), int h()) {}
-''');
- await assertHasFix('''
-g(String Function(int x) f, int Function() h) {}
-''');
- }
-
- @failingTest
- Future<void> test_singleFile_nested() async {
- // Only the outer function gets converted.
- await resolveTestCode('''
-g(String f(int h())) {}
-''');
- await assertHasFix('''
-g(String Function(int Function() h) f) {}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_if_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_if_element_test.dart
deleted file mode 100644
index e965e54..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_if_element_test.dart
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToIfElementTest);
- });
-}
-
-@reflectiveTest
-class ConvertToIfElementTest extends BulkFixProcessorTest {
- @override
- String get lintCode =>
- LintNames.prefer_if_elements_to_conditional_expressions;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-String f(bool b) {
- return ['a', b ? 'c' : 'd', 'e'];
-}
-
-String f2(bool b) {
- return {'a', b ? 'c' : 'd', 'e'};
-}
-''');
- await assertHasFix('''
-String f(bool b) {
- return ['a', if (b) 'c' else 'd', 'e'];
-}
-
-String f2(bool b) {
- return {'a', if (b) 'c' else 'd', 'e'};
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_if_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_if_null_test.dart
deleted file mode 100644
index 5bca56c..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_if_null_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToIfNullTest);
- });
-}
-
-@reflectiveTest
-class ConvertToIfNullTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_if_null_operators;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f(String s) {
- print(s == null ? 'default' : s);
- print(s != null ? s : 'default');
-}
-''');
- await assertHasFix('''
-void f(String s) {
- print(s ?? 'default');
- print(s ?? 'default');
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_int_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_int_literal_test.dart
deleted file mode 100644
index 32b17ce..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_int_literal_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToIntLiteralTest);
- });
-}
-
-@reflectiveTest
-class ConvertToIntLiteralTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_int_literals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-const double d1 = 42.0;
-double d2 = 7.0e2;
-''');
- await assertHasFix('''
-const double d1 = 42;
-double d2 = 700;
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart
index 42a907d..f83a3b9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart
@@ -20,12 +20,12 @@
Future<void> test_singleFile() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
!(p is String) && !!(p is String);
}
''');
await assertHasFix('''
-main(p) {
+void f(p) {
p is! String && !(p is! String);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_list_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_list_literal_test.dart
deleted file mode 100644
index af7f3cb..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_list_literal_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToListLiteralTest);
- });
-}
-
-@reflectiveTest
-class ConvertToListLiteralTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_collection_literals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-List l = List();
-var l2 = List<int>();
-''');
- await assertHasFix('''
-List l = [];
-var l2 = <int>[];
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_map_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_map_literal_test.dart
deleted file mode 100644
index cb02894..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_map_literal_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToMapLiteralTest);
- });
-}
-
-@reflectiveTest
-class ConvertToMapLiteralTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_collection_literals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-Map m = Map();
-var m2 = Map<String, int>();
-''');
- await assertHasFix('''
-Map m = {};
-var m2 = <String, int>{};
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_null_aware_test.dart
deleted file mode 100644
index e30e7d7..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_null_aware_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToNullAwareTest);
- });
-}
-
-@reflectiveTest
-class ConvertToNullAwareTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_null_aware_operators;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class A {
- int m(int p) => p;
-}
-int f(A x, A y) => x == null ? null : x.m(y == null ? null : y.m(0));
-''');
- await assertHasFix('''
-class A {
- int m(int p) => p;
-}
-int f(A x, A y) => x?.m(y?.m(0));
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_package_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_package_import_test.dart
deleted file mode 100644
index 3c8cf2b..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_package_import_test.dart
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2021, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import '../fix_processor.dart';
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToPackageImportTest);
- });
-}
-
-@reflectiveTest
-class ConvertToPackageImportTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_relative_lib_imports;
-
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/44673')
- Future<void> test_singleFile() async {
- writeTestPackageConfig(config: PackageConfigFileBuilder());
- addSource('/home/test/lib/bar.dart', 'class Bar {}');
-
- testFile = convertPath('/home/test/tool/test.dart');
-
- await resolveTestCode('''
-import '../lib/bar.dart';
-
-var bar = Bar();
-''');
- await assertHasFix('''
-import 'package:test/foo/bar.dart';
-
-var bar = Bar();
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_relative_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_relative_import_test.dart
deleted file mode 100644
index 40b022f..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_relative_import_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToRelativeImportTest);
- });
-}
-
-@reflectiveTest
-class ConvertToRelativeImportTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_relative_imports;
-
- Future<void> test_singleFile() async {
- addSource('/home/test/lib/foo.dart', '''
-class C {}
-''');
- addSource('/home/test/lib/bar.dart', '''
-class D {}
-''');
- testFile = convertPath('/home/test/lib/src/test.dart');
-
- await resolveTestCode('''
-import 'package:test/bar.dart';
-import 'package:test/foo.dart';
-C c;
-D d;
-''');
- await assertHasFix('''
-import '../bar.dart';
-import '../foo.dart';
-C c;
-D d;
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_set_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_set_literal_test.dart
deleted file mode 100644
index bfcaf1c..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_set_literal_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToSetLiteralTest);
- });
-}
-
-@reflectiveTest
-class ConvertToSetLiteralTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_collection_literals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-Set s = Set();
-var s1 = Set<int>();
-''');
- await assertHasFix('''
-Set s = {};
-var s1 = <int>{};
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_single_quoted_strings_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_single_quoted_strings_test.dart
deleted file mode 100644
index 68a54c0..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_single_quoted_strings_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToSingleQuotedStringTest);
- });
-}
-
-@reflectiveTest
-class ConvertToSingleQuotedStringTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_single_quotes;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-main() {
- print("abc");
- print("e" + "f" + "g");
-}
-''');
- await assertHasFix('''
-main() {
- print('abc');
- print('e' + 'f' + 'g');
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_spread_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_spread_test.dart
deleted file mode 100644
index ddbdc0a..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_spread_test.dart
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToSpreadTest);
- });
-}
-
-@reflectiveTest
-class ConvertToSpreadTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_spread_collections;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-f() {
- var ints = [1, 2, 3];
- print(['a']..addAll(ints.map((i) => i.toString()))..addAll(['c']));
-}
-
-f2() {
- bool condition;
- var things;
- var l = ['a']..addAll(condition ? things : []);
-}
-''');
- await assertHasFix('''
-f() {
- var ints = [1, 2, 3];
- print(['a', ...ints.map((i) => i.toString())]..addAll(['c']));
-}
-
-f2() {
- bool condition;
- var things;
- var l = ['a', if (condition) ...things];
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_where_type_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_where_type_test.dart
deleted file mode 100644
index 62788ef..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_where_type_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ConvertToWhereTypeTest);
- });
-}
-
-@reflectiveTest
-class ConvertToWhereTypeTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_iterable_whereType;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-Iterable<C> f(List<Object> list) {
- return list.where((e) => e is C);
-}
-Iterable<C> f2(List<Object> list) =>
- list.where((e) => e is C);
-
-class C {}
-''');
- await assertHasFix('''
-Iterable<C> f(List<Object> list) {
- return list.whereType<C>();
-}
-Iterable<C> f2(List<Object> list) =>
- list.whereType<C>();
-
-class C {}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
index a90e17f..db092c5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
@@ -4,35 +4,8 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'add_await_test.dart' as add_await;
-import 'add_const_test.dart' as add_const;
-import 'add_diagnostic_property_reference_test.dart'
- as add_diagnostic_property_reference;
-import 'add_override_test.dart' as add_override;
-import 'add_required_test.dart' as add_required;
import 'bulk_fix_processor_test.dart' as bulk_fix_processor;
-import 'convert_documentation_into_line_test.dart'
- as convert_documentation_into_line;
-import 'convert_for_each_to_for_loop_test.dart' as convert_for_each_to_for_loop;
-import 'convert_map_from_iterable_to_for_literal_test.dart'
- as convert_map_from_iterable_to_for_literal;
-import 'convert_to_contains_test.dart' as convert_to_contains;
-import 'convert_to_generic_function_syntax_test.dart'
- as convert_to_generic_function_syntax;
-import 'convert_to_if_element_test.dart' as convert_to_if_element;
-import 'convert_to_if_null_test.dart' as convert_to_if_null;
-import 'convert_to_int_literal_test.dart' as convert_to_int_literal;
import 'convert_to_is_not_test.dart' as convert_to_is_not;
-import 'convert_to_list_literal_test.dart' as convert_to_list_literal;
-import 'convert_to_map_literal_test.dart' as convert_to_map_literal;
-import 'convert_to_null_aware_test.dart' as convert_to_null_aware;
-import 'convert_to_package_import_test.dart' as convert_to_package_import;
-import 'convert_to_relative_import_test.dart' as convert_to_relative_import;
-import 'convert_to_set_literal_test.dart' as convert_to_set_literal;
-import 'convert_to_single_quoted_strings_test.dart'
- as convert_to_single_quoted_strings;
-import 'convert_to_spread_test.dart' as convert_to_spread;
-import 'convert_to_where_type_test.dart' as convert_to_where_type;
import 'create_method_test.dart' as create_method;
import 'data_driven_test.dart' as data_driven;
import 'inline_invocation_test.dart' as inline_invocation;
@@ -76,30 +49,8 @@
void main() {
defineReflectiveSuite(() {
- add_await.main();
- add_const.main();
- add_diagnostic_property_reference.main();
- add_override.main();
- add_required.main();
bulk_fix_processor.main();
- convert_documentation_into_line.main();
- convert_for_each_to_for_loop.main();
- convert_map_from_iterable_to_for_literal.main();
- convert_to_contains.main();
- convert_to_generic_function_syntax.main();
- convert_to_if_element.main();
- convert_to_if_null.main();
- convert_to_int_literal.main();
convert_to_is_not.main();
- convert_to_list_literal.main();
- convert_to_map_literal.main();
- convert_to_null_aware.main();
- convert_to_package_import.main();
- convert_to_relative_import.main();
- convert_to_set_literal.main();
- convert_to_single_quoted_strings.main();
- convert_to_spread.main();
- convert_to_where_type.main();
create_method.main();
data_driven.main();
inline_invocation.main();
diff --git a/pkg/analysis_server/test/src/services/correction/fix/change_to_static_access_test.dart b/pkg/analysis_server/test/src/services/correction/fix/change_to_static_access_test.dart
index a814c91..63abb76 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/change_to_static_access_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/change_to_static_access_test.dart
@@ -43,7 +43,7 @@
extension E on int {
static void foo() {}
}
-main() {
+void f() {
0.foo();
}
''');
@@ -51,7 +51,7 @@
extension E on int {
static void foo() {}
}
-main() {
+void f() {
E.foo();
}
''');
@@ -127,7 +127,7 @@
extension E on int {
static int get foo => 42;
}
-main() {
+void f() {
0.foo;
}
''');
@@ -135,7 +135,7 @@
extension E on int {
static int get foo => 42;
}
-main() {
+void f() {
E.foo;
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart b/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart
index 6fa6559..7a14be2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/change_to_test.dart
@@ -70,13 +70,13 @@
Future<void> test_class_fromImport() async {
await resolveTestCode('''
-main() {
+void f() {
Stirng s = 'abc';
print(s);
}
''');
await assertHasFix('''
-main() {
+void f() {
String s = 'abc';
print(s);
}
@@ -86,14 +86,14 @@
Future<void> test_class_fromThisLibrary() async {
await resolveTestCode('''
class MyClass {}
-main() {
+void f() {
MyCalss v = null;
print(v);
}
''');
await assertHasFix('''
class MyClass {}
-main() {
+void f() {
MyClass v = null;
print(v);
}
@@ -116,14 +116,14 @@
Future<void> test_class_prefixed() async {
await resolveTestCode('''
import 'dart:async' as c;
-main() {
+void f() {
c.Fture v = null;
print(v);
}
''');
await assertHasFix('''
import 'dart:async' as c;
-main() {
+void f() {
c.Future v = null;
print(v);
}
@@ -145,12 +145,12 @@
Future<void> test_function_fromImport() async {
await resolveTestCode('''
-main() {
+void f() {
pritn(0);
}
''');
await assertHasFix('''
-main() {
+void f() {
print(0);
}
''');
@@ -159,13 +159,13 @@
Future<void> test_function_prefixed_fromImport() async {
await resolveTestCode('''
import 'dart:core' as c;
-main() {
+void f() {
c.prnt(42);
}
''');
await assertHasFix('''
import 'dart:core' as c;
-main() {
+void f() {
c.print(42);
}
''');
@@ -174,8 +174,8 @@
Future<void> test_function_prefixed_ignoreLocal() async {
await resolveTestCode('''
import 'dart:async' as c;
-main() {
- c.main();
+void f() {
+ c.f();
}
''');
await assertNoFix();
@@ -184,13 +184,13 @@
Future<void> test_function_thisLibrary() async {
await resolveTestCode('''
myFunction() {}
-main() {
+void f() {
myFuntcion();
}
''');
await assertHasFix('''
myFunction() {}
-main() {
+void f() {
myFunction();
}
''');
@@ -260,7 +260,7 @@
class A {
static int MY_NAME = 1;
}
-main() {
+void f() {
A.MY_NAM;
}
''');
@@ -268,7 +268,7 @@
class A {
static int MY_NAME = 1;
}
-main() {
+void f() {
A.MY_NAME;
}
''');
@@ -297,7 +297,7 @@
await resolveTestCode('''
class A {
int myField = 0;
- main() {
+ void f() {
print(myFild);
}
}
@@ -305,7 +305,7 @@
await assertHasFix('''
class A {
int myField = 0;
- main() {
+ void f() {
print(myField);
}
}
@@ -383,7 +383,7 @@
Future<void> test_method_ignoreOperators() async {
await resolveTestCode('''
-main(Object object) {
+void f(Object object) {
object.then();
}
''');
@@ -414,7 +414,7 @@
class A {
myMethod() {}
}
-main() {
+void f() {
A a = new A();
a.myMehtod();
}
@@ -423,7 +423,7 @@
class A {
myMethod() {}
}
-main() {
+void f() {
A a = new A();
a.myMethod();
}
@@ -455,7 +455,7 @@
myMethod() {}
}
class B extends A {
- main() {
+ void f() {
myMehtod();
}
}
@@ -465,7 +465,7 @@
myMethod() {}
}
class B extends A {
- main() {
+ void f() {
myMethod();
}
}
@@ -476,7 +476,7 @@
await resolveTestCode('''
class A {
myMethod() {}
- main() {
+ void f() {
myMehtod();
}
}
@@ -484,7 +484,7 @@
await assertHasFix('''
class A {
myMethod() {}
- main() {
+ void f() {
myMethod();
}
}
@@ -573,7 +573,7 @@
await resolveTestCode('''
class A {
int myField = 0;
- main() {
+ void f() {
myFild = 42;
}
}
@@ -581,7 +581,7 @@
await assertHasFix('''
class A {
int myField = 0;
- main() {
+ void f() {
myField = 42;
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart
index e68869f..6f68f20 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart
@@ -7,15 +7,60 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertDocumentationIntoLineBulkTest);
defineReflectiveTests(ConvertDocumentationIntoLineTest);
});
}
@reflectiveTest
+class ConvertDocumentationIntoLineBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.slash_for_doc_comments;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+/**
+ * C
+ */
+class C {
+ /**
+ * f
+ */
+ int f;
+
+ /**
+ * m
+ */
+ m() {}
+}
+
+/**
+ * f
+ */
+void f() {}
+''');
+ await assertHasFix('''
+/// C
+class C {
+ /// f
+ int f;
+
+ /// m
+ m() {}
+}
+
+/// f
+void f() {}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertDocumentationIntoLineTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_LINE_COMMENT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart
index b8d2fbd..84d4285 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart
@@ -7,15 +7,105 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertForEachToForLoopBulkTest);
defineReflectiveTests(ConvertForEachToForLoopTest);
});
}
@reflectiveTest
+class ConvertForEachToForLoopBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_function_literals_in_foreach_calls;
+
+ Future<void> test_blockBody_blockBody() async {
+ await resolveTestCode(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ a.forEach((ea) {
+ b.forEach((eb) {
+ result.add('$ea $eb');
+ });
+ });
+}
+''');
+ await assertHasFix(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ for (var ea in a) {
+ for (var eb in b) {
+ result.add('$ea $eb');
+ }
+ }
+}
+''');
+ }
+
+ Future<void> test_blockBody_expressionBody() async {
+ await resolveTestCode(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ a.forEach((ea) {
+ b.forEach((eb) => result.add('$ea $eb'));
+ });
+}
+''');
+ await assertHasFix(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ for (var ea in a) {
+ for (var eb in b) {
+ result.add('$ea $eb');
+ }
+ }
+}
+''');
+ }
+
+ Future<void> test_expressionBody_blockBody() async {
+ await resolveTestCode(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ a.forEach((ea) => b.forEach((eb) {
+ result.add('$ea $eb');
+ }));
+}
+''');
+ await assertHasFix(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ for (var ea in a) {
+ b.forEach((eb) {
+ result.add('$ea $eb');
+ });
+ }
+}
+''');
+ }
+
+ Future<void> test_expressionBody_expressionBody() async {
+ await resolveTestCode(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ a.forEach((ea) => b.forEach((eb) => result.add('$ea $eb')));
+}
+''');
+ await assertHasFix(r'''
+void f(List<String> a, List<String> b) {
+ var result = <String>[];
+ for (var ea in a) {
+ b.forEach((eb) => result.add('$ea $eb'));
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertForEachToForLoopTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_FOR_EACH_TO_FOR_LOOP;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart
index f0edd0b..9796fa4 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToContainsBulkTest);
defineReflectiveTests(ConvertToContainsTest);
});
}
@reflectiveTest
+class ConvertToContainsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_contains;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+bool f(List<int> list, int value) {
+ return -1 != list.indexOf(value);
+}
+
+bool f2(List<int> list, int value) {
+ return 0 > list.indexOf(value);
+}
+''');
+ await assertHasFix('''
+bool f(List<int> list, int value) {
+ return list.contains(value);
+}
+
+bool f2(List<int> list, int value) {
+ return !list.contains(value);
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToContainsTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_CONTAINS;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart
index fafbb6e..a083583 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart
@@ -7,15 +7,46 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToForElementBulkTest);
defineReflectiveTests(ConvertToForElementTest);
});
}
@reflectiveTest
+class ConvertToForElementBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_for_elements_to_map_fromIterable;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+f(Iterable<int> i) {
+ var k = 3;
+ return Map.fromIterable(i, key: (k) => k * 2, value: (v) => k);
+}
+
+f2(Iterable<int> i) {
+ return Map.fromIterable(i, key: (k) => k * 2, value: (v) => 0);
+}
+''');
+ await assertHasFix('''
+f(Iterable<int> i) {
+ var k = 3;
+ return { for (var e in i) e * 2 : k };
+}
+
+f2(Iterable<int> i) {
+ return { for (var k in i) k * 2 : 0 };
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToForElementTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_FOR_ELEMENT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart
index 6d1ed6b..7279ed8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart
@@ -7,16 +7,36 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(PreferGenericFunctionTypeAliasesBulkTest);
defineReflectiveTests(PreferGenericFunctionTypeAliasesTest);
+ defineReflectiveTests(UseFunctionTypeSyntaxForParametersBulkTest);
defineReflectiveTests(UseFunctionTypeSyntaxForParametersTest);
});
}
@reflectiveTest
+class PreferGenericFunctionTypeAliasesBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_generic_function_type_aliases;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+typedef String F(int x);
+typedef F2<P, R>(P x);
+''');
+ await assertHasFix('''
+typedef F = String Function(int x);
+typedef F2<P, R> = Function(P x);
+''');
+ }
+}
+
+@reflectiveTest
class PreferGenericFunctionTypeAliasesTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_GENERIC_FUNCTION_SYNTAX;
@@ -69,6 +89,32 @@
}
@reflectiveTest
+class UseFunctionTypeSyntaxForParametersBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.use_function_type_syntax_for_parameters;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+g(String f(int x), int h()) {}
+''');
+ await assertHasFix('''
+g(String Function(int x) f, int Function() h) {}
+''');
+ }
+
+ @failingTest
+ Future<void> test_singleFile_nested() async {
+ // Only the outer function gets converted.
+ await resolveTestCode('''
+g(String f(int h())) {}
+''');
+ await assertHasFix('''
+g(String Function(int Function() h) f) {}
+''');
+ }
+}
+
+@reflectiveTest
class UseFunctionTypeSyntaxForParametersTest extends FixProcessorLintTest
with WithNullSafetyLintMixin {
@override
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart
index ed2c3aa..ca70353 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart
@@ -7,15 +7,45 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToIfElementBulkTest);
defineReflectiveTests(ConvertToIfElementTest);
});
}
@reflectiveTest
+class ConvertToIfElementBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode =>
+ LintNames.prefer_if_elements_to_conditional_expressions;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+String f(bool b) {
+ return ['a', b ? 'c' : 'd', 'e'];
+}
+
+String f2(bool b) {
+ return {'a', b ? 'c' : 'd', 'e'};
+}
+''');
+ await assertHasFix('''
+String f(bool b) {
+ return ['a', if (b) 'c' else 'd', 'e'];
+}
+
+String f2(bool b) {
+ return {'a', if (b) 'c' else 'd', 'e'};
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToIfElementTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_IF_ELEMENT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart
index a453603..c395555 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart
@@ -8,15 +8,38 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToIfNullBulkTest);
defineReflectiveTests(ConvertToIfNullTest);
});
}
@reflectiveTest
+class ConvertToIfNullBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_if_null_operators;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f(String s) {
+ print(s == null ? 'default' : s);
+ print(s != null ? s : 'default');
+}
+''');
+ await assertHasFix('''
+void f(String s) {
+ print(s ?? 'default');
+ print(s ?? 'default');
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToIfNullTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_IF_NULL;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart
index 154e215..3be5cf8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart
@@ -7,15 +7,34 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToIntLiteralBulkTest);
defineReflectiveTests(ConvertToIntLiteralTest);
});
}
@reflectiveTest
+class ConvertToIntLiteralBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_int_literals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+const double d1 = 42.0;
+double d2 = 7.0e2;
+''');
+ await assertHasFix('''
+const double d1 = 42;
+double d2 = 700;
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToIntLiteralTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_INT_LITERAL;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart
index 451e808..938fe3e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart
@@ -7,15 +7,34 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToListLiteralBulkTest);
defineReflectiveTests(ConvertToListLiteralTest);
});
}
@reflectiveTest
+class ConvertToListLiteralBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_collection_literals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+List l = List();
+var l2 = List<int>();
+''');
+ await assertHasFix('''
+List l = [];
+var l2 = <int>[];
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToListLiteralTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_LIST_LITERAL;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart
index 3407683..f5ca86a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart
@@ -7,15 +7,34 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToMapLiteralBulkTest);
defineReflectiveTests(ConvertToMapLiteralTest);
});
}
@reflectiveTest
+class ConvertToMapLiteralBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_collection_literals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+Map m = Map();
+var m2 = Map<String, int>();
+''');
+ await assertHasFix('''
+Map m = {};
+var m2 = <String, int>{};
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToMapLiteralTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_MAP_LITERAL;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_named_arguments_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_named_arguments_test.dart
index b911dbe..804be9f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_named_arguments_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_named_arguments_test.dart
@@ -25,7 +25,7 @@
A({int? a, int? b});
}
-main() {
+void f() {
new A(1, 2);
}
''');
@@ -76,7 +76,7 @@
A({int? a, double? b});
}
-main() {
+void f() {
new A(1.2, 3);
}
''');
@@ -85,7 +85,7 @@
A({int? a, double? b});
}
-main() {
+void f() {
new A(b: 1.2, a: 3);
}
''');
@@ -97,7 +97,7 @@
A(int a, {int? b});
}
-main() {
+void f() {
new A(1, 2);
}
''');
@@ -106,7 +106,7 @@
A(int a, {int? b});
}
-main() {
+void f() {
new A(1, b: 2);
}
''');
@@ -139,7 +139,7 @@
A({String? a});
}
-main() {
+void f() {
new A(1);
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart
index e460dc9..d5e10ac 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart
@@ -7,15 +7,38 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToNullAwareBulkTest);
defineReflectiveTests(ConvertToNullAwareTest);
});
}
@reflectiveTest
+class ConvertToNullAwareBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_null_aware_operators;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class A {
+ int m(int p) => p;
+}
+int f(A x, A y) => x == null ? null : x.m(y == null ? null : y.m(0));
+''');
+ await assertHasFix('''
+class A {
+ int m(int p) => p;
+}
+int f(A x, A y) => x?.m(y?.m(0));
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToNullAwareTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_NULL_AWARE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
index e991423..aaf2cf6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
@@ -7,15 +7,42 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToPackageImportBulkTest);
defineReflectiveTests(ConvertToPackageImportTest);
});
}
@reflectiveTest
+class ConvertToPackageImportBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_relative_lib_imports;
+
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/44673')
+ Future<void> test_singleFile() async {
+ writeTestPackageConfig(config: PackageConfigFileBuilder());
+ addSource('/home/test/lib/bar.dart', 'class Bar {}');
+
+ testFile = convertPath('/home/test/tool/test.dart');
+
+ await resolveTestCode('''
+import '../lib/bar.dart';
+
+var bar = Bar();
+''');
+ await assertHasFix('''
+import 'package:test/foo/bar.dart';
+
+var bar = Bar();
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToPackageImportTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_PACKAGE_IMPORT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart
index fb75c1c..0b20f39 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart
@@ -8,15 +8,46 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToRelativeImportBulkTest);
defineReflectiveTests(ConvertToRelativeImportTest);
});
}
@reflectiveTest
+class ConvertToRelativeImportBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_relative_imports;
+
+ Future<void> test_singleFile() async {
+ addSource('/home/test/lib/foo.dart', '''
+class C {}
+''');
+ addSource('/home/test/lib/bar.dart', '''
+class D {}
+''');
+ testFile = convertPath('/home/test/lib/src/test.dart');
+
+ await resolveTestCode('''
+import 'package:test/bar.dart';
+import 'package:test/foo.dart';
+C c;
+D d;
+''');
+ await assertHasFix('''
+import '../bar.dart';
+import '../foo.dart';
+C c;
+D d;
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToRelativeImportTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_RELATIVE_IMPORT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart
index 28674cb..37e97ef 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart
@@ -7,15 +7,34 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToSetLiteralBulkTest);
defineReflectiveTests(ConvertToSetLiteralTest);
});
}
@reflectiveTest
+class ConvertToSetLiteralBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_collection_literals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+Set s = Set();
+var s1 = Set<int>();
+''');
+ await assertHasFix('''
+Set s = {};
+var s1 = <int>{};
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToSetLiteralTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_SET_LITERAL;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart
index 12f8212..889b22a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart
@@ -7,15 +7,38 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToSingleQuotedStringBulkTest);
defineReflectiveTests(ConvertToSingleQuotedStringTest);
});
}
@reflectiveTest
+class ConvertToSingleQuotedStringBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_single_quotes;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f() {
+ print("abc");
+ print("e" + "f" + "g");
+}
+''');
+ await assertHasFix('''
+void f() {
+ print('abc');
+ print('e' + 'f' + 'g');
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToSingleQuotedStringTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_SINGLE_QUOTED_STRING;
@@ -25,14 +48,14 @@
Future<void> test_one_interpolation() async {
await resolveTestCode(r'''
-main() {
+void f() {
var b = 'b';
var c = 'c';
print("a $b-${c} d");
}
''');
await assertHasFix(r'''
-main() {
+void f() {
var b = 'b';
var c = 'c';
print('a $b-${c} d');
@@ -43,12 +66,12 @@
/// More coverage in the `convert_to_single_quoted_string_test.dart` assist test.
Future<void> test_one_simple() async {
await resolveTestCode('''
-main() {
+void f() {
print("abc");
}
''');
await assertHasFix('''
-main() {
+void f() {
print('abc');
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart
index bb9b5c8..db6fbce 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart
@@ -7,15 +7,50 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToSpreadBulkTest);
defineReflectiveTests(ConvertToSpreadTest);
});
}
@reflectiveTest
+class ConvertToSpreadBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_spread_collections;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+f() {
+ var ints = [1, 2, 3];
+ print(['a']..addAll(ints.map((i) => i.toString()))..addAll(['c']));
+}
+
+f2() {
+ bool condition;
+ var things;
+ var l = ['a']..addAll(condition ? things : []);
+}
+''');
+ await assertHasFix('''
+f() {
+ var ints = [1, 2, 3];
+ print(['a', ...ints.map((i) => i.toString())]..addAll(['c']));
+}
+
+f2() {
+ bool condition;
+ var things;
+ var l = ['a', if (condition) ...things];
+}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToSpreadTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_SPREAD;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart
index f139f68..0dc4ebe 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart
@@ -7,15 +7,44 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ConvertToWhereTypeBulkTest);
defineReflectiveTests(ConvertToWhereTypeTest);
});
}
@reflectiveTest
+class ConvertToWhereTypeBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_iterable_whereType;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+Iterable<C> f(List<Object> list) {
+ return list.where((e) => e is C);
+}
+Iterable<C> f2(List<Object> list) =>
+ list.where((e) => e is C);
+
+class C {}
+''');
+ await assertHasFix('''
+Iterable<C> f(List<Object> list) {
+ return list.whereType<C>();
+}
+Iterable<C> f2(List<Object> list) =>
+ list.whereType<C>();
+
+class C {}
+''');
+ }
+}
+
+@reflectiveTest
class ConvertToWhereTypeTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.CONVERT_TO_WHERE_TYPE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
index 3aaa0bb..1e0b056 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_field_test.dart
@@ -193,7 +193,7 @@
class A {
A get self => this;
}
-main() {
+void f() {
var a = new A();
int v = a.self.test;
print(v);
@@ -205,7 +205,7 @@
A get self => this;
}
-main() {
+void f() {
var a = new A();
int v = a.self.test;
print(v);
@@ -216,7 +216,7 @@
Future<void> test_getter_unqualified_instance_asInvocationArgument() async {
await resolveTestCode('''
class A {
- main() {
+ void m() {
f(test);
}
}
@@ -226,7 +226,7 @@
class A {
String test;
- main() {
+ void m() {
f(test);
}
}
@@ -237,7 +237,7 @@
Future<void> test_getter_unqualified_instance_assignmentRhs() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
int v = test;
print(v);
}
@@ -247,7 +247,7 @@
class A {
int test;
- main() {
+ void f() {
int v = test;
print(v);
}
@@ -258,7 +258,7 @@
Future<void> test_getter_unqualified_instance_asStatement() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
test;
}
}
@@ -267,7 +267,7 @@
class A {
var test;
- main() {
+ void f() {
test;
}
}
@@ -357,7 +357,7 @@
enum MyEnum {
AAA, BBB
}
-main() {
+void f() {
MyEnum.foo;
}
''');
@@ -373,7 +373,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main(A a) {
+void f(A a) {
int v = a.test;
print(v);
}
@@ -398,7 +398,7 @@
Future<void> test_inSDK() async {
await resolveTestCode('''
-main(List p) {
+void f(List p) {
p.foo = 1;
}
''');
@@ -441,7 +441,7 @@
}
class B<T> {
List<T> items = [];
- main(A a) {
+ void f(A a) {
a.test = items;
}
}
@@ -452,7 +452,7 @@
}
class B<T> {
List<T> items = [];
- main(A a) {
+ void f(A a) {
a.test = items;
}
}
@@ -464,7 +464,7 @@
class A<T> {
List<T> items = [];
- main(A a) {
+ void f(A a) {
test = items;
}
}
@@ -475,7 +475,7 @@
List<T> test;
- main(A a) {
+ void f(A a) {
test = items;
}
}
@@ -534,7 +534,7 @@
await resolveTestCode('''
class A {
}
-main() {
+void f() {
A.test = 5;
}
''');
@@ -542,7 +542,7 @@
class A {
static int test;
}
-main() {
+void f() {
A.test = 5;
}
''');
@@ -551,7 +551,7 @@
Future<void> test_setter_unqualified_instance() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
test = 5;
}
}
@@ -560,7 +560,7 @@
class A {
int test;
- main() {
+ void f() {
test = 5;
}
}
@@ -570,7 +570,7 @@
Future<void> test_setter_unqualified_static() async {
await resolveTestCode('''
class A {
- static main() {
+ static void f() {
test = 5;
}
}
@@ -579,7 +579,7 @@
class A {
static int test;
- static main() {
+ static void f() {
test = 5;
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart
index 5f328c6..988c679 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_file_test.dart
@@ -100,7 +100,7 @@
);
}
- Future<void> test_forPart() async {
+ Future<void> test_forPart_explicitlyNamedLibrary() async {
await resolveTestCode('''
library my.lib;
part 'my_part.dart';
@@ -113,6 +113,21 @@
expect(fileEdit.file, convertPath('/home/test/lib/my_part.dart'));
expect(fileEdit.fileStamp, -1);
expect(fileEdit.edits, hasLength(1));
- expect(fileEdit.edits[0].replacement, contains('part of my.lib;'));
+ expect(fileEdit.edits[0].replacement, contains("part of 'test.dart';"));
+ }
+
+ Future<void> test_forPart_implicitlyNamedLibrary() async {
+ await resolveTestCode('''
+part 'foo/my_part.dart';
+''');
+ await assertHasFixWithoutApplying();
+ // validate change
+ var fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+ var fileEdit = change.edits[0];
+ expect(fileEdit.file, convertPath('/home/test/lib/foo/my_part.dart'));
+ expect(fileEdit.fileStamp, -1);
+ expect(fileEdit.edits, hasLength(1));
+ expect(fileEdit.edits[0].replacement, contains("part of '../test.dart';"));
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_getter_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_getter_test.dart
index 1c44825..7c382e6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_getter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_getter_test.dart
@@ -46,7 +46,7 @@
Future<void> test_unqualified_instance_assignmentLhs() async {
await resolveTestCode('''
mixin M {
- main() {
+ void f() {
test = 42;
}
}
@@ -57,7 +57,7 @@
Future<void> test_unqualified_instance_assignmentRhs() async {
await resolveTestCode('''
mixin M {
- main() {
+ void f() {
int v = test;
print(v);
}
@@ -67,7 +67,7 @@
mixin M {
int get test => null;
- main() {
+ void f() {
int v = test;
print(v);
}
@@ -105,7 +105,7 @@
Future<void> test_inSDK() async {
await resolveTestCode('''
-main(List p) {
+void f(List p) {
int v = p.foo;
print(v);
}
@@ -316,7 +316,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main(A a) {
+void f(A a) {
int v = a.test;
print(v);
}
@@ -346,7 +346,7 @@
class A {
A get self => this;
}
-main() {
+void f() {
var a = new A();
int v = a.self.test;
print(v);
@@ -358,7 +358,7 @@
int get test => null;
}
-main() {
+void f() {
var a = new A();
int v = a.self.test;
print(v);
@@ -402,7 +402,7 @@
Future<void> test_unqualified_instance_asInvocationArgument() async {
await resolveTestCode('''
class A {
- main() {
+ void m() {
f(test);
}
}
@@ -412,7 +412,7 @@
class A {
String get test => null;
- main() {
+ void m() {
f(test);
}
}
@@ -423,7 +423,7 @@
Future<void> test_unqualified_instance_assignmentLhs() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
test = 42;
}
}
@@ -434,7 +434,7 @@
Future<void> test_unqualified_instance_assignmentRhs() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
int v = test;
print(v);
}
@@ -444,7 +444,7 @@
class A {
int get test => null;
- main() {
+ void f() {
int v = test;
print(v);
}
@@ -455,7 +455,7 @@
Future<void> test_unqualified_instance_asStatement() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
test;
}
}
@@ -464,7 +464,7 @@
class A {
get test => null;
- main() {
+ void f() {
test;
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
index c8884f9..97f550f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
@@ -118,7 +118,7 @@
await resolveTestCode('''
mixin M {}
-main() {
+void f() {
M.myUndefinedMethod();
}
''');
@@ -127,7 +127,7 @@
static void myUndefinedMethod() {}
}
-main() {
+void f() {
M.myUndefinedMethod();
}
''');
@@ -136,14 +136,14 @@
Future<void> test_createUnqualified() async {
await resolveTestCode('''
mixin M {
- main() {
+ void f() {
myUndefinedMethod();
}
}
''');
await assertHasFix('''
mixin M {
- main() {
+ void f() {
myUndefinedMethod();
}
@@ -210,7 +210,7 @@
Future<void> test_createQualified_emptyClassBody() async {
await resolveTestCode('''
class A {}
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -218,7 +218,7 @@
class A {
static void myUndefinedMethod() {}
}
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -228,7 +228,7 @@
await resolveTestCode('''
class A {
}
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -236,7 +236,7 @@
class A {
static void myUndefinedMethod() {}
}
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -247,7 +247,7 @@
class A {
foo() {}
}
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -257,7 +257,7 @@
static void myUndefinedMethod() {}
}
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -284,7 +284,7 @@
Future<void> test_createQualified_targetIsFunctionType() async {
await resolveTestCode('''
typedef A();
-main() {
+void f() {
A.myUndefinedMethod();
}
''');
@@ -293,7 +293,7 @@
Future<void> test_createQualified_targetIsUnresolved() async {
await resolveTestCode('''
-main() {
+void f() {
NoSuchClass.myUndefinedMethod();
}
''');
@@ -328,14 +328,14 @@
Future<void> test_createUnqualified_parameters() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
myUndefinedMethod(0, 1.0, '3');
}
}
''');
await assertHasFix('''
class A {
- main() {
+ void f() {
myUndefinedMethod(0, 1.0, '3');
}
@@ -371,14 +371,14 @@
Future<void> test_createUnqualified_parameters_named() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
myUndefinedMethod(0, bbb: 1.0, ccc: '2');
}
}
''');
await assertHasFix('''
class A {
- main() {
+ void f() {
myUndefinedMethod(0, bbb: 1.0, ccc: '2');
}
@@ -412,7 +412,7 @@
Future<void> test_createUnqualified_returnType() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
int v = myUndefinedMethod();
print(v);
}
@@ -420,7 +420,7 @@
''');
await assertHasFix('''
class A {
- main() {
+ void f() {
int v = myUndefinedMethod();
print(v);
}
@@ -452,14 +452,14 @@
Future<void> test_createUnqualified_staticFromMethod() async {
await resolveTestCode('''
class A {
- static main() {
+ static void f() {
myUndefinedMethod();
}
}
''');
await assertHasFix('''
class A {
- static main() {
+ static void f() {
myUndefinedMethod();
}
@@ -607,7 +607,7 @@
class A<T> {
B b = B();
Map<int, T> items = {};
- main() {
+ void f() {
b.process(items);
}
}
@@ -619,7 +619,7 @@
class A<T> {
B b = B();
Map<int, T> items = {};
- main() {
+ void f() {
b.process(items);
}
}
@@ -635,7 +635,7 @@
class A {
B b = B();
List<int> items = [];
- main() {
+ void f() {
b.process(items);
}
}
@@ -646,7 +646,7 @@
class A {
B b = B();
List<int> items = [];
- main() {
+ void f() {
b.process(items);
}
}
@@ -661,7 +661,7 @@
await resolveTestCode('''
class A<T> {
List<T> items = [];
- main() {
+ void f() {
process(items);
}
}
@@ -669,7 +669,7 @@
await assertHasFix('''
class A<T> {
List<T> items = [];
- main() {
+ void f() {
process(items);
}
@@ -681,7 +681,7 @@
Future<void> test_generic_returnType() async {
await resolveTestCode('''
class A<T> {
- main() {
+ void f() {
T t = new B().compute();
print(t);
}
@@ -692,7 +692,7 @@
''');
await assertHasFix('''
class A<T> {
- main() {
+ void f() {
T t = new B().compute();
print(t);
}
@@ -708,7 +708,7 @@
await resolveTestCode('''
class A {
}
-main() {
+void f() {
var a = new A();
a.myUndefinedMethod();
}
@@ -717,7 +717,7 @@
class A {
void myUndefinedMethod() {}
}
-main() {
+void f() {
var a = new A();
a.myUndefinedMethod();
}
@@ -726,7 +726,7 @@
Future<void> test_inSDK() async {
await resolveTestCode('''
-main() {
+void f() {
List.foo();
}
''');
@@ -862,7 +862,7 @@
Future<void> test_targetIsEnum() async {
await resolveTestCode('''
enum MyEnum {A, B}
-main() {
+void f() {
MyEnum.foo();
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_setter_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_setter_test.dart
index a383db8..4534817 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_setter_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_setter_test.dart
@@ -44,7 +44,7 @@
Future<void> test_unqualified_instance_assignmentLhs() async {
await resolveTestCode('''
mixin M {
- main() {
+ void f() {
test = 0;
}
}
@@ -53,7 +53,7 @@
mixin M {
set test(int test) {}
- main() {
+ void f() {
test = 0;
}
}
@@ -63,7 +63,7 @@
Future<void> test_unqualified_instance_assignmentRhs() async {
await resolveTestCode('''
mixin M {
- main() {
+ void f() {
test;
}
}
@@ -110,7 +110,7 @@
Future<void> test_inSDK() async {
await resolveTestCode('''
-main(List p) {
+void f(List p) {
p.foo = 0;
}
''');
@@ -311,7 +311,7 @@
await resolveTestCode('''
import 'package:test/a.dart';
-main(A a) {
+void f(A a) {
a.test = 0;
}
''');
@@ -339,7 +339,7 @@
class A {
A get self => this;
}
-main() {
+void f() {
var a = new A();
a.self.test = 0;
}
@@ -350,7 +350,7 @@
set test(int test) {}
}
-main() {
+void f() {
var a = new A();
a.self.test = 0;
}
@@ -380,7 +380,7 @@
Future<void> test_unqualified_instance_assignmentLhs() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
test = 0;
}
}
@@ -389,7 +389,7 @@
class A {
set test(int test) {}
- main() {
+ void f() {
test = 0;
}
}
@@ -399,7 +399,7 @@
Future<void> test_unqualified_instance_assignmentRhs() async {
await resolveTestCode('''
class A {
- main() {
+ void f() {
test;
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/fix_test.dart b/pkg/analysis_server/test/src/services/correction/fix/fix_test.dart
index b66fd12..8a42b59 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/fix_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/fix_test.dart
@@ -21,7 +21,7 @@
Future<void> test_malformedTypeTest() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p i s Null;
}''');
await assertNoExceptions();
diff --git a/pkg/analysis_server/test/src/services/correction/fix/import_library_sdk_test.dart b/pkg/analysis_server/test/src/services/correction/fix/import_library_sdk_test.dart
index 3d52c0e..9490fff 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/import_library_sdk_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/import_library_sdk_test.dart
@@ -23,7 +23,7 @@
Future<void> test_alreadyImported_sdk() async {
await resolveTestCode('''
import 'dart:collection' show HashMap;
-main() {
+void f() {
HashMap? s = null;
LinkedHashMap? f = null;
print('\$s \$f');
@@ -34,14 +34,14 @@
Future<void> test_withClass_asExpression() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p as HashMap;
}
''');
await assertHasFix('''
import 'dart:collection';
-main(p) {
+void f(p) {
p as HashMap;
}
''');
@@ -149,14 +149,14 @@
Future<void> test_withClass_invocationTarget() async {
await resolveTestCode('''
-main() {
+void f() {
Timer.run(null);
}
''');
await assertHasFix('''
import 'dart:async';
-main() {
+void f() {
Timer.run(null);
}
''');
@@ -164,14 +164,14 @@
Future<void> test_withClass_IsExpression() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p is Completer;
}
''');
await assertHasFix('''
import 'dart:async';
-main(p) {
+void f(p) {
p is Completer;
}
''');
@@ -179,7 +179,7 @@
Future<void> test_withClass_itemOfList() async {
await resolveTestCode('''
-main() {
+void f() {
var a = [Completer];
print(a);
}
@@ -187,7 +187,7 @@
await assertHasFix('''
import 'dart:async';
-main() {
+void f() {
var a = [Completer];
print(a);
}
@@ -200,7 +200,7 @@
const MyAnnotation(a, b);
}
@MyAnnotation(int, const [Completer])
-main() {}
+void f() {}
''');
await assertHasFix('''
import 'dart:async';
@@ -209,7 +209,7 @@
const MyAnnotation(a, b);
}
@MyAnnotation(int, const [Completer])
-main() {}
+void f() {}
''', errorFilter: (error) {
return error.errorCode == CompileTimeErrorCode.UNDEFINED_IDENTIFIER;
});
@@ -217,7 +217,7 @@
Future<void> test_withClass_typeAnnotation() async {
await resolveTestCode('''
-main() {
+void f() {
Completer f = null;
print(f);
}
@@ -225,7 +225,7 @@
await assertHasFix('''
import 'dart:async';
-main() {
+void f() {
Completer f = null;
print(f);
}
@@ -234,14 +234,14 @@
Future<void> test_withClass_typeAnnotation_PrefixedIdentifier() async {
await resolveTestCode('''
-main() {
+void f() {
Timer.run;
}
''');
await assertHasFix('''
import 'dart:async';
-main() {
+void f() {
Timer.run;
}
''');
@@ -249,7 +249,7 @@
Future<void> test_withClass_typeArgument() async {
await resolveTestCode('''
-main() {
+void f() {
List<Completer> completers = [];
print(completers);
}
@@ -257,7 +257,7 @@
await assertHasFix('''
import 'dart:async';
-main() {
+void f() {
List<Completer> completers = [];
print(completers);
}
@@ -277,14 +277,14 @@
Future<void> test_withTopLevelVariable() async {
await resolveTestCode('''
-main() {
+void f() {
print(pi);
}
''');
await assertHasFix('''
import 'dart:math';
-main() {
+void f() {
print(pi);
}
''');
@@ -293,14 +293,14 @@
Future<void> test_withTopLevelVariable_annotation() async {
await resolveTestCode('''
@pi
-main() {
+void f() {
}
''');
await assertHasFix('''
import 'dart:math';
@pi
-main() {
+void f() {
}
''');
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
index 5c33251..d9d83cb 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
@@ -23,7 +23,7 @@
Future<void> test_catch_afterCatchAll_catch() async {
await resolveTestCode('''
-main() {
+void f() {
try {
} catch (e) {
print('a');
@@ -33,7 +33,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
try {
} catch (e) {
print('a');
@@ -44,7 +44,7 @@
Future<void> test_catch_afterCatchAll_on() async {
await resolveTestCode('''
-main() {
+void f() {
try {
} on Object {
print('a');
@@ -54,7 +54,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
try {
} on Object {
print('a');
@@ -67,7 +67,7 @@
await resolveTestCode('''
class A {}
class B extends A {}
-main() {
+void f() {
try {
} on A {
print('a');
@@ -79,7 +79,7 @@
await assertHasFix('''
class A {}
class B extends A {}
-main() {
+void f() {
try {
} on A {
print('a');
@@ -107,14 +107,14 @@
Future<void> test_statements_one() async {
await resolveTestCode('''
-int main() {
+int f() {
print(0);
return 42;
print(1);
}
''');
await assertHasFix('''
-int main() {
+int f() {
print(0);
return 42;
}
@@ -123,7 +123,7 @@
Future<void> test_statements_two() async {
await resolveTestCode('''
-int main() {
+int f() {
print(0);
return 42;
print(1);
@@ -131,7 +131,7 @@
}
''');
await assertHasFix('''
-int main() {
+int f() {
print(0);
return 42;
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart
index 57bfd6c..c0805e5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart
@@ -23,7 +23,7 @@
Future<void> test_assignment_all() async {
await resolveTestCode('''
-main(Object p, Object q) {
+void f(Object p, Object q) {
if (p is String) {
String v = ((p as String));
print(v);
@@ -35,7 +35,7 @@
}
''');
await assertHasFixAllFix(HintCode.UNNECESSARY_CAST, '''
-main(Object p, Object q) {
+void f(Object p, Object q) {
if (p is String) {
String v = p;
print(v);
@@ -56,7 +56,7 @@
Future<void> test_assignment() async {
await resolveTestCode('''
-main(Object p) {
+void f(Object p) {
if (p is String) {
String v = ((p as String));
print(v);
@@ -64,7 +64,7 @@
}
''');
await assertHasFix('''
-main(Object p) {
+void f(Object p) {
if (p is String) {
String v = p;
print(v);
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart
new file mode 100644
index 0000000..2304921
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2021, 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:analysis_server/src/services/correction/fix.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'bulk/bulk_fix_processor.dart';
+import 'fix_processor.dart';
+
+void main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveUnnecessaryStringEscapeBulkTest);
+ defineReflectiveTests(RemoveUnnecessaryStringEscapeTest);
+ });
+}
+
+@reflectiveTest
+class RemoveUnnecessaryStringEscapeBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_string_escapes;
+
+ Future<void> test_in_file() async {
+ await resolveTestCode(r'''
+var a = '\a\c\e';
+''');
+ await assertHasFix('''
+var a = 'ace';
+''');
+ }
+}
+
+@reflectiveTest
+class RemoveUnnecessaryStringEscapeTest extends FixProcessorLintTest {
+ @override
+ FixKind get kind => DartFixKind.REMOVE_UNNECESSARY_STRING_ESCAPE;
+
+ @override
+ String get lintCode => LintNames.unnecessary_string_escapes;
+
+ Future<void> test_letter() async {
+ await resolveTestCode(r'''
+var a = '\a';
+''');
+ await assertHasFix('''
+var a = 'a';
+''');
+ }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart
index 154a433..dcbf510 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_element_test.dart
@@ -37,7 +37,7 @@
Future<void> test_class_notUsed_isExpression() async {
await resolveTestCode(r'''
class _A {}
-main(p) {
+void f(p) {
if (p is _A) {
}
}
@@ -67,12 +67,12 @@
Future<void> test_functionLocal_notUsed_noReference() async {
await resolveTestCode(r'''
-main() {
+void f() {
f() {}
}
''');
await assertHasFix(r'''
-main() {
+void f() {
}
''');
}
@@ -80,11 +80,11 @@
Future<void> test_functionTop_notUsed_noReference() async {
await resolveTestCode(r'''
_f() {}
-main() {
+void f() {
}
''');
await assertHasFix(r'''
-main() {
+void f() {
}
''');
}
@@ -92,11 +92,11 @@
Future<void> test_functionTypeAlias_notUsed_noReference() async {
await resolveTestCode(r'''
typedef _F(a, b);
-main() {
+void f() {
}
''');
await assertHasFix(r'''
-main() {
+void f() {
}
''');
}
@@ -186,7 +186,7 @@
Future<void> test_topLevelVariable_notUsed() async {
await resolveTestCode(r'''
int _a = 1;
-main() {
+void f() {
_a = 2;
}
''');
@@ -215,10 +215,10 @@
Future<void> test_topLevelVariable_notUsed_noReference_only() async {
await resolveTestCode(r'''
int _a = 1;
-main() {}
+void f() {}
''');
await assertHasFix(r'''
-main() {}
+void f() {}
''');
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
index 1aa08ac..e582716 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
@@ -25,7 +25,7 @@
Future<void> test_localVariable() async {
await resolveTestCode('''
-main() {
+void f() {
int my_integer_variable = 42;
int foo = 0;
print(my_integer_variable);
@@ -33,7 +33,7 @@
}
''');
await assertHasFix('''
-main() {
+void f() {
int myIntegerVariable = 42;
int foo = 0;
print(myIntegerVariable);
@@ -44,14 +44,14 @@
Future<void> test_parameter_closure() async {
await resolveTestCode('''
-main() {
+void f() {
[0, 1, 2].forEach((my_integer_variable) {
print(my_integer_variable);
});
}
''');
await assertHasFix('''
-main() {
+void f() {
[0, 1, 2].forEach((myIntegerVariable) {
print(myIntegerVariable);
});
@@ -75,14 +75,14 @@
Future<void> test_parameter_method() async {
await resolveTestCode('''
class A {
- main(int my_integer_variable) {
+ void f(int my_integer_variable) {
print(my_integer_variable);
}
}
''');
await assertHasFix('''
class A {
- main(int myIntegerVariable) {
+ void f(int myIntegerVariable) {
print(myIntegerVariable);
}
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_null_aware_test.dart
index 0196167..282e085 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_null_aware_test.dart
@@ -24,12 +24,12 @@
Future<void> test_chain() async {
await resolveTestCode('''
-main(x) {
+void f(x) {
x?.a.b.c;
}
''');
await assertHasFix('''
-main(x) {
+void f(x) {
x?.a?.b?.c;
}
''');
@@ -37,12 +37,12 @@
Future<void> test_methodInvocation() async {
await resolveTestCode('''
-main(x) {
+void f(x) {
x?.a.b();
}
''');
await assertHasFix('''
-main(x) {
+void f(x) {
x?.a?.b();
}
''');
@@ -50,12 +50,12 @@
Future<void> test_propertyAccess() async {
await resolveTestCode('''
-main(x) {
+void f(x) {
x?.a().b;
}
''');
await assertHasFix('''
-main(x) {
+void f(x) {
x?.a()?.b;
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
index ece1e25..75962a3 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
@@ -12,6 +12,7 @@
as add_diagnostic_property_reference;
import 'add_explicit_cast_test.dart' as add_explicit_cast;
import 'add_field_formal_parameters_test.dart' as add_field_formal_parameters;
+import 'add_key_to_constructors_test.dart' as add_key_to_constructors;
import 'add_late_test.dart' as add_late;
import 'add_missing_enum_case_clauses_test.dart'
as add_missing_enum_case_clauses;
@@ -138,6 +139,8 @@
import 'remove_unnecessary_new_test.dart' as remove_unnecessary_new;
import 'remove_unnecessary_parentheses_test.dart'
as remove_unnecessary_parentheses;
+import 'remove_unnecessary_string_escapes_test.dart'
+ as remove_unnecessary_string_escapes;
import 'remove_unnecessary_string_interpolation_test.dart'
as remove_unnecessary_string_interpolation;
import 'remove_unused_catch_clause_test.dart' as remove_unused_catch_clause;
@@ -193,6 +196,7 @@
add_diagnostic_property_reference.main();
add_explicit_cast.main();
add_field_formal_parameters.main();
+ add_key_to_constructors.main();
add_late.main();
add_missing_enum_case_clauses.main();
add_missing_enum_like_case_clauses.main();
@@ -304,6 +308,7 @@
remove_unnecessary_const.main();
remove_unnecessary_new.main();
remove_unnecessary_parentheses.main();
+ remove_unnecessary_string_escapes.main();
remove_unnecessary_string_interpolation.main();
remove_unused_catch_clause.main();
remove_unused_catch_stack.main();
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart
index 2e53d54..911281c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart
@@ -23,13 +23,13 @@
Future<void> test_isNull_all() async {
await resolveTestCode('''
-main(p, q) {
+void f(p, q) {
p is Null;
q is Null;
}
''');
await assertHasFixAllFix(HintCode.TYPE_CHECK_IS_NULL, '''
-main(p, q) {
+void f(p, q) {
p == null;
q == null;
}
@@ -44,12 +44,12 @@
Future<void> test_isNull() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p is Null;
}
''');
await assertHasFix('''
-main(p) {
+void f(p) {
p == null;
}
''');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart
index fdd7d12..70a9bae 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart
@@ -23,13 +23,13 @@
Future<void> test_isNotNull_all() async {
await resolveTestCode('''
-main(p, q) {
+void f(p, q) {
p is! Null;
q is! Null;
}
''');
await assertHasFixAllFix(HintCode.TYPE_CHECK_IS_NOT_NULL, '''
-main(p, q) {
+void f(p, q) {
p != null;
q != null;
}
@@ -44,12 +44,12 @@
Future<void> test_isNotNull() async {
await resolveTestCode('''
-main(p) {
+void f(p) {
p is! Null;
}
''');
await assertHasFix('''
-main(p) {
+void f(p) {
p != null;
}
''');
diff --git a/pkg/analysis_server/test/src/utilities/flutter_test.dart b/pkg/analysis_server/test/src/utilities/flutter_test.dart
index efdff5a..4b35f0a 100644
--- a/pkg/analysis_server/test/src/utilities/flutter_test.dart
+++ b/pkg/analysis_server/test/src/utilities/flutter_test.dart
@@ -105,7 +105,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
new MyWidget(1234);
new MyWidget.named(5678);
}
@@ -116,8 +116,8 @@
Widget build(BuildContext context) => null;
}
''');
- var main = testUnit.declarations[0] as FunctionDeclaration;
- var body = main.functionExpression.body as BlockFunctionBody;
+ var f = testUnit.declarations[0] as FunctionDeclaration;
+ var body = f.functionExpression.body as BlockFunctionBody;
var statements = body.block.statements;
// new MyWidget(1234);
@@ -161,7 +161,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
createEmptyText();
createText('xyz');
}
@@ -192,7 +192,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
new Container(child: new Text(''));
}
@@ -211,7 +211,7 @@
Widget bar;
}
-main(Foo foo) {
+void f(Foo foo) {
foo.bar; // ref
}
''');
@@ -228,7 +228,7 @@
Widget bar;
}
-main(Foo foo) {
+void f(Foo foo) {
foo.bar; // ref
}
''');
@@ -240,7 +240,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(Widget widget) {
+void f(Widget widget) {
widget; // ref
}
''');
@@ -252,7 +252,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
var intVariable = 42;
intVariable;
}
@@ -275,7 +275,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
var text = new Text('abc');
useWidget(text); // ref
}
@@ -291,7 +291,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
Widget text;
text = Text('abc');
}
@@ -322,7 +322,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(bool condition, Widget w1, Widget w2) {
+void f(bool condition, Widget w1, Widget w2) {
condition ? w1 : w2;
}
''');
@@ -338,7 +338,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(Widget widget) => widget; // ref
+void f(Widget widget) => widget; // ref
''');
var expression = findNode.simple('widget; // ref');
expect(_flutter.identifyWidgetExpression(expression), expression);
@@ -349,7 +349,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(Widget widget) {
+void f(Widget widget) {
widget; // ref
}
''');
@@ -361,7 +361,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(bool b) {
+void f(bool b) {
[
for (var v in [0, 1, 2]) Container()
];
@@ -377,7 +377,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(bool b) {
+void f(bool b) {
[
if (b)
Text('then')
@@ -399,7 +399,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(Widget widget) {
+List<Widget> f(Widget widget) {
return [widget]; // ref
}
''');
@@ -411,7 +411,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
var text = new Text('abc');
useWidget(child: text); // ref
}
@@ -426,7 +426,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main(Widget widget) {
+Widget f(Widget widget) {
return widget; // ref
}
''');
@@ -480,7 +480,7 @@
await resolveTestCode('''
import 'package:flutter/widgets.dart';
-main() {
+void f() {
MyWidget.named(); // use
var text = new Text('abc');
text;
diff --git a/pkg/analyzer/lib/dart/element/type_provider.dart b/pkg/analyzer/lib/dart/element/type_provider.dart
index fd72800..752df98 100644
--- a/pkg/analyzer/lib/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/dart/element/type_provider.dart
@@ -31,11 +31,13 @@
/// Return the type representing the built-in type `dynamic`.
DartType get dynamicType;
- /// Return the element representing the built-in type `Enum`.
- ClassElement get enumElement;
+ /// Return the element representing the built-in type `Enum`, or `null` if
+ /// the SDK does not have definition of `Enum`.
+ ClassElement? get enumElement;
- /// Return the type representing the built-in type `Enum`.
- InterfaceType get enumType;
+ /// Return the type representing the built-in type `Enum`, or `null` if
+ /// the SDK does not have definition of `Enum`.
+ InterfaceType? get enumType;
/// Return the type representing the built-in type `Function`.
InterfaceType get functionType;
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index abd2d98..d5c7fbb 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -2701,8 +2701,10 @@
bool get hasStaticMember => true;
@override
- List<InterfaceType> get interfaces =>
- <InterfaceType>[library.typeProvider.enumType];
+ List<InterfaceType> get interfaces {
+ var enumType = library.typeProvider.enumType;
+ return enumType != null ? <InterfaceType>[enumType] : const [];
+ }
@override
bool get isAbstract => false;
diff --git a/pkg/analyzer/lib/src/dart/element/type_provider.dart b/pkg/analyzer/lib/src/dart/element/type_provider.dart
index 6f29133..948b8c448 100644
--- a/pkg/analyzer/lib/src/dart/element/type_provider.dart
+++ b/pkg/analyzer/lib/src/dart/element/type_provider.dart
@@ -103,6 +103,9 @@
/// If `false`, then legacy types are returned.
final bool isNonNullableByDefault;
+ bool _hasEnumElement = false;
+ bool _hasEnumType = false;
+
ClassElement? _boolElement;
ClassElement? _doubleElement;
ClassElement? _enumElement;
@@ -223,13 +226,28 @@
DartType get dynamicType => DynamicTypeImpl.instance;
@override
- ClassElement get enumElement {
- return _enumElement ??= _getClassElement(_coreLibrary, "Enum");
+ ClassElement? get enumElement {
+ if (!_hasEnumElement) {
+ _hasEnumElement = true;
+ _enumElement = _coreLibrary.getType('Enum');
+ }
+ return _enumElement;
}
@override
- InterfaceType get enumType {
- return _enumType ??= _getType(_coreLibrary, "Enum");
+ InterfaceType? get enumType {
+ if (!_hasEnumType) {
+ _hasEnumType = true;
+ var element = enumElement;
+ if (element != null) {
+ _enumType = InterfaceTypeImpl(
+ element: element,
+ typeArguments: const [],
+ nullabilitySuffix: _nullabilitySuffix,
+ );
+ }
+ }
+ return _enumType;
}
@override
diff --git a/pkg/analyzer/lib/src/dart/error/hint_codes.dart b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
index 878e7c7..7f845f6 100644
--- a/pkg/analyzer/lib/src/dart/error/hint_codes.dart
+++ b/pkg/analyzer/lib/src/dart/error/hint_codes.dart
@@ -309,6 +309,30 @@
/**
* No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the class `Function` is used in
+ // either the `extends`, `implements`, or `with` clause of a class or mixin.
+ // Using the class `Function` in this way has no semantic value, so it's
+ // effectively dead code.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `Function` is used as
+ // the superclass of `F`:
+ //
+ // ```dart
+ // class F extends [!Function!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the class `Function` from whichever clause it's in, and remove the
+ // whole clause if `Function` is the only type in the clause:
+ //
+ // ```dart
+ // class F {}
+ // ```
static const HintCode DEPRECATED_EXTENDS_FUNCTION = HintCode(
'DEPRECATED_SUBTYPE_OF_FUNCTION', "Extending 'Function' is deprecated.",
correction: "Try removing 'Function' from the 'extends' clause.",
@@ -742,12 +766,82 @@
correction: "Try using a package: URI instead.");
/**
- * Deferred libraries shouldn't define a top level function 'loadLibrary'.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a library that declares a
+ // function named `loadLibrary` is imported using a deferred import. A
+ // deferred import introduces an implicit function named `loadLibrary`. This
+ // function is used to load the contents of the deferred library, and the
+ // implicit function hides the explicit declaration in the deferred library.
+ //
+ // For more information, see the language tour's coverage of
+ // [deferred loading](https://dart.dev/guides/language/language-tour#lazily-loading-a-library).
+ //
+ // #### Example
+ //
+ // Given a file (`a.dart`) that defines a function named `loadLibrary`:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // void loadLibrary(Library library) {}
+ //
+ // class Library {}
+ // ```
+ //
+ // The following code produces this diagnostic because the implicit
+ // declaration of `a.loadLibrary` is hiding the explicit declaration of
+ // `loadLibrary` in `a.dart`:
+ //
+ // ```dart
+ // [!import 'a.dart' deferred as a;!]
+ //
+ // void f() {
+ // a.Library();
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the imported library isn't required to be deferred, then remove the
+ // keyword `deferred`:
+ //
+ // ```dart
+ // import 'a.dart' as a;
+ //
+ // void f() {
+ // a.Library();
+ // }
+ // ```
+ //
+ // If the imported library is required to be deferred and you need to
+ // reference the imported function, then rename the function in the imported
+ // library:
+ //
+ // ```dart
+ // void populateLibrary(Library library) {}
+ //
+ // class Library {}
+ // ```
+ //
+ // If the imported library is required to be deferred and you don't need to
+ // reference the imported function, then add a `hide` clause:
+ //
+ // ```dart
+ // import 'a.dart' deferred as a hide loadLibrary;
+ //
+ // void f() {
+ // a.Library();
+ // }
+ // ```
+ //
+ // If type arguments shouldn't be required for the class, then mark the class
+ // with the `@optionalTypeArgs` annotation (from `package:meta`):
static const HintCode IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION = HintCode(
'IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION',
- "The library '{0}' defines a top-level function named 'loadLibrary' "
- "which is hidden by deferring this library.",
+ "The imported library defines a top-level function named 'loadLibrary' "
+ "that is hidden by deferring this library.",
correction: "Try changing the import to not be deferred, or "
"rename the function in the imported library.");
@@ -2620,20 +2714,111 @@
correction: "Use explicit type arguments for '{0}'.");
/**
- * This hint is generated anywhere where a `@sealed` class or mixin is used as
- * a super-type of a class.
+ * Parameters:
+ * 0: the name of the sealed class
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a sealed class (one that either
+ // has the `@sealed` annotation or inherits or mixes in a sealed class) is
+ // referenced in either the `extends`, `implements`, or `with` clause of a
+ // class or mixin declaration if the declaration isn't in the same package as
+ // the sealed class.
+ //
+ // #### Example
+ //
+ // Given a library in a package other than the package being analyzed that
+ // contains the following:
+ //
+ // ```dart
+ // %uri="package:a/a.dart"
+ // import 'package:meta/meta.dart';
+ //
+ // class A {}
+ //
+ // @sealed
+ // class B {}
+ // ```
+ //
+ // The following code produces this diagnostic because `C`, which isn't in the
+ // same package as `B`, is extending the sealed class `B`:
+ //
+ // ```dart
+ // import 'package:a/a.dart';
+ //
+ // [!class C extends B {}!]
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the class doesn't need to be a subtype of the sealed class, then change
+ // the declaration so that it isn't:
+ //
+ // ```dart
+ // import 'package:a/a.dart';
+ //
+ // class B extends A {}
+ // ```
+ //
+ // If the class needs to be a subtype of the sealed class, then either change
+ // the sealed class so that it's no longer sealed or move the subclass into
+ // the same package as the sealed class.
static const HintCode SUBTYPE_OF_SEALED_CLASS = HintCode(
'SUBTYPE_OF_SEALED_CLASS',
"The class '{0}' shouldn't be extended, mixed in, or implemented because "
- "it is sealed.",
+ "it's sealed.",
correction:
- "Try composing instead of inheriting, or refer to its documentation "
- "for more information.");
+ "Try composing instead of inheriting, or refer to the documentation "
+ "of '{0}' for more information.");
/**
- * Type checks of the type `x is! Null` should be done with `x != null`.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's a type check (using the
+ // `as` operator) where the type is `Null`. There's only one value whose type
+ // is `Null`, so the code is both more readable and more performant when it
+ // tests for `null` explicitly.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the code is testing to
+ // see whether the value of `s` is `null` by using a type check:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if ([!s is Null!]) {
+ // return;
+ // }
+ // print(s);
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the code is testing to
+ // see whether the value of `s` is something other than `null` by using a type
+ // check:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if ([!s is! Null!]) {
+ // print(s);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the type check with the equivalent comparison with `null`:
+ //
+ // ```dart
+ // void f(String? s) {
+ // if (s == null) {
+ // return;
+ // }
+ // print(s);
+ // }
+ // ```
static const HintCode TYPE_CHECK_IS_NOT_NULL = HintCode(
'TYPE_CHECK_WITH_NULL',
"Tests for non-null should be done with '!= null'.",
@@ -2641,7 +2826,7 @@
uniqueName: 'TYPE_CHECK_IS_NOT_NULL');
/**
- * Type checks of the type `x is Null` should be done with `x == null`.
+ * No parameters.
*/
static const HintCode TYPE_CHECK_IS_NULL = HintCode(
'TYPE_CHECK_WITH_NULL', "Tests for null should be done with '== null'.",
@@ -2786,8 +2971,51 @@
correction: 'Try removing the import directive.');
/**
- * Unnecessary `noSuchMethod` declaration.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's a declaration of
+ // `noSuchMethod`, the only thing the declaration does is invoke the
+ // overridden declaration, and the overridden declaration isn't the
+ // declaration in `Object`.
+ //
+ // Overriding the implementation of `Object`'s `noSuchMethod` (no matter what
+ // the implementation does) signals to the analyzer that it shouldn't flag any
+ // inherited abstract methods that aren't implemented in that class. This
+ // works even if the overriding implementation is inherited from a superclass,
+ // so there's no value to declare it again in a subclass.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the declaration of
+ // `noSuchMethod` in `A` makes the declaration of `noSuchMethod` in `B`
+ // unnecessary:
+ //
+ // ```dart
+ // class A {
+ // @override
+ // dynamic noSuchMethod(x) => super.noSuchMethod(x);
+ // }
+ // class B extends A {
+ // @override
+ // dynamic [!noSuchMethod!](y) {
+ // return super.noSuchMethod(y);
+ // }
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the unnecessary declaration:
+ //
+ // ```dart
+ // class A {
+ // @override
+ // dynamic noSuchMethod(x) => super.noSuchMethod(x);
+ // }
+ // class B extends A {}
+ // ```
static const HintCode UNNECESSARY_NO_SUCH_METHOD = HintCode(
'UNNECESSARY_NO_SUCH_METHOD', "Unnecessary 'noSuchMethod' declaration.",
correction: "Try removing the declaration of 'noSuchMethod'.");
diff --git a/pkg/analyzer/lib/src/error/codes.dart b/pkg/analyzer/lib/src/error/codes.dart
index 7f671fd..aae8a23 100644
--- a/pkg/analyzer/lib/src/error/codes.dart
+++ b/pkg/analyzer/lib/src/error/codes.dart
@@ -1722,13 +1722,31 @@
"Try renaming the member to a name that doesn't conflict.");
/**
- * 7. Classes: It is a compile time error if a generic class declares a type
- * variable with the same name as the class or any of its members or
- * constructors.
- *
* Parameters:
* 0: the name of the type variable
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class, mixin, or extension
+ // declaration declares a type parameter with the same name as the class,
+ // mixin, or extension that declares it.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type parameter `C`
+ // has the same name as the class `C` of which it's a part:
+ //
+ // ```dart
+ // class C<[!C!]> {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rename either the type parameter, or the class, mixin, or extension:
+ //
+ // ```dart
+ // class C<T> {}
+ // ```
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_CLASS =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_CONTAINER',
@@ -1739,9 +1757,6 @@
);
/**
- * It is a compile time error if an extension declares a type parameter with
- * the same name as the extension.
- *
* Parameters:
* 0: the name of the type variable
*/
@@ -1755,13 +1770,35 @@
);
/**
- * 7. Classes: It is a compile time error if a generic class declares a type
- * variable with the same name as the class or any of its members or
- * constructors.
- *
* Parameters:
* 0: the name of the type variable
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a class, mixin, or extension
+ // declaration declares a type parameter with the same name as one of the
+ // members of the class, mixin, or extension that declares it.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type parameter `T`
+ // has the same name as the field `T`:
+ //
+ // ```dart
+ // class C<[!T!]> {
+ // int T = 0;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Rename either the type parameter or the member with which it conflicts:
+ //
+ // ```dart
+ // class C<T> {
+ // int total = 0;
+ // }
+ // ```
static const CompileTimeErrorCode CONFLICTING_TYPE_VARIABLE_AND_MEMBER_CLASS =
CompileTimeErrorCode(
'CONFLICTING_TYPE_VARIABLE_AND_MEMBER',
@@ -1785,8 +1822,8 @@
);
/**
- * It is a compile time error if a generic extension declares a member with
- * the same basename as the name of any of the extension's type parameters.
+ * Parameters:
+ * 0: the name of the type variable
*/
static const CompileTimeErrorCode
CONFLICTING_TYPE_VARIABLE_AND_MEMBER_EXTENSION = CompileTimeErrorCode(
@@ -1824,8 +1861,8 @@
/**
* Parameters:
- * 0: The type of the runtime value of the argument
- * 1: The static type of the parameter
+ * 0: the type of the runtime value of the argument
+ * 1: the static type of the parameter
*/
// #### Description
//
@@ -3727,7 +3764,7 @@
/**
* Parameters:
- * 0: The name of the disallowed type
+ * 0: the name of the disallowed type
*/
// #### Description
//
@@ -4954,9 +4991,9 @@
/**
* Parameters:
- * 0: The type of the iterable expression.
- * 1: The sequence type -- Iterable for `for` or Stream for `await for`.
- * 2: The loop variable type.
+ * 0: the type of the iterable expression.
+ * 1: the sequence type -- Iterable for `for` or Stream for `await for`.
+ * 2: the loop variable type.
*/
// #### Description
//
@@ -5010,8 +5047,8 @@
/**
* Parameters:
- * 0: The type of the iterable expression.
- * 1: The sequence type -- Iterable for `for` or Stream for `await for`.
+ * 0: the type of the iterable expression.
+ * 1: the sequence type -- Iterable for `for` or Stream for `await for`.
*/
// #### Description
//
@@ -5341,7 +5378,7 @@
/**
* Parameters:
- * 0: The name of the disallowed type
+ * 0: the name of the disallowed type
*/
static const CompileTimeErrorCode IMPLEMENTS_DISALLOWED_CLASS =
CompileTimeErrorCode(
@@ -6120,20 +6157,49 @@
correction: "Try replacing it with a class.");
/**
- * An integer literal with static type `double` and numeric value `i`
- * evaluates to an instance of the `double` class representing the value `i`.
- * It is a compile-time error if the value `i` cannot be represented
- * _precisely_ by the an instace of `double`.
+ * Parameters:
+ * 0: the lexeme of the integer
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an integer literal is being
+ // implicitly converted to a double, but can't be represented as a 64-bit
+ // double without overflow or loss of precision. Integer literals are
+ // implicitly converted to a double if the context requires the type `double`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the integer value
+ // `9223372036854775807` can't be represented exactly as a double:
+ //
+ // ```dart
+ // double x = [!9223372036854775807!];
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to use the exact value, then use the class `BigInt` to
+ // represent the value:
+ //
+ // ```dart
+ // var x = BigInt.parse('9223372036854775807');
+ // ```
+ //
+ // If you need to use a double, then change the value to one that can be
+ // represented exactly:
+ //
+ // ```dart
+ // double x = 9223372036854775808;
+ // ```
static const CompileTimeErrorCode INTEGER_LITERAL_IMPRECISE_AS_DOUBLE =
CompileTimeErrorCode(
'INTEGER_LITERAL_IMPRECISE_AS_DOUBLE',
"The integer literal is being used as a double, but can't be "
- "represented as a 64 bit double without overflow and/or loss of "
- "precision: {0}",
+ "represented as a 64-bit double without overflow or loss of "
+ "precision: '{0}'.",
correction:
- "Try using the BigInt class, or switch to the closest valid "
- "double: {1}");
+ "Try using the class 'BigInt', or switch to the closest valid "
+ "double: '{1}'.");
/**
* No parameters.
@@ -8374,7 +8440,7 @@
/**
* Parameters:
- * 0: The name of the disallowed type
+ * 0: the name of the disallowed type
*/
static const CompileTimeErrorCode MIXIN_OF_DISALLOWED_CLASS =
CompileTimeErrorCode(
@@ -8449,7 +8515,7 @@
/**
* Parameters:
- * 0: The name of the disallowed type
+ * 0: the name of the disallowed type
*/
static const CompileTimeErrorCode
MIXIN_SUPER_CLASS_CONSTRAINT_DISALLOWED_CLASS = CompileTimeErrorCode(
@@ -10870,7 +10936,7 @@
/**
* Parameters:
- * 0: The name of the prefix
+ * 0: the name of the prefix
*/
// #### Description
//
@@ -10918,7 +10984,7 @@
/**
* Parameters:
- * 0: The name of the prefix
+ * 0: the name of the prefix
*/
// #### Description
//
@@ -10983,9 +11049,54 @@
"Try renaming either the prefix or the local declaration.");
/**
- * It is an error for a mixin to add a private name that conflicts with a
- * private name added by a superclass or another mixin.
+ * Parameters:
+ * 0: the private name that collides
+ * 1: the name of the first mixin
+ * 2: the name of the second mixin
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when two mixins that define the same
+ // private member are used together in a single class in a library other than
+ // the one that defines the mixins.
+ //
+ // #### Example
+ //
+ // Given a file named `a.dart` containing the following code:
+ //
+ // ```dart
+ // %uri="lib/a.dart"
+ // class A {
+ // void _foo() {}
+ // }
+ //
+ // class B {
+ // void _foo() {}
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because the classes `A` and `B`
+ // both define the method `_foo`:
+ //
+ // ```dart
+ // import 'a.dart';
+ //
+ // class C extends Object with A, [!B!] {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you don't need both of the mixins, then remove one of them from the
+ // `with` clause:
+ //
+ // ```dart
+ // import 'a.dart';
+ //
+ // class C extends Object with A, [!B!] {}
+ // ```
+ //
+ // If you need both of the mixins, then rename the conflicting member in one
+ // of the two mixins.
static const CompileTimeErrorCode PRIVATE_COLLISION_IN_MIXIN_APPLICATION =
CompileTimeErrorCode(
'PRIVATE_COLLISION_IN_MIXIN_APPLICATION',
@@ -12291,8 +12402,8 @@
/**
* Parameters:
- * 0: The static type of the switch expression
- * 1: The static type of the case expressions
+ * 0: the static type of the switch expression
+ * 1: the static type of the case expressions
*/
// #### Description
//
@@ -12437,9 +12548,32 @@
"cycle in order to break the cycle.");
/**
- * 15.3.1 Typedef: Any self reference, either directly, or recursively via
- * another typedef, is a compile time error.
+ * No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a typedef refers to itself,
+ // either directly or indirectly.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `F` depends on itself
+ // indirectly through `G`:
+ //
+ // ```dart
+ // typedef [!F!] = void Function(G);
+ // typedef G = void Function(F);
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change one or more of the typedefs in the cycle so that none of them refer
+ // to themselves:
+ //
+ // ```dart
+ // typedef F = void Function(G);
+ // typedef G = void Function(int);
+ // ```
static const CompileTimeErrorCode TYPE_ALIAS_CANNOT_REFERENCE_ITSELF =
CompileTimeErrorCode(
'TYPE_ALIAS_CANNOT_REFERENCE_ITSELF',
@@ -12583,19 +12717,56 @@
hasPublishedDocs: true);
/**
- * 10 Generics: It is a static type warning if a type parameter is a supertype
- * of its upper bound.
- *
* Parameters:
* 0: the name of the type parameter
* 1: the name of the bounding type
*
* See [CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS].
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the bound of a type parameter
+ // (the type following the `extends` keyword) is either directly or indirectly
+ // the type parameter itself. Stating that the type parameter must be the same
+ // as itself or a subtype of itself or a subtype of itself isn't helpful
+ // because it will always be the same as itself.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the bound of `T` is
+ // `T`:
+ //
+ // ```dart
+ // class C<[!T!] extends T> {}
+ // ```
+ //
+ // The following code produces this diagnostic because the bound of `T1` is
+ // `T2`, and the bound of `T2` is `T1`, effectively making the bound of `T1`
+ // be `T1`:
+ //
+ // ```dart
+ // class C<[!T1!] extends T2, T2 extends T1> {}
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type parameter needs to be a subclass of some type, then replace the
+ // bound with the required type:
+ //
+ // ```dart
+ // class C<T extends num> {}
+ // ```
+ //
+ // If the type parameter can be any type, then remove the `extends` clause:
+ //
+ // ```dart
+ // class C<T> {}
+ // ```
static const CompileTimeErrorCode TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND =
CompileTimeErrorCode('TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND',
"'{0}' can't be a supertype of its upper bound.",
- correction: "Try using a type that is or is a subclass of '{1}'.");
+ correction:
+ "Try using a type that is the same as or a subclass of '{1}'.");
/**
* No parameters.
@@ -14416,13 +14587,52 @@
hasPublishedDocs: true);
/**
- * It will be a static type warning if <i>m</i> is not a generic method with
- * exactly <i>n</i> type parameters.
- *
* Parameters:
* 0: the name of the class being instantiated
* 1: the name of the constructor being invoked
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when type arguments are provided
+ // after the name of a named constructor. Constructors can't declare type
+ // parameters, so invocations can only provide the type arguments associated
+ // with the class, and those type arguments are required to follow the name of
+ // the class rather than the name of the constructor.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the type parameters
+ // (`<String>`) follow the name of the constructor rather than the name of the
+ // class:
+ //
+ // ```dart
+ // class C<T> {
+ // C.named();
+ // }
+ // C f() => C.named[!<String>!]();
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the type arguments are for the class' type parameters, then move the
+ // type arguments to follow the class name:
+ //
+ // ```dart
+ // class C<T> {
+ // C.named();
+ // }
+ // C f() => C<String>.named();
+ // ```
+ //
+ // If the type arguments aren't for the class' type parameters, then remove
+ // them:
+ //
+ // ```dart
+ // class C<T> {
+ // C.named();
+ // }
+ // C f() => C.named();
+ // ```
static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR =
CompileTimeErrorCode('WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR',
"The constructor '{0}.{1}' doesn't have type parameters.",
@@ -14434,6 +14644,42 @@
* 1: the number of type parameters that were declared
* 2: the number of type arguments provided
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an extension that has type
+ // parameters is used and type arguments are provided, but the number of type
+ // arguments isn't the same as the number of type parameters.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the extension `E` is
+ // declared to have a single type parameter (`T`), but the extension override
+ // has two type arguments:
+ //
+ // ```dart
+ // extension E<T> on List<T> {
+ // int get len => length;
+ // }
+ //
+ // void f(List<int> p) {
+ // E[!<int, String>!](p).len;
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the type arguments so that there are the same number of type
+ // arguments as there are type parameters:
+ //
+ // ```dart
+ // extension E<T> on List<T> {
+ // int get len => length;
+ // }
+ //
+ // void f(List<int> p) {
+ // E<int>(p).len;
+ // }
+ // ```
static const CompileTimeErrorCode WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION =
CompileTimeErrorCode(
'WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION',
@@ -14540,11 +14786,45 @@
);
/**
- * ?? Yield: It is a compile-time error if a yield statement appears in a
- * function that is not a generator function.
- *
* No parameters.
*/
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a `yield` or `yield*` statement
+ // appears in a function whose body isn't marked with one of the `async*` or
+ // `sync*` modifiers.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because `yield` is being used
+ // in a function whose body doesn't have a modifier:
+ //
+ // ```dart
+ // Iterable<int> get digits {
+ // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ // }
+ // ```
+ //
+ // The following code produces this diagnostic because `yield*` is being used
+ // in a function whose body has the `async` modifier rather than the `async*`
+ // modifier:
+ //
+ // ```dart
+ // Stream<int> get digits async {
+ // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ // }
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add a modifier, or change the existing modifier to be either `async*` or
+ // `sync*`:
+ //
+ // ```dart
+ // Iterable<int> get digits sync* {
+ // yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ // }
+ // ```
static const CompileTimeErrorCode YIELD_EACH_IN_NON_GENERATOR =
CompileTimeErrorCode(
'YIELD_IN_NON_GENERATOR',
@@ -14824,8 +15104,8 @@
/**
* Parameters:
- * 0: The null-aware operator that is invalid
- * 1: The non-null-aware operator that can replace the invalid operator
+ * 0: the null-aware operator that is invalid
+ * 1: the non-null-aware operator that can replace the invalid operator
*/
// #### Description
//
@@ -14905,8 +15185,8 @@
/**
* Parameters:
- * 0: The null-aware operator that is invalid
- * 1: The non-null-aware operator that can replace the invalid operator
+ * 0: the null-aware operator that is invalid
+ * 1: the non-null-aware operator that can replace the invalid operator
*/
static const StaticWarningCode
INVALID_NULL_AWARE_OPERATOR_AFTER_SHORT_CIRCUIT = StaticWarningCode(
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index b6480b1..a089bf5 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -210,23 +210,10 @@
@override
final TypeSystemImpl typeSystem;
- /// The class declaration representing the class containing the current node,
- /// or `null` if the current node is not contained in a class.
- ClassDeclaration? _enclosingClassDeclaration;
-
- /// The function type alias representing the function type containing the
- /// current node, or `null` if the current node is not contained in a function
- /// type alias.
- FunctionTypeAlias? _enclosingFunctionTypeAlias;
-
/// The element representing the function containing the current node, or
/// `null` if the current node is not contained in a function.
ExecutableElement? _enclosingFunction;
- /// The mixin declaration representing the class containing the current node,
- /// or `null` if the current node is not contained in a mixin.
- MixinDeclaration? _enclosingMixinDeclaration;
-
/// The helper for tracking if the current location has access to `this`.
final ThisAccessTracker _thisAccessTracker = ThisAccessTracker.unit();
@@ -638,7 +625,6 @@
ClassElement? enclosingClassElement,
ExecutableElement? enclosingExecutableElement,
}) {
- _enclosingClassDeclaration = null;
enclosingClass = enclosingClassElement;
_thisType = enclosingClass?.thisType;
_enclosingFunction = enclosingExecutableElement;
@@ -885,12 +871,6 @@
@override
void visitAnnotation(covariant AnnotationImpl node) {
var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
- AstNode parent = node.parent;
- if (identical(parent, _enclosingClassDeclaration) ||
- identical(parent, _enclosingFunctionTypeAlias) ||
- identical(parent, _enclosingMixinDeclaration)) {
- return;
- }
AnnotationResolver(this).resolve(node, whyNotPromotedList);
var arguments = node.arguments;
if (arguments != null) {
@@ -1089,28 +1069,35 @@
@override
void visitClassDeclaration(ClassDeclaration node) {
//
- // Resolve the metadata in the library scope.
- //
- node.metadata.accept(this);
- _enclosingClassDeclaration = node;
- //
// Continue the class resolution.
//
var outerType = enclosingClass;
try {
- enclosingClass = node.declaredElement;
- _thisType = enclosingClass?.thisType;
super.visitClassDeclaration(node);
node.accept(elementResolver);
node.accept(typeAnalyzer);
} finally {
_thisType = outerType?.thisType;
enclosingClass = outerType;
- _enclosingClassDeclaration = null;
}
}
@override
+ void visitClassDeclarationInScope(ClassDeclaration node) {
+ enclosingClass = node.declaredElement;
+ _thisType = enclosingClass?.thisType;
+ super.visitClassDeclarationInScope(node);
+ }
+
+ @override
+ void visitClassTypeAlias(ClassTypeAlias node) {
+ super.visitClassTypeAlias(node);
+ node.accept(elementResolver);
+ // Note: no need to call the typeAnalyzer since it does not override
+ // visitClassTypeAlias.
+ }
+
+ @override
void visitComment(Comment node) {
var parent = node.parent;
if (parent is FunctionDeclaration ||
@@ -1360,11 +1347,6 @@
@override
void visitEnumDeclaration(EnumDeclaration node) {
//
- // Resolve the metadata in the library scope
- // and associate the annotations with the element.
- //
- node.metadata.accept(this);
- //
// Continue the enum resolution.
//
var outerType = enclosingClass;
@@ -1377,7 +1359,6 @@
} finally {
_thisType = outerType?.thisType;
enclosingClass = outerType;
- _enclosingClassDeclaration = null;
}
}
@@ -1409,7 +1390,6 @@
@override
void visitExtensionDeclaration(ExtensionDeclaration node) {
try {
- _thisType = node.declaredElement!.extendedType;
super.visitExtensionDeclaration(node);
node.accept(elementResolver);
node.accept(typeAnalyzer);
@@ -1419,6 +1399,12 @@
}
@override
+ void visitExtensionDeclarationInScope(ExtensionDeclaration node) {
+ _thisType = node.declaredElement!.extendedType;
+ super.visitExtensionDeclarationInScope(node);
+ }
+
+ @override
void visitExtensionOverride(ExtensionOverride node) {
var whyNotPromotedList = <Map<DartType, NonPromotionReason> Function()>[];
node.extensionName.accept(this);
@@ -1498,6 +1484,9 @@
nullSafetyDeadCodeVerifier.flowEnd(node);
_enclosingFunction = outerFunction;
+ node.accept(elementResolver);
+ // Note: no need to call the typeAnalyzer since it does not override
+ // visitFunctionDeclaration
}
@override
@@ -1548,15 +1537,10 @@
@override
void visitFunctionTypeAlias(FunctionTypeAlias node) {
- // Resolve the metadata in the library scope.
- node.metadata.accept(this);
- var outerAlias = _enclosingFunctionTypeAlias;
- _enclosingFunctionTypeAlias = node;
- try {
- super.visitFunctionTypeAlias(node);
- } finally {
- _enclosingFunctionTypeAlias = outerAlias;
- }
+ super.visitFunctionTypeAlias(node);
+ node.accept(elementResolver);
+ // Note: no need to call the typeAnalyzer since it does not override
+ // visitFunctionTypeAlias.
}
@override
@@ -1566,6 +1550,22 @@
}
@override
+ void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
+ super.visitFunctionTypedFormalParameter(node);
+ node.accept(elementResolver);
+ // Note: no need to call the typeAnalyzer since it does not override
+ // visitFunctionTypedFormalParameter.
+ }
+
+ @override
+ void visitGenericTypeAlias(GenericTypeAlias node) {
+ super.visitGenericTypeAlias(node);
+ node.accept(elementResolver);
+ // Note: no need to call the typeAnalyzer since it does not override
+ // visitGenericTypeAlias.
+ }
+
+ @override
void visitGenericTypeAliasInFunctionScope(GenericTypeAlias node) {
super.visitGenericTypeAliasInFunctionScope(node);
safelyVisitComment(node.documentationComment);
@@ -1737,6 +1737,9 @@
nullSafetyDeadCodeVerifier.flowEnd(node);
_enclosingFunction = outerFunction;
+ node.accept(elementResolver);
+ // Note: no need to call the typeAnalyzer since it does not override
+ // visitMethodDeclaration.
}
@override
@@ -1778,28 +1781,27 @@
@override
void visitMixinDeclaration(MixinDeclaration node) {
//
- // Resolve the metadata in the library scope.
- //
- node.metadata.accept(this);
- _enclosingMixinDeclaration = node;
- //
// Continue the class resolution.
//
var outerType = enclosingClass;
try {
- enclosingClass = node.declaredElement;
- _thisType = enclosingClass?.thisType;
super.visitMixinDeclaration(node);
node.accept(elementResolver);
node.accept(typeAnalyzer);
} finally {
_thisType = outerType?.thisType;
enclosingClass = outerType;
- _enclosingMixinDeclaration = null;
}
}
@override
+ void visitMixinDeclarationInScope(MixinDeclaration node) {
+ enclosingClass = node.declaredElement;
+ _thisType = enclosingClass?.thisType;
+ super.visitMixinDeclarationInScope(node);
+ }
+
+ @override
void visitNamedExpression(NamedExpression node) {
InferenceContext.setTypeFromNode(node.expression, node);
super.visitNamedExpression(node);
@@ -2575,6 +2577,7 @@
try {
ClassElement element = node.declaredElement!;
enclosingClass = node.declaredElement;
+ node.metadata.accept(this);
nameScope = TypeParameterScope(
nameScope,
@@ -2601,12 +2604,12 @@
void visitClassMembersInScope(ClassDeclaration node) {
node.documentationComment?.accept(this);
- node.metadata.accept(this);
node.members.accept(this);
}
@override
void visitClassTypeAlias(ClassTypeAlias node) {
+ node.metadata.accept(this);
Scope outerScope = nameScope;
try {
ClassElement element = node.declaredElement!;
@@ -2614,12 +2617,24 @@
TypeParameterScope(nameScope, element.typeParameters),
element,
);
- super.visitClassTypeAlias(node);
+ visitClassTypeAliasInScope(node);
} finally {
nameScope = outerScope;
}
}
+ void visitClassTypeAliasInScope(ClassTypeAlias node) {
+ // Note: we don't visit metadata because it's not inside the class type
+ // alias's type parameter scope. It was already visited in
+ // [visitClassTypeAlias].
+ node.documentationComment?.accept(this);
+ node.name.accept(this);
+ node.typeParameters?.accept(this);
+ node.superclass.accept(this);
+ node.withClause.accept(this);
+ node.implementsClause?.accept(this);
+ }
+
@override
void visitCompilationUnit(CompilationUnit node) {
_setNodeNameScope(node, nameScope);
@@ -2693,6 +2708,7 @@
try {
ClassElement element = node.declaredElement!;
enclosingClass = node.declaredElement;
+ node.metadata.accept(this);
nameScope = ClassScope(nameScope, element);
visitEnumMembersInScope(node);
@@ -2704,7 +2720,6 @@
void visitEnumMembersInScope(EnumDeclaration node) {
node.documentationComment?.accept(this);
- node.metadata.accept(this);
node.constants.accept(this);
}
@@ -2721,6 +2736,7 @@
try {
ExtensionElement element = node.declaredElement!;
enclosingExtension = element;
+ node.metadata.accept(this);
nameScope = TypeParameterScope(
nameScope,
@@ -2744,7 +2760,6 @@
void visitExtensionMembersInScope(ExtensionDeclaration node) {
node.documentationComment?.accept(this);
- node.metadata.accept(this);
node.members.accept(this);
}
@@ -2835,6 +2850,7 @@
@override
void visitFunctionDeclaration(FunctionDeclaration node) {
+ node.metadata.accept(this);
Scope outerScope = nameScope;
try {
var element = node.declaredElement!;
@@ -2849,7 +2865,12 @@
}
void visitFunctionDeclarationInScope(FunctionDeclaration node) {
- super.visitFunctionDeclaration(node);
+ // Note: we don't visit metadata because it's not inside the function's type
+ // parameter scope. It was already visited in [visitFunctionDeclaration].
+ node.documentationComment?.accept(this);
+ node.returnType?.accept(this);
+ node.name.accept(this);
+ node.functionExpression.accept(this);
}
@override
@@ -2875,6 +2896,7 @@
@override
void visitFunctionTypeAlias(FunctionTypeAlias node) {
+ node.metadata.accept(this);
Scope outerScope = nameScope;
try {
var element = node.declaredElement!;
@@ -2886,11 +2908,19 @@
}
void visitFunctionTypeAliasInScope(FunctionTypeAlias node) {
- super.visitFunctionTypeAlias(node);
+ // Note: we don't visit metadata because it's not inside the function type
+ // alias's type parameter scope. It was already visited in
+ // [visitFunctionTypeAlias].
+ node.documentationComment?.accept(this);
+ node.returnType?.accept(this);
+ node.name.accept(this);
+ node.typeParameters?.accept(this);
+ node.parameters.accept(this);
}
@override
void visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
+ node.metadata.accept(this);
Scope outerScope = nameScope;
try {
ParameterElement element = node.declaredElement!;
@@ -2898,12 +2928,24 @@
nameScope,
element.typeParameters,
);
- super.visitFunctionTypedFormalParameter(node);
+ visitFunctionTypedFormalParameterInScope(node);
} finally {
nameScope = outerScope;
}
}
+ void visitFunctionTypedFormalParameterInScope(
+ FunctionTypedFormalParameter node) {
+ // Note: we don't visit metadata because it's not inside the function typed
+ // formal parameter's type parameter scope. It was already visited in
+ // [visitFunctionTypedFormalParameter].
+ node.documentationComment?.accept(this);
+ node.returnType?.accept(this);
+ node.identifier.accept(this);
+ node.typeParameters?.accept(this);
+ node.parameters.accept(this);
+ }
+
@override
void visitGenericFunctionType(GenericFunctionType node) {
var type = node.type;
@@ -2927,11 +2969,12 @@
@override
void visitGenericTypeAlias(GenericTypeAlias node) {
+ node.metadata.accept(this);
Scope outerScope = nameScope;
try {
var element = node.declaredElement as TypeAliasElement;
nameScope = TypeParameterScope(nameScope, element.typeParameters);
- super.visitGenericTypeAlias(node);
+ visitGenericTypeAliasInScope(node);
var aliasedElement = element.aliasedElement;
if (aliasedElement is GenericFunctionTypeElement) {
@@ -2945,6 +2988,16 @@
void visitGenericTypeAliasInFunctionScope(GenericTypeAlias node) {}
+ void visitGenericTypeAliasInScope(GenericTypeAlias node) {
+ // Note: we don't visit metadata because it's not inside the generic type
+ // alias's type parameter scope. It was already visited in
+ // [visitGenericTypeAlias].
+ node.documentationComment?.accept(this);
+ node.name.accept(this);
+ node.typeParameters?.accept(this);
+ node.type.accept(this);
+ }
+
@override
void visitIfStatement(IfStatement node) {
node.condition.accept(this);
@@ -2964,6 +3017,7 @@
@override
void visitMethodDeclaration(MethodDeclaration node) {
+ node.metadata.accept(this);
Scope outerScope = nameScope;
try {
ExecutableElement element = node.declaredElement!;
@@ -2978,7 +3032,14 @@
}
void visitMethodDeclarationInScope(MethodDeclaration node) {
- super.visitMethodDeclaration(node);
+ // Note: we don't visit metadata because it's not inside the method's type
+ // parameter scope. It was already visited in [visitMethodDeclaration].
+ node.documentationComment?.accept(this);
+ node.returnType?.accept(this);
+ node.name.accept(this);
+ node.typeParameters?.accept(this);
+ node.parameters?.accept(this);
+ node.body.accept(this);
}
@override
@@ -2988,6 +3049,7 @@
try {
ClassElement element = node.declaredElement!;
enclosingClass = element;
+ node.metadata.accept(this);
nameScope = TypeParameterScope(nameScope, element.typeParameters);
visitMixinDeclarationInScope(node);
@@ -3009,7 +3071,6 @@
void visitMixinMembersInScope(MixinDeclaration node) {
node.documentationComment?.accept(this);
- node.metadata.accept(this);
node.members.accept(this);
}
diff --git a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
index 7a2d01d..50dec14 100644
--- a/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
+++ b/pkg/analyzer/lib/src/pubspec/pubspec_warning_code.dart
@@ -4,30 +4,113 @@
import 'package:analyzer/error/error.dart';
+// It is hard to visually separate each code's _doc comment_ from its published
+// _documentation comment_ when each is written as an end-of-line comment.
+// ignore_for_file: slash_for_doc_comments
+
/// The error codes used for warnings in pubspec files. The convention for this
/// class is for the name of the error code to indicate the problem that caused
/// the error to be generated and for the error message to explain what is wrong
/// and, when appropriate, how the problem can be corrected.
class PubspecWarningCode extends ErrorCode {
- /// A code indicating that a specified asset does not exist.
- ///
- /// Parameters:
- /// 0: the path to the asset as given in the file.
+ /**
+ * Parameters:
+ * 0: the path to the asset as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an asset list contains a value
+ // referencing a file that doesn't exist.
+ //
+ // #### Example
+ //
+ // Assuming that the file `doesNotExist.gif` doesn't exist, the following code
+ // produces this diagnostic because it's listed as an asset:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - doesNotExist.gif
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is correct, then create a file at that path.
+ //
+ // If the path isn't correct, then change the path to match the path of the
+ // file containing the asset.
static const PubspecWarningCode ASSET_DOES_NOT_EXIST = PubspecWarningCode(
- 'ASSET_DOES_NOT_EXIST', "The asset {0} does not exist.",
+ 'ASSET_DOES_NOT_EXIST', "The asset file '{0}' doesn't exist.",
correction: "Try creating the file or fixing the path to the file.");
- /// A code indicating that a specified asset directory does not exist.
- ///
- /// Parameters:
- /// 0: the path to the asset directory as given in the file.
+ /**
+ * Parameters:
+ * 0: the path to the asset directory as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an asset list contains a value
+ // referencing a directory that doesn't exist.
+ //
+ // #### Example
+ //
+ // Assuming that the directory `assets` doesn't exist, the following code
+ // produces this diagnostic because it's listed as a directory containing
+ // assets:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - assets/
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is correct, then create a directory at that path.
+ //
+ // If the path isn't correct, then change the path to match the path of the
+ // directory containing the assets.
static const PubspecWarningCode ASSET_DIRECTORY_DOES_NOT_EXIST =
PubspecWarningCode('ASSET_DIRECTORY_DOES_NOT_EXIST',
- "The asset directory {0} does not exist.",
+ "The asset directory '{0}' doesn't exist.",
correction: "Try creating the directory or fixing the path to the "
"directory.");
- /// A code indicating that the value of the asset field is not a list.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of the `asset` key
+ // isn't a list.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value of the assets
+ // key is a string when a list is expected:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets: assets/
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the value of the asset list so that it's a list:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - assets/
+ // ```
static const PubspecWarningCode ASSET_FIELD_NOT_LIST = PubspecWarningCode(
'ASSET_FIELD_NOT_LIST',
"The value of the 'asset' field is expected to be a list of relative "
@@ -35,84 +118,413 @@
correction:
"Try converting the value to be a list of relative file paths.");
- /// A code indicating that an element in the asset list is not a string.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when an asset list contains a value
+ // that isn't a string.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the asset list contains
+ // a map:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - image.gif: true
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Change the asset list so that it only contains valid POSIX-style file
+ // paths:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // assets:
+ // - image.gif
+ // ```
static const PubspecWarningCode ASSET_NOT_STRING = PubspecWarningCode(
- 'ASSET_NOT_STRING', "Assets are expected to be a file paths (strings).",
+ 'ASSET_NOT_STRING', "Assets are required to be file paths (strings).",
correction: "Try converting the value to be a string.");
- /// A code indicating that the value of a dependencies field is not a map.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of either the
+ // `dependencies` or `dev_dependencies` key isn't a map.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value of the
+ // top-level `dependencies` key is a list:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // - meta
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Use a map as the value of the `dependencies` key:
+ //
+ // ```yaml
+ // %uri='pubspec.yaml'
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
static const PubspecWarningCode DEPENDENCIES_FIELD_NOT_MAP =
PubspecWarningCode('DEPENDENCIES_FIELD_NOT_MAP',
"The value of the '{0}' field is expected to be a map.",
correction: "Try converting the value to be a map.");
- /// A code indicating that a field is deprecated.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a key is used in a
+ // `pubspec.yaml` file that was deprecated. Unused keys take up space and
+ // might imply semantics that are no longer valid.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the `author` key is no
+ // longer being used:
+ //
+ // ```dart
+ // %uri="pubspec.yaml"
+ // name: example
+ // author: 'Dash'
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the deprecated key:
+ //
+ // ```dart
+ // %uri="pubspec.yaml"
+ // name: example
+ // ```
static const PubspecWarningCode DEPRECATED_FIELD = PubspecWarningCode(
'DEPRECATED_FIELD',
- "The '{0}' field is no longer used and may be removed.",
+ "The '{0}' field is no longer used and can be removed.",
correction: "Try removing the field.");
- /// A code indicating that the value of the flutter field is not a map.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the value of the `flutter` key
+ // isn't a map.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value of the
+ // top-level `flutter` key is a string:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter: true
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you need to specify Flutter-specific options, then change the value to
+ // be a map:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // flutter:
+ // uses-material-design: true
+ // ```
+ //
+ // If you don't need to specify Flutter-specific options, then remove the
+ // `flutter` key:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // ```
static const PubspecWarningCode FLUTTER_FIELD_NOT_MAP = PubspecWarningCode(
'FLUTTER_FIELD_NOT_MAP',
"The value of the 'flutter' field is expected to be a map.",
correction: "Try converting the value to be a map.");
- /// A code indicating that a versioned package has an invalid dependency (git
- /// or path).
- ///
- /// Parameters:
- /// 0: the kind of dependency.
+ /**
+ * Parameters:
+ * 0: the kind of dependency.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a package under either
+ // `dependencies` or `dev_dependencies` is not a pub, `git`, or `path` based
+ // dependency.
+ //
+ // See [Package dependencies](https://dart.dev/tools/pub/dependencies) for
+ // more information about the kind of dependencies that are supported.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the dependency on the
+ // package `transmogrify` is not a pub, `git`, or `path` based dependency:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // transmogrify:
+ // hosted:
+ // name: transmogrify
+ // url: http://your-package-server.com
+ // version: ^1.4.0
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If you want to publish your package to `pub.dev`, then change the
+ // dependencies to ones that are supported by `pub`.
+ //
+ // If you don't want to publish your package to `pub.dev`, then add a
+ // `publish_to: none` entry to mark the package as one that isn't intended to
+ // be published:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // publish_to: none
+ // dependencies:
+ // transmogrify:
+ // hosted:
+ // name: transmogrify
+ // url: http://your-package-server.com
+ // version: ^1.4.0
+ // ```
static const PubspecWarningCode INVALID_DEPENDENCY = PubspecWarningCode(
- 'INVALID_DEPENDENCY', "Publishable packages can't have {0} dependencies.",
+ 'INVALID_DEPENDENCY',
+ "Publishable packages can't have '{0}' dependencies.",
correction:
"Try adding a 'publish_to: none' entry to mark the package as not "
"for publishing or remove the {0} dependency.");
- /// A code indicating that the name field is missing.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's no top-level `name` key.
+ // The `name` key provides the name of the package, which is required.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the package doesn't
+ // have a name:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Add the top-level key `name` with a value that's the name of the package:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
static const PubspecWarningCode MISSING_NAME = PubspecWarningCode(
- 'MISSING_NAME', "The name field is required but missing.",
+ 'MISSING_NAME', "The 'name' field is required but missing.",
correction: "Try adding a field named 'name'.");
- /// A code indicating that the name field is not a string.
+ /**
+ * No parameters.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when the top-level `name` key has a
+ // value that isn't a string.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the value following the
+ // `name` key is a list:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name:
+ // - example
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Replace the value with a string:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // ```
static const PubspecWarningCode NAME_NOT_STRING = PubspecWarningCode(
'NAME_NOT_STRING',
- "The value of the name field is expected to be a string.",
+ "The value of the 'name' field is required to be a string.",
correction: "Try converting the value to be a string.");
- /// A code indicating that a specified path dependency does not exist.
- ///
- /// Parameters:
- /// 0: the path to the dependency as given in the file.
+ /**
+ * Parameters:
+ * 0: the path to the dependency as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a dependency has a `path` key
+ // referencing a directory that doesn't exist.
+ //
+ // #### Example
+ //
+ // Assuming that the directory `doesNotExist` doesn't exist, the following
+ // code produces this diagnostic because it's listed as the path of a package:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // local_package:
+ // path: doesNotExist
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is correct, then create a directory at that path.
+ //
+ // If the path isn't correct, then change the path to match the path to the
+ // root of the package.
static const PubspecWarningCode PATH_DOES_NOT_EXIST = PubspecWarningCode(
- 'PATH_DOES_NOT_EXIST', "The path {0} does not exist.",
+ 'PATH_DOES_NOT_EXIST', "The path '{0}' doesn't exist.",
correction:
"Try creating the referenced path or using a path that exists.");
- /// A code indicating that a path value is not is not posix-style.
- ///
- /// Parameters:
- /// 0: the path as given in the file.
+ /**
+ * Parameters:
+ * 0: the path as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a dependency has a `path` key
+ // whose value is a string, but isn't a POSIX-style path.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the path following the
+ // `path` key is a Windows path:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // local_package:
+ // path: E:\local_package
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Convert the path to a POSIX path.
static const PubspecWarningCode PATH_NOT_POSIX = PubspecWarningCode(
- 'PATH_NOT_POSIX', "The path {0} is not posix.",
- correction: "Try converting the value to a posix-style path.");
+ 'PATH_NOT_POSIX', "The path '{0}' isn't a POSIX-style path.",
+ correction: "Try converting the value to a POSIX-style path.");
- /// A code indicating that a specified path dependency points to a directory
- /// that does not contain a pubspec.
- ///
- /// Parameters:
- /// 0: the path to the dependency as given in the file.
+ /**
+ * Parameters:
+ * 0: the path to the dependency as given in the file.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when a dependency has a `path` key
+ // that references a directory that doesn't contain a `pubspec.yaml` file.
+ //
+ // #### Example
+ //
+ // Assuming that the directory `local_package` doesn't contain a file named
+ // `pubspec.yaml`, the following code produces this diagnostic because it's
+ // listed as the path of a package:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: example
+ // dependencies:
+ // local_package:
+ // path: local_package
+ // ```
+ //
+ // #### Common fixes
+ //
+ // If the path is intended to be the root of a package, then add a
+ // `pubspec.yaml` file in the directory:
+ //
+ // ```yaml
+ // %uri="pubspec.yaml"
+ // name: local_package
+ // ```
+ //
+ // If the path is wrong, then replace it with a the correct path.
static const PubspecWarningCode PATH_PUBSPEC_DOES_NOT_EXIST = PubspecWarningCode(
'PATH_PUBSPEC_DOES_NOT_EXIST',
- "The directory {0} does not contain a pubspec.",
+ "The directory '{0}' doesn't contain a pubspec.",
correction:
"Try creating a pubspec in the referenced directory or using a path that has a pubspec.");
- /// A code indicating that a package listed as a dev dependency is also listed
- /// as a normal dependency.
- ///
- /// Parameters:
- /// 0: the name of the package in the dev_dependency list.
+ /**
+ * Parameters:
+ * 0: the name of the package in the dev_dependency list.
+ */
+ // #### Description
+ //
+ // The analyzer produces this diagnostic when there's an entry under
+ // `dev_dependencies` for a package that is also listed under `dependencies`.
+ // The packages under `dependencies` are available to all of the code in the
+ // package, so there's no need to also list them under `dev_dependencies`.
+ //
+ // #### Example
+ //
+ // The following code produces this diagnostic because the package `meta` is
+ // listed under both `dependencies` and `dev_dependencies`:
+ //
+ // ```yaml
+ // %uri='pubspec.yaml'
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // dev_dependencies:
+ // meta: ^1.0.2
+ // ```
+ //
+ // #### Common fixes
+ //
+ // Remove the entry under `dev_dependencies` (and the `dev_dependencies` key
+ // if that's the only package listed there):
+ //
+ // ```yaml
+ // %uri='pubspec.yaml'
+ // name: example
+ // dependencies:
+ // meta: ^1.0.2
+ // ```
static const PubspecWarningCode UNNECESSARY_DEV_DEPENDENCY =
PubspecWarningCode(
'UNNECESSARY_DEV_DEPENDENCY',
diff --git a/pkg/analyzer/lib/src/test_utilities/find_node.dart b/pkg/analyzer/lib/src/test_utilities/find_node.dart
index 0443c30..260f431 100644
--- a/pkg/analyzer/lib/src/test_utilities/find_node.dart
+++ b/pkg/analyzer/lib/src/test_utilities/find_node.dart
@@ -64,6 +64,10 @@
return _node(search, (n) => n is ClassDeclaration);
}
+ ClassTypeAlias classTypeAlias(String search) {
+ return _node(search, (n) => n is ClassTypeAlias);
+ }
+
CollectionElement collectionElement(String search) {
return _node(search, (n) => n is CollectionElement);
}
@@ -104,6 +108,10 @@
return _node(search, (n) => n is DoubleLiteral);
}
+ EnumDeclaration enumDeclaration(String search) {
+ return _node(search, (n) => n is EnumDeclaration);
+ }
+
ExportDirective export(String search) {
return _node(search, (n) => n is ExportDirective);
}
@@ -168,6 +176,10 @@
return _node(search, (n) => n is GenericFunctionType);
}
+ GenericTypeAlias genericTypeAlias(String search) {
+ return _node(search, (n) => n is GenericTypeAlias);
+ }
+
IfElement ifElement(String search) {
return _node(search, (n) => n is IfElement);
}
@@ -220,6 +232,10 @@
return _node(search, (n) => n is MixinDeclaration);
}
+ MixinDeclaration mixinDeclaration(String search) {
+ return _node(search, (n) => n is MixinDeclaration);
+ }
+
NamedExpression namedExpression(String search) {
return _node(search, (n) => n is NamedExpression);
}
diff --git a/pkg/analyzer/test/generated/simple_resolver_test.dart b/pkg/analyzer/test/generated/simple_resolver_test.dart
index 981d29c..b0a30a2 100644
--- a/pkg/analyzer/test/generated/simple_resolver_test.dart
+++ b/pkg/analyzer/test/generated/simple_resolver_test.dart
@@ -850,6 +850,58 @@
);
}
+ test_metadata_classTypeAlias() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+@A class C<A> = D with E;
+class D {}
+class E {}
+''');
+ verifyTestResolved();
+
+ var annotations = findElement.class_('C').metadata;
+ expect(annotations, hasLength(1));
+
+ var cDeclaration = findNode.classTypeAlias('C<A>');
+ assertElement(
+ cDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
+ test_metadata_enum() async {
+ await assertNoErrorsInCode('''
+const A = null;
+@A enum E { A, B }
+''');
+ verifyTestResolved();
+
+ var annotations = findElement.enum_('E').metadata;
+ expect(annotations, hasLength(1));
+
+ var eDeclaration = findNode.enumDeclaration('E');
+ assertElement(
+ eDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
+ test_metadata_extension() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+@A extension E<A> on List<A> {}''');
+ verifyTestResolved();
+
+ var annotations = findElement.extension_('E').metadata;
+ expect(annotations, hasLength(1));
+
+ var cDeclaration = findNode.extensionDeclaration('E<A>');
+ assertElement(
+ cDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
test_metadata_field() async {
await assertNoErrorsInCode(r'''
const A = null;
@@ -885,6 +937,39 @@
expect(annotations, hasLength(1));
}
+ test_metadata_function_generic() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+@A f<A>() {}''');
+ verifyTestResolved();
+
+ var annotations = findElement.topFunction('f').metadata;
+ expect(annotations, hasLength(1));
+
+ var fDeclaration = findNode.functionDeclaration('f<A>');
+ assertElement(
+ fDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
+ test_metadata_functionTypeAlias() async {
+ await assertNoErrorsInCode('''
+const A = null;
+@A typedef F<A>(int A);
+''');
+ verifyTestResolved();
+
+ var annotations = findElement.typeAlias('F').metadata;
+ expect(annotations, hasLength(1));
+
+ var fDeclaration = findNode.functionTypeAlias('F');
+ assertElement(
+ fDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
test_metadata_functionTypedParameter() async {
await assertNoErrorsInCode(r'''
const A = null;
@@ -895,6 +980,39 @@
expect(metadata, hasLength(1));
}
+ test_metadata_functionTypedParameter_generic() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+f(@A int p<A>(int x)) {}''');
+ verifyTestResolved();
+
+ var annotations = findElement.parameter('p').metadata;
+ expect(annotations, hasLength(1));
+
+ var pDeclaration = findNode.functionTypedFormalParameter('p<A>');
+ assertElement(
+ pDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
+ test_metadata_genericTypeAlias() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+@A typedef F<A> = A Function();
+''');
+ verifyTestResolved();
+
+ var annotations = findElement.typeAlias('F').metadata;
+ expect(annotations, hasLength(1));
+
+ var fDeclaration = findNode.genericTypeAlias('F<A>');
+ assertElement(
+ fDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
test_metadata_libraryDirective() async {
await assertNoErrorsInCode(r'''
@A library lib;
@@ -917,6 +1035,40 @@
expect(metadata, hasLength(1));
}
+ test_metadata_method_generic() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+class C {
+ @A void m<A>() {}
+}''');
+ verifyTestResolved();
+
+ var annotations = findElement.method('m').metadata;
+ expect(annotations, hasLength(1));
+
+ var mDeclaration = findNode.methodDeclaration('m<A>');
+ assertElement(
+ mDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
+ test_metadata_mixin() async {
+ await assertNoErrorsInCode(r'''
+const A = null;
+@A mixin M<A> on Object {}''');
+ verifyTestResolved();
+
+ var annotations = findElement.mixin('M').metadata;
+ expect(annotations, hasLength(1));
+
+ var mDeclaration = findNode.mixinDeclaration('M<A>');
+ assertElement(
+ mDeclaration.metadata[0].name,
+ findElement.topGet('A'),
+ );
+ }
+
test_metadata_namedParameter() async {
await assertNoErrorsInCode(r'''
const A = null;
diff --git a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
index 40f03e0..95765b9 100644
--- a/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/metadata_test.dart
@@ -897,6 +897,215 @@
''');
}
+ test_value_genericMixinApplication_inference_unnamedConstructor_classTypeAlias() async {
+ await assertNoErrorsInCode(r'''
+ class A<T> {
+ final T f;
+ const A(this.f);
+}
+
+mixin M {}
+
+class B<T> = A<T> with M;
+
+@B(42)
+class C<T> = D with E;
+
+class D {}
+class E {}
+''');
+
+ var annotation = findNode.annotation('@B');
+ _assertResolvedNodeText(annotation, r'''
+Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42
+ staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign: @
+ element: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B
+''');
+ _assertAnnotationValueText(annotation, r'''
+B<int>
+ (super): A<int>
+ f: int 42
+''');
+ }
+
+ test_value_genericMixinApplication_inference_unnamedConstructor_functionTypeAlias() async {
+ await assertNoErrorsInCode(r'''
+ class A<T> {
+ final T f;
+ const A(this.f);
+}
+
+mixin M {}
+
+class B<T> = A<T> with M;
+
+@B(42)
+typedef T F<T>();
+''');
+
+ var annotation = findNode.annotation('@B');
+ _assertResolvedNodeText(annotation, r'''
+Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42
+ staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign: @
+ element: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B
+''');
+ _assertAnnotationValueText(annotation, r'''
+B<int>
+ (super): A<int>
+ f: int 42
+''');
+ }
+
+ test_value_genericMixinApplication_inference_unnamedConstructor_functionTypedFormalParameter() async {
+ await assertNoErrorsInCode(r'''
+ class A<T> {
+ final T f;
+ const A(this.f);
+}
+
+mixin M {}
+
+class B<T> = A<T> with M;
+
+f(@B(42) g()) {}
+''');
+
+ var annotation = findNode.annotation('@B');
+ _assertResolvedNodeText(annotation, r'''
+Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42
+ staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign: @
+ element: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B
+''');
+ _assertAnnotationValueText(annotation, r'''
+B<int>
+ (super): A<int>
+ f: int 42
+''');
+ }
+
+ test_value_genericMixinApplication_inference_unnamedConstructor_genericTypeAlias() async {
+ await assertNoErrorsInCode(r'''
+ class A<T> {
+ final T f;
+ const A(this.f);
+}
+
+mixin M {}
+
+class B<T> = A<T> with M;
+
+@B(42)
+typedef F = void Function();
+''');
+
+ var annotation = findNode.annotation('@B');
+ _assertResolvedNodeText(annotation, r'''
+Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42
+ staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign: @
+ element: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B
+''');
+ _assertAnnotationValueText(annotation, r'''
+B<int>
+ (super): A<int>
+ f: int 42
+''');
+ }
+
+ test_value_genericMixinApplication_inference_unnamedConstructor_methodDeclaration() async {
+ await assertNoErrorsInCode(r'''
+ class A<T> {
+ final T f;
+ const A(this.f);
+}
+
+mixin M {}
+
+class B<T> = A<T> with M;
+
+class C {
+ @B(42)
+ m() {}
+}
+''');
+
+ var annotation = findNode.annotation('@B');
+ _assertResolvedNodeText(annotation, r'''
+Annotation
+ arguments: ArgumentList
+ arguments
+ IntegerLiteral
+ literal: 42
+ staticType: int
+ leftParenthesis: (
+ rightParenthesis: )
+ atSign: @
+ element: ConstructorMember
+ base: self::@class::B::@constructor::•
+ substitution: {T: int}
+ name: SimpleIdentifier
+ staticElement: self::@class::B
+ staticType: null
+ token: B
+''');
+ _assertAnnotationValueText(annotation, r'''
+B<int>
+ (super): A<int>
+ f: int 42
+''');
+ }
+
test_value_genericMixinApplication_typeArguments_unnamedConstructor() async {
await assertNoErrorsInCode(r'''
class A<T> {
diff --git a/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart b/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
index 69cb215..d5538cc 100644
--- a/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/undefined_identifier_test.dart
@@ -18,6 +18,51 @@
@reflectiveTest
class UndefinedIdentifierTest extends PubPackageResolutionTest
with WithoutNullSafetyMixin {
+ test_annotation_references_static_method_in_class() async {
+ await assertErrorsInCode('''
+@Annotation(foo)
+class C {
+ static void foo() {}
+}
+class Annotation {
+ const Annotation(dynamic d);
+}
+ ''', [
+ error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 12, 3),
+ error(CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT, 12, 3),
+ ]);
+ }
+
+ test_annotation_references_static_method_in_extension() async {
+ await assertErrorsInCode('''
+@Annotation(foo)
+extension E on int {
+ static void foo() {}
+}
+class Annotation {
+ const Annotation(dynamic d);
+}
+ ''', [
+ error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 12, 3),
+ error(CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT, 12, 3),
+ ]);
+ }
+
+ test_annotation_references_static_method_in_mixin() async {
+ await assertErrorsInCode('''
+@Annotation(foo)
+mixin M {
+ static void foo() {}
+}
+class Annotation {
+ const Annotation(dynamic d);
+}
+ ''', [
+ error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 12, 3),
+ error(CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT, 12, 3),
+ ]);
+ }
+
@failingTest
test_commentReference() async {
await assertErrorsInCode('''
diff --git a/pkg/analyzer/test/verify_diagnostics_test.dart b/pkg/analyzer/test/verify_diagnostics_test.dart
index 1ccaa65..5222636 100644
--- a/pkg/analyzer/test/verify_diagnostics_test.dart
+++ b/pkg/analyzer/test/verify_diagnostics_test.dart
@@ -75,8 +75,14 @@
'CompileTimeErrorCode.RETURN_IN_GENERATOR',
// Produces two diagnostic out of necessity.
'CompileTimeErrorCode.TOP_LEVEL_CYCLE',
+ // Produces two diagnostic out of necessity.
+ 'CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF',
+ // Produces two diagnostic out of necessity.
+ 'CompileTimeErrorCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND',
// Produces the diagnostic HintCode.UNUSED_LOCAL_VARIABLE when it shouldn't.
'CompileTimeErrorCode.UNDEFINED_IDENTIFIER_AWAIT',
+ // Produces multiple diagnostic because of poor recovery.
+ 'CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR',
// The code has been replaced but is not yet removed.
'HintCode.DEPRECATED_MEMBER_USE',
// Produces two diagnostics when it should only produce one (see
@@ -85,6 +91,24 @@
// Produces two diagnostics when it should only produce one (see
// https://github.com/dart-lang/sdk/issues/43263)
'StaticWarningCode.DEAD_NULL_AWARE_EXPRESSION',
+ //
+ // The following can't currently be verified because the examples aren't
+ // Dart code.
+ //
+ 'PubspecWarningCode.ASSET_DOES_NOT_EXIST',
+ 'PubspecWarningCode.ASSET_DIRECTORY_DOES_NOT_EXIST',
+ 'PubspecWarningCode.ASSET_FIELD_NOT_LIST',
+ 'PubspecWarningCode.ASSET_NOT_STRING',
+ 'PubspecWarningCode.DEPENDENCIES_FIELD_NOT_MAP',
+ 'PubspecWarningCode.DEPRECATED_FIELD',
+ 'PubspecWarningCode.FLUTTER_FIELD_NOT_MAP',
+ 'PubspecWarningCode.INVALID_DEPENDENCY',
+ 'PubspecWarningCode.MISSING_NAME',
+ 'PubspecWarningCode.NAME_NOT_STRING',
+ 'PubspecWarningCode.PATH_DOES_NOT_EXIST',
+ 'PubspecWarningCode.PATH_NOT_POSIX',
+ 'PubspecWarningCode.PATH_PUBSPEC_DOES_NOT_EXIST',
+ 'PubspecWarningCode.UNNECESSARY_DEV_DEPENDENCY',
];
/// The prefix used on directive lines to specify the experiments that should
diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md
index 2201508..09d37cc 100644
--- a/pkg/analyzer/tool/diagnostics/diagnostics.md
+++ b/pkg/analyzer/tool/diagnostics/diagnostics.md
@@ -808,6 +808,128 @@
}
{% endprettify %}
+### asset_directory_does_not_exist
+
+_The asset directory '{0}' doesn't exist._
+
+#### Description
+
+The analyzer produces this diagnostic when an asset list contains a value
+referencing a directory that doesn't exist.
+
+#### Example
+
+Assuming that the directory `assets` doesn't exist, the following code
+produces this diagnostic because it's listed as a directory containing
+assets:
+
+```yaml
+name: example
+flutter:
+ assets:
+ - assets/
+```
+
+#### Common fixes
+
+If the path is correct, then create a directory at that path.
+
+If the path isn't correct, then change the path to match the path of the
+directory containing the assets.
+
+### asset_does_not_exist
+
+_The asset file '{0}' doesn't exist._
+
+#### Description
+
+The analyzer produces this diagnostic when an asset list contains a value
+referencing a file that doesn't exist.
+
+#### Example
+
+Assuming that the file `doesNotExist.gif` doesn't exist, the following code
+produces this diagnostic because it's listed as an asset:
+
+```yaml
+name: example
+flutter:
+ assets:
+ - doesNotExist.gif
+```
+
+#### Common fixes
+
+If the path is correct, then create a file at that path.
+
+If the path isn't correct, then change the path to match the path of the
+file containing the asset.
+
+### asset_field_not_list
+
+_The value of the 'asset' field is expected to be a list of relative file
+paths._
+
+#### Description
+
+The analyzer produces this diagnostic when the value of the `asset` key
+isn't a list.
+
+#### Example
+
+The following code produces this diagnostic because the value of the assets
+key is a string when a list is expected:
+
+```yaml
+name: example
+flutter:
+ assets: assets/
+```
+
+#### Common fixes
+
+Change the value of the asset list so that it's a list:
+
+```yaml
+name: example
+flutter:
+ assets:
+ - assets/
+```
+
+### asset_not_string
+
+_Assets are required to be file paths (strings)._
+
+#### Description
+
+The analyzer produces this diagnostic when an asset list contains a value
+that isn't a string.
+
+#### Example
+
+The following code produces this diagnostic because the asset list contains
+a map:
+
+```yaml
+name: example
+flutter:
+ assets:
+ - image.gif: true
+```
+
+#### Common fixes
+
+Change the asset list so that it only contains valid POSIX-style file
+paths:
+
+```yaml
+name: example
+flutter:
+ assets:
+ - image.gif
+```
+
### assignment_to_const
_Constant variables can't be assigned a value._
@@ -1796,6 +1918,76 @@
class C extends A<String> implements B {}
{% endprettify %}
+### conflicting_type_variable_and_container
+
+_'{0}' can't be used to name both a type variable and the class in which the
+type variable is defined._
+
+_'{0}' can't be used to name both a type variable and the extension in which the
+type variable is defined._
+
+_'{0}' can't be used to name both a type variable and the mixin in which the
+type variable is defined._
+
+#### Description
+
+The analyzer produces this diagnostic when a class, mixin, or extension
+declaration declares a type parameter with the same name as the class,
+mixin, or extension that declares it.
+
+#### Example
+
+The following code produces this diagnostic because the type parameter `C`
+has the same name as the class `C` of which it's a part:
+
+{% prettify dart tag=pre+code %}
+class C<[!C!]> {}
+{% endprettify %}
+
+#### Common fixes
+
+Rename either the type parameter, or the class, mixin, or extension:
+
+{% prettify dart tag=pre+code %}
+class C<T> {}
+{% endprettify %}
+
+### conflicting_type_variable_and_member
+
+_'{0}' can't be used to name both a type variable and a member in this class._
+
+_'{0}' can't be used to name both a type variable and a member in this
+extension._
+
+_'{0}' can't be used to name both a type variable and a member in this mixin._
+
+#### Description
+
+The analyzer produces this diagnostic when a class, mixin, or extension
+declaration declares a type parameter with the same name as one of the
+members of the class, mixin, or extension that declares it.
+
+#### Example
+
+The following code produces this diagnostic because the type parameter `T`
+has the same name as the field `T`:
+
+{% prettify dart tag=pre+code %}
+class C<[!T!]> {
+ int T = 0;
+}
+{% endprettify %}
+
+#### Common fixes
+
+Rename either the type parameter or the member with which it conflicts:
+
+{% prettify dart tag=pre+code %}
+class C<T> {
+ int total = 0;
+}
+{% endprettify %}
+
### const_constructor_param_type_mismatch
_A value of type '{0}' can't be assigned to a parameter of type '{1}' in a const
@@ -3005,6 +3197,64 @@
}
{% endprettify %}
+### dependencies_field_not_map
+
+_The value of the '{0}' field is expected to be a map._
+
+#### Description
+
+The analyzer produces this diagnostic when the value of either the
+`dependencies` or `dev_dependencies` key isn't a map.
+
+#### Example
+
+The following code produces this diagnostic because the value of the
+top-level `dependencies` key is a list:
+
+```yaml
+name: example
+dependencies:
+ - meta
+```
+
+#### Common fixes
+
+Use a map as the value of the `dependencies` key:
+
+```yaml
+name: example
+dependencies:
+ meta: ^1.0.2
+```
+
+### deprecated_field
+
+_The '{0}' field is no longer used and can be removed._
+
+#### Description
+
+The analyzer produces this diagnostic when a key is used in a
+`pubspec.yaml` file that was deprecated. Unused keys take up space and
+might imply semantics that are no longer valid.
+
+#### Example
+
+The following code produces this diagnostic because the `author` key is no
+longer being used:
+
+{% prettify dart tag=pre+code %}
+name: example
+author: 'Dash'
+{% endprettify %}
+
+#### Common fixes
+
+Remove the deprecated key:
+
+{% prettify dart tag=pre+code %}
+name: example
+{% endprettify %}
+
### deprecated_member_use
_'{0}' is deprecated and shouldn't be used._
@@ -3059,6 +3309,39 @@
documentation for deprecated declarations should indicate what code to use
in place of the deprecated code.
+### deprecated_subtype_of_function
+
+_Extending 'Function' is deprecated._
+
+_Implementing 'Function' has no effect._
+
+_Mixing in 'Function' is deprecated._
+
+#### Description
+
+The analyzer produces this diagnostic when the class `Function` is used in
+either the `extends`, `implements`, or `with` clause of a class or mixin.
+Using the class `Function` in this way has no semantic value, so it's
+effectively dead code.
+
+#### Example
+
+The following code produces this diagnostic because `Function` is used as
+the superclass of `F`:
+
+{% prettify dart tag=pre+code %}
+class F extends [!Function!] {}
+{% endprettify %}
+
+#### Common fixes
+
+Remove the class `Function` from whichever clause it's in, and remove the
+whole clause if `Function` is the only type in the clause:
+
+{% prettify dart tag=pre+code %}
+class F {}
+{% endprettify %}
+
### duplicate_constructor
_The constructor with name '{0}' is already defined._
@@ -4833,6 +5116,43 @@
}
{% endprettify %}
+### flutter_field_not_map
+
+_The value of the 'flutter' field is expected to be a map._
+
+#### Description
+
+The analyzer produces this diagnostic when the value of the `flutter` key
+isn't a map.
+
+#### Example
+
+The following code produces this diagnostic because the value of the
+top-level `flutter` key is a string:
+
+```yaml
+name: example
+flutter: true
+```
+
+#### Common fixes
+
+If you need to specify Flutter-specific options, then change the value to
+be a map:
+
+```yaml
+name: example
+flutter:
+ uses-material-design: true
+```
+
+If you don't need to specify Flutter-specific options, then remove the
+`flutter` key:
+
+```yaml
+name: example
+```
+
### for_in_of_invalid_element_type
_The type '{0}' used in the 'for' loop must implement '{1}' with a type argument
@@ -5270,6 +5590,81 @@
}
{% endprettify %}
+### import_deferred_library_with_load_function
+
+_The imported library defines a top-level function named 'loadLibrary' that is
+hidden by deferring this library._
+
+#### Description
+
+The analyzer produces this diagnostic when a library that declares a
+function named `loadLibrary` is imported using a deferred import. A
+deferred import introduces an implicit function named `loadLibrary`. This
+function is used to load the contents of the deferred library, and the
+implicit function hides the explicit declaration in the deferred library.
+
+For more information, see the language tour's coverage of
+[deferred loading](https://dart.dev/guides/language/language-tour#lazily-loading-a-library).
+
+#### Example
+
+Given a file (`a.dart`) that defines a function named `loadLibrary`:
+
+{% prettify dart tag=pre+code %}
+void loadLibrary(Library library) {}
+
+class Library {}
+{% endprettify %}
+
+The following code produces this diagnostic because the implicit
+declaration of `a.loadLibrary` is hiding the explicit declaration of
+`loadLibrary` in `a.dart`:
+
+{% prettify dart tag=pre+code %}
+[!import 'a.dart' deferred as a;!]
+
+void f() {
+ a.Library();
+}
+{% endprettify %}
+
+#### Common fixes
+
+If the imported library isn't required to be deferred, then remove the
+keyword `deferred`:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' as a;
+
+void f() {
+ a.Library();
+}
+{% endprettify %}
+
+If the imported library is required to be deferred and you need to
+reference the imported function, then rename the function in the imported
+library:
+
+{% prettify dart tag=pre+code %}
+void populateLibrary(Library library) {}
+
+class Library {}
+{% endprettify %}
+
+If the imported library is required to be deferred and you don't need to
+reference the imported function, then add a `hide` clause:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart' deferred as a hide loadLibrary;
+
+void f() {
+ a.Library();
+}
+{% endprettify %}
+
+If type arguments shouldn't be required for the class, then mark the class
+with the `@optionalTypeArgs` annotation (from `package:meta`):
+
### import_internal_library
_The library '{0}' is internal and can't be imported._
@@ -5709,6 +6104,43 @@
If you intend to use an instance of a class, then use the name of that class in place of the name of the enum.
+### integer_literal_imprecise_as_double
+
+_The integer literal is being used as a double, but can't be represented as a
+64-bit double without overflow or loss of precision: '{0}'._
+
+#### Description
+
+The analyzer produces this diagnostic when an integer literal is being
+implicitly converted to a double, but can't be represented as a 64-bit
+double without overflow or loss of precision. Integer literals are
+implicitly converted to a double if the context requires the type `double`.
+
+#### Example
+
+The following code produces this diagnostic because the integer value
+`9223372036854775807` can't be represented exactly as a double:
+
+{% prettify dart tag=pre+code %}
+double x = [!9223372036854775807!];
+{% endprettify %}
+
+#### Common fixes
+
+If you need to use the exact value, then use the class `BigInt` to
+represent the value:
+
+{% prettify dart tag=pre+code %}
+var x = BigInt.parse('9223372036854775807');
+{% endprettify %}
+
+If you need to use a double, then change the value to one that can be
+represented exactly:
+
+{% prettify dart tag=pre+code %}
+double x = 9223372036854775808;
+{% endprettify %}
+
### integer_literal_out_of_range
_The integer literal {0} can't be represented in 64 bits._
@@ -5898,6 +6330,54 @@
int s = i;
{% endprettify %}
+### invalid_dependency
+
+_Publishable packages can't have '{0}' dependencies._
+
+#### Description
+
+The analyzer produces this diagnostic when a package under either
+`dependencies` or `dev_dependencies` is not a pub, `git`, or `path` based
+dependency.
+
+See [Package dependencies](https://dart.dev/tools/pub/dependencies) for
+more information about the kind of dependencies that are supported.
+
+#### Example
+
+The following code produces this diagnostic because the dependency on the
+package `transmogrify` is not a pub, `git`, or `path` based dependency:
+
+```yaml
+name: example
+dependencies:
+ transmogrify:
+ hosted:
+ name: transmogrify
+ url: http://your-package-server.com
+ version: ^1.4.0
+```
+
+#### Common fixes
+
+If you want to publish your package to `pub.dev`, then change the
+dependencies to ones that are supported by `pub`.
+
+If you don't want to publish your package to `pub.dev`, then add a
+`publish_to: none` entry to mark the package as one that isn't intended to
+be published:
+
+```yaml
+name: example
+publish_to: none
+dependencies:
+ transmogrify:
+ hosted:
+ name: transmogrify
+ url: http://your-package-server.com
+ version: ^1.4.0
+```
+
### invalid_extension_argument_count
_Extension overrides must have exactly one argument: the value of 'this' in the
@@ -7456,6 +7936,35 @@
}
{% endprettify %}
+### missing_name
+
+_The 'name' field is required but missing._
+
+#### Description
+
+The analyzer produces this diagnostic when there's no top-level `name` key.
+The `name` key provides the name of the package, which is required.
+
+#### Example
+
+The following code produces this diagnostic because the package doesn't
+have a name:
+
+```yaml
+dependencies:
+ meta: ^1.0.2
+```
+
+#### Common fixes
+
+Add the top-level key `name` with a value that's the name of the package:
+
+```yaml
+name: example
+dependencies:
+ meta: ^1.0.2
+```
+
### missing_required_argument
_The named parameter '{0}' is required, but there's no corresponding argument._
@@ -8194,6 +8703,33 @@
}
{% endprettify %}
+### name_not_string
+
+_The value of the 'name' field is required to be a string._
+
+#### Description
+
+The analyzer produces this diagnostic when the top-level `name` key has a
+value that isn't a string.
+
+#### Example
+
+The following code produces this diagnostic because the value following the
+`name` key is a list:
+
+```yaml
+name:
+ - example
+```
+
+#### Common fixes
+
+Replace the value with a string:
+
+```yaml
+name: example
+```
+
### new_with_undefined_constructor_default
_The class '{0}' doesn't have a default constructor._
@@ -10014,6 +10550,92 @@
part of 'test.dart';
{% endprettify %}
+### path_does_not_exist
+
+_The path '{0}' doesn't exist._
+
+#### Description
+
+The analyzer produces this diagnostic when a dependency has a `path` key
+referencing a directory that doesn't exist.
+
+#### Example
+
+Assuming that the directory `doesNotExist` doesn't exist, the following
+code produces this diagnostic because it's listed as the path of a package:
+
+```yaml
+name: example
+dependencies:
+ local_package:
+ path: doesNotExist
+```
+
+#### Common fixes
+
+If the path is correct, then create a directory at that path.
+
+If the path isn't correct, then change the path to match the path to the
+root of the package.
+
+### path_not_posix
+
+_The path '{0}' isn't a POSIX-style path._
+
+#### Description
+
+The analyzer produces this diagnostic when a dependency has a `path` key
+whose value is a string, but isn't a POSIX-style path.
+
+#### Example
+
+The following code produces this diagnostic because the path following the
+`path` key is a Windows path:
+
+```yaml
+name: example
+dependencies:
+ local_package:
+ path: E:\local_package
+```
+
+#### Common fixes
+
+Convert the path to a POSIX path.
+
+### path_pubspec_does_not_exist
+
+_The directory '{0}' doesn't contain a pubspec._
+
+#### Description
+
+The analyzer produces this diagnostic when a dependency has a `path` key
+that references a directory that doesn't contain a `pubspec.yaml` file.
+
+#### Example
+
+Assuming that the directory `local_package` doesn't contain a file named
+`pubspec.yaml`, the following code produces this diagnostic because it's
+listed as the path of a package:
+
+```yaml
+name: example
+dependencies:
+ local_package:
+ path: local_package
+```
+
+#### Common fixes
+
+If the path is intended to be the root of a package, then add a
+`pubspec.yaml` file in the directory:
+
+```yaml
+name: local_package
+```
+
+If the path is wrong, then replace it with a the correct path.
+
### prefix_collides_with_top_level_member
_The name '{0}' is already used as an import prefix and can't be used to name a
@@ -10094,6 +10716,54 @@
If the name is wrong, then correct the name.
+### private_collision_in_mixin_application
+
+_The private name '{0}', defined by '{1}', conflicts with the same name defined
+by '{2}'._
+
+#### Description
+
+The analyzer produces this diagnostic when two mixins that define the same
+private member are used together in a single class in a library other than
+the one that defines the mixins.
+
+#### Example
+
+Given a file named `a.dart` containing the following code:
+
+{% prettify dart tag=pre+code %}
+class A {
+ void _foo() {}
+}
+
+class B {
+ void _foo() {}
+}
+{% endprettify %}
+
+The following code produces this diagnostic because the classes `A` and `B`
+both define the method `_foo`:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart';
+
+class C extends Object with A, [!B!] {}
+{% endprettify %}
+
+#### Common fixes
+
+If you don't need both of the mixins, then remove one of them from the
+`with` clause:
+
+{% prettify dart tag=pre+code %}
+import 'a.dart';
+
+class C extends Object with A, [!B!] {}
+{% endprettify %}
+
+If you need both of the mixins, then rename the conflicting member in one
+of the two mixins.
+
### private_optional_parameter
_Named parameters can't start with an underscore._
@@ -11612,6 +12282,57 @@
class B {}
{% endprettify %}
+### subtype_of_sealed_class
+
+_The class '{0}' shouldn't be extended, mixed in, or implemented because it's
+sealed._
+
+#### Description
+
+The analyzer produces this diagnostic when a sealed class (one that either
+has the `@sealed` annotation or inherits or mixes in a sealed class) is
+referenced in either the `extends`, `implements`, or `with` clause of a
+class or mixin declaration if the declaration isn't in the same package as
+the sealed class.
+
+#### Example
+
+Given a library in a package other than the package being analyzed that
+contains the following:
+
+{% prettify dart tag=pre+code %}
+import 'package:meta/meta.dart';
+
+class A {}
+
+@sealed
+class B {}
+{% endprettify %}
+
+The following code produces this diagnostic because `C`, which isn't in the
+same package as `B`, is extending the sealed class `B`:
+
+{% prettify dart tag=pre+code %}
+import 'package:a/a.dart';
+
+[!class C extends B {}!]
+{% endprettify %}
+
+#### Common fixes
+
+If the class doesn't need to be a subtype of the sealed class, then change
+the declaration so that it isn't:
+
+{% prettify dart tag=pre+code %}
+import 'package:a/a.dart';
+
+class B extends A {}
+{% endprettify %}
+
+If the class needs to be a subtype of the sealed class, then either change
+the sealed class so that it's no longer sealed or move the subclass into
+the same package as the sealed class.
+
### supertype_expands_to_type_parameter
_A type alias that expands to a type parameter can't be implemented._
@@ -11868,6 +12589,36 @@
variables is assigned a value that doesn't depend on the other variables
before any of the variables in the cycle are referenced.
+### type_alias_cannot_reference_itself
+
+_Typedefs can't reference themselves directly or recursively via another
+typedef._
+
+#### Description
+
+The analyzer produces this diagnostic when a typedef refers to itself,
+either directly or indirectly.
+
+#### Example
+
+The following code produces this diagnostic because `F` depends on itself
+indirectly through `G`:
+
+{% prettify dart tag=pre+code %}
+typedef [!F!] = void Function(G);
+typedef G = void Function(F);
+{% endprettify %}
+
+#### Common fixes
+
+Change one or more of the typedefs in the cycle so that none of them refer
+to themselves:
+
+{% prettify dart tag=pre+code %}
+typedef F = void Function(G);
+typedef G = void Function(int);
+{% endprettify %}
+
### type_annotation_deferred_class
_The deferred type '{0}' can't be used in a declaration, cast, or type test._
@@ -11938,6 +12689,58 @@
var a = A<int>();
{% endprettify %}
+### type_check_with_null
+
+_Tests for non-null should be done with '!= null'._
+
+_Tests for null should be done with '== null'._
+
+#### Description
+
+The analyzer produces this diagnostic when there's a type check (using the
+`as` operator) where the type is `Null`. There's only one value whose type
+is `Null`, so the code is both more readable and more performant when it
+tests for `null` explicitly.
+
+#### Example
+
+The following code produces this diagnostic because the code is testing to
+see whether the value of `s` is `null` by using a type check:
+
+{% prettify dart tag=pre+code %}
+void f(String? s) {
+ if ([!s is Null!]) {
+ return;
+ }
+ print(s);
+}
+{% endprettify %}
+
+The following code produces this diagnostic because the code is testing to
+see whether the value of `s` is something other than `null` by using a type
+check:
+
+{% prettify dart tag=pre+code %}
+void f(String? s) {
+ if ([!s is! Null!]) {
+ print(s);
+ }
+}
+{% endprettify %}
+
+#### Common fixes
+
+Replace the type check with the equivalent comparison with `null`:
+
+{% prettify dart tag=pre+code %}
+void f(String? s) {
+ if (s == null) {
+ return;
+ }
+ print(s);
+}
+{% endprettify %}
+
### type_parameter_referenced_by_static
_Static members can't reference type parameters of the class._
@@ -11980,6 +12783,50 @@
Note, however, that there isn’t a relationship between `T` and `S`, so this
second option changes the semantics from what was likely to be intended.
+### type_parameter_supertype_of_its_bound
+
+_'{0}' can't be a supertype of its upper bound._
+
+#### Description
+
+The analyzer produces this diagnostic when the bound of a type parameter
+(the type following the `extends` keyword) is either directly or indirectly
+the type parameter itself. Stating that the type parameter must be the same
+as itself or a subtype of itself or a subtype of itself isn't helpful
+because it will always be the same as itself.
+
+#### Example
+
+The following code produces this diagnostic because the bound of `T` is
+`T`:
+
+{% prettify dart tag=pre+code %}
+class C<[!T!] extends T> {}
+{% endprettify %}
+
+The following code produces this diagnostic because the bound of `T1` is
+`T2`, and the bound of `T2` is `T1`, effectively making the bound of `T1`
+be `T1`:
+
+{% prettify dart tag=pre+code %}
+class C<[!T1!] extends T2, T2 extends T1> {}
+{% endprettify %}
+
+#### Common fixes
+
+If the type parameter needs to be a subclass of some type, then replace the
+bound with the required type:
+
+{% prettify dart tag=pre+code %}
+class C<T extends num> {}
+{% endprettify %}
+
+If the type parameter can be any type, then remove the `extends` clause:
+
+{% prettify dart tag=pre+code %}
+class C<T> {}
+{% endprettify %}
+
### type_test_with_non_type
_The name '{0}' isn't a type and can't be used in an 'is' expression._
@@ -13130,6 +13977,42 @@
}
{% endprettify %}
+### unnecessary_dev_dependency
+
+_The dev dependency on {0} is unnecessary because there is also a normal
+dependency on that package._
+
+#### Description
+
+The analyzer produces this diagnostic when there's an entry under
+`dev_dependencies` for a package that is also listed under `dependencies`.
+The packages under `dependencies` are available to all of the code in the
+package, so there's no need to also list them under `dev_dependencies`.
+
+#### Example
+
+The following code produces this diagnostic because the package `meta` is
+listed under both `dependencies` and `dev_dependencies`:
+
+```yaml
+name: example
+dependencies:
+ meta: ^1.0.2
+dev_dependencies:
+ meta: ^1.0.2
+```
+
+#### Common fixes
+
+Remove the entry under `dev_dependencies` (and the `dev_dependencies` key
+if that's the only package listed there):
+
+```yaml
+name: example
+dependencies:
+ meta: ^1.0.2
+```
+
### unnecessary_non_null_assertion
_The '!' will have no effect because the receiver can't be null._
@@ -13159,6 +14042,54 @@
}
{% endprettify %}
+### unnecessary_no_such_method
+
+_Unnecessary 'noSuchMethod' declaration._
+
+#### Description
+
+The analyzer produces this diagnostic when there's a declaration of
+`noSuchMethod`, the only thing the declaration does is invoke the
+overridden declaration, and the overridden declaration isn't the
+declaration in `Object`.
+
+Overriding the implementation of `Object`'s `noSuchMethod` (no matter what
+the implementation does) signals to the analyzer that it shouldn't flag any
+inherited abstract methods that aren't implemented in that class. This
+works even if the overriding implementation is inherited from a superclass,
+so there's no value to declare it again in a subclass.
+
+#### Example
+
+The following code produces this diagnostic because the declaration of
+`noSuchMethod` in `A` makes the declaration of `noSuchMethod` in `B`
+unnecessary:
+
+{% prettify dart tag=pre+code %}
+class A {
+ @override
+ dynamic noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {
+ @override
+ dynamic [!noSuchMethod!](y) {
+ return super.noSuchMethod(y);
+ }
+}
+{% endprettify %}
+
+#### Common fixes
+
+Remove the unnecessary declaration:
+
+{% prettify dart tag=pre+code %}
+class A {
+ @override
+ dynamic noSuchMethod(x) => super.noSuchMethod(x);
+}
+class B extends A {}
+{% endprettify %}
+
### unnecessary_null_comparison
_The operand can't be null, so the condition is always false._
@@ -13917,6 +14848,95 @@
void f(C<int> x) {}
{% endprettify %}
+### wrong_number_of_type_arguments_constructor
+
+_The constructor '{0}.{1}' doesn't have type parameters._
+
+#### Description
+
+The analyzer produces this diagnostic when type arguments are provided
+after the name of a named constructor. Constructors can't declare type
+parameters, so invocations can only provide the type arguments associated
+with the class, and those type arguments are required to follow the name of
+the class rather than the name of the constructor.
+
+#### Example
+
+The following code produces this diagnostic because the type parameters
+(`<String>`) follow the name of the constructor rather than the name of the
+class:
+
+{% prettify dart tag=pre+code %}
+class C<T> {
+ C.named();
+}
+C f() => C.named[!<String>!]();
+{% endprettify %}
+
+#### Common fixes
+
+If the type arguments are for the class' type parameters, then move the
+type arguments to follow the class name:
+
+{% prettify dart tag=pre+code %}
+class C<T> {
+ C.named();
+}
+C f() => C<String>.named();
+{% endprettify %}
+
+If the type arguments aren't for the class' type parameters, then remove
+them:
+
+{% prettify dart tag=pre+code %}
+class C<T> {
+ C.named();
+}
+C f() => C.named();
+{% endprettify %}
+
+### wrong_number_of_type_arguments_extension
+
+_The extension '{0}' is declared with {1} type parameters, but {2} type
+arguments were given._
+
+#### Description
+
+The analyzer produces this diagnostic when an extension that has type
+parameters is used and type arguments are provided, but the number of type
+arguments isn't the same as the number of type parameters.
+
+#### Example
+
+The following code produces this diagnostic because the extension `E` is
+declared to have a single type parameter (`T`), but the extension override
+has two type arguments:
+
+{% prettify dart tag=pre+code %}
+extension E<T> on List<T> {
+ int get len => length;
+}
+
+void f(List<int> p) {
+ E[!<int, String>!](p).len;
+}
+{% endprettify %}
+
+#### Common fixes
+
+Change the type arguments so that there are the same number of type
+arguments as there are type parameters:
+
+{% prettify dart tag=pre+code %}
+extension E<T> on List<T> {
+ int get len => length;
+}
+
+void f(List<int> p) {
+ E<int>(p).len;
+}
+{% endprettify %}
+
### wrong_number_of_type_arguments_method
_The method '{0}' is declared with {1} type parameters, but {2} type arguments
@@ -13966,6 +14986,52 @@
int f(C c) => c.m(2);
{% endprettify %}
+### yield_in_non_generator
+
+_Yield statements must be in a generator function (one marked with either
+'async*' or 'sync*')._
+
+_Yield-each statements must be in a generator function (one marked with either
+'async*' or 'sync*')._
+
+#### Description
+
+The analyzer produces this diagnostic when a `yield` or `yield*` statement
+appears in a function whose body isn't marked with one of the `async*` or
+`sync*` modifiers.
+
+#### Example
+
+The following code produces this diagnostic because `yield` is being used
+in a function whose body doesn't have a modifier:
+
+{% prettify dart tag=pre+code %}
+Iterable<int> get digits {
+ yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+}
+{% endprettify %}
+
+The following code produces this diagnostic because `yield*` is being used
+in a function whose body has the `async` modifier rather than the `async*`
+modifier:
+
+{% prettify dart tag=pre+code %}
+Stream<int> get digits async {
+ yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+}
+{% endprettify %}
+
+#### Common fixes
+
+Add a modifier, or change the existing modifier to be either `async*` or
+`sync*`:
+
+{% prettify dart tag=pre+code %}
+Iterable<int> get digits sync* {
+ yield* [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+}
+{% endprettify %}
+
### yield_of_invalid_type
_The type '{0}' implied by the 'yield' expression must be assignable to '{1}'._
diff --git a/pkg/analyzer/tool/diagnostics/generate.dart b/pkg/analyzer/tool/diagnostics/generate.dart
index c19400f..00d1b88 100644
--- a/pkg/analyzer/tool/diagnostics/generate.dart
+++ b/pkg/analyzer/tool/diagnostics/generate.dart
@@ -33,10 +33,12 @@
[analyzerPath, 'lib', 'src', 'dart', 'error', 'hint_codes.dart'],
[analyzerPath, 'lib', 'src', 'dart', 'error', 'syntactic_errors.dart'],
[analyzerPath, 'lib', 'src', 'error', 'codes.dart'],
+ [analyzerPath, 'lib', 'src', 'pubspec', 'pubspec_warning_code.dart'],
], [
null,
[analyzerPath, 'lib', 'src', 'dart', 'error', 'syntactic_errors.g.dart'],
null,
+ null,
]);
}
diff --git a/pkg/dds/lib/src/dap/server.dart b/pkg/dds/lib/src/dap/server.dart
index 20f205e..2fe4ac5 100644
--- a/pkg/dds/lib/src/dap/server.dart
+++ b/pkg/dds/lib/src/dap/server.dart
@@ -15,8 +15,6 @@
/// A DAP server that binds to a port and runs in multi-session mode.
class DapServer {
- static const defaultPort = 9200;
-
final ServerSocket _socket;
final bool enableDds;
final bool enableAuthCodes;
diff --git a/pkg/dds/test/dap/integration/test_server.dart b/pkg/dds/test/dap/integration/test_server.dart
index 3680256..c2a11f7 100644
--- a/pkg/dds/test/dap/integration/test_server.dart
+++ b/pkg/dds/test/dap/integration/test_server.dart
@@ -6,15 +6,12 @@
import 'dart:convert';
import 'dart:io';
import 'dart:isolate';
-import 'dart:math' show Random;
import 'package:dds/src/dap/logging.dart';
import 'package:dds/src/dap/server.dart';
import 'package:path/path.dart' as path;
import 'package:pedantic/pedantic.dart';
-final _random = Random();
-
abstract class DapTestServer {
List<String> get errorLogs;
String get host;
@@ -53,14 +50,6 @@
/// but will be a little more difficult to debug tests as the debugger will not
/// be attached to the process.
class OutOfProcessDapTestServer extends DapTestServer {
- /// To avoid issues with port bindings if multiple test libraries are run
- /// concurrently (in their own processes), start from a random port between
- /// [DapServer.defaultPort] and [DapServer.defaultPort] + 5000.
- ///
- /// This number will then be increased should multiple libraries run within
- /// this same process.
- static var _nextPort = DapServer.defaultPort + _random.nextInt(5000);
-
var _isShuttingDown = false;
final Process _process;
final int port;
@@ -75,10 +64,7 @@
this.port,
Logger? logger,
) {
- // The DAP server should generally not write to stdout/stderr (unless -v is
- // passed), but it may do if it fails to start or crashes. If this happens,
- // and there's no logger, print to stdout.
- _process.stdout.transform(utf8.decoder).listen(logger ?? print);
+ // Treat anything written to stderr as the DAP crashing and fail the test.
_process.stderr.transform(utf8.decoder).listen((error) {
logger?.call(error);
_errors.add(error);
@@ -111,20 +97,37 @@
final dapServerScript =
path.join(ddsLibFolder, '../tool/dap/run_server.dart');
- final port = OutOfProcessDapTestServer._nextPort++;
- final host = 'localhost';
final _process = await Process.start(
Platform.resolvedExecutable,
[
dapServerScript,
'dap',
- '--host=$host',
- '--port=$port',
...?additionalArgs,
if (logger != null) '--verbose'
],
);
+ final startedCompleter = Completer<void>();
+ late String host;
+ late int port;
+
+ // Scrape the `started` event to get the host/port. Any other output
+ // should be sent to the logger (as it may be verbose output for diagnostic
+ // purposes).
+ _process.stdout.transform(utf8.decoder).listen((text) {
+ if (!startedCompleter.isCompleted) {
+ final event = jsonDecode(text);
+ if (event['state'] == 'started') {
+ host = event['dapHost'];
+ port = event['dapPort'];
+ startedCompleter.complete();
+ return;
+ }
+ }
+ logger?.call(text);
+ });
+ await startedCompleter.future;
+
return OutOfProcessDapTestServer._(_process, host, port, logger);
}
}
diff --git a/pkg/dds/tool/dap/run_server.dart b/pkg/dds/tool/dap/run_server.dart
index 32e08e6..b35a46d 100644
--- a/pkg/dds/tool/dap/run_server.dart
+++ b/pkg/dds/tool/dap/run_server.dart
@@ -2,6 +2,7 @@
// 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:convert';
import 'dart:io';
import 'package:args/command_runner.dart';
@@ -44,7 +45,7 @@
..addOption(
argPort,
abbr: 'p',
- defaultsTo: DapServer.defaultPort.toString(),
+ defaultsTo: '0',
help: 'The port to bind the server to',
)
..addFlag(
@@ -69,12 +70,18 @@
final port = int.parse(args[argPort]);
final host = args[argHost];
- await DapServer.create(
+ final server = await DapServer.create(
host: host,
port: port,
enableDdds: args[argDds],
enableAuthCodes: args[argAuthCodes],
logger: args[argVerbose] ? print : null,
);
+
+ stdout.write(jsonEncode({
+ 'state': 'started',
+ 'dapHost': server.host,
+ 'dapPort': server.port,
+ }));
}
}
diff --git a/pkg/vm/lib/transformations/type_flow/transformer.dart b/pkg/vm/lib/transformations/type_flow/transformer.dart
index 399d39a..47cce1b 100644
--- a/pkg/vm/lib/transformations/type_flow/transformer.dart
+++ b/pkg/vm/lib/transformations/type_flow/transformer.dart
@@ -9,6 +9,7 @@
import 'package:kernel/target/targets.dart';
import 'package:kernel/ast.dart' hide Statement, StatementVisitor;
+import 'package:kernel/clone.dart' show CloneVisitorNotMembers;
import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
import 'package:kernel/library_index.dart' show LibraryIndex;
@@ -56,6 +57,8 @@
Statistics.reset();
final analysisStopWatch = new Stopwatch()..start();
+ MoveFieldInitializers().transformComponent(component);
+
final typeFlowAnalysis = new TypeFlowAnalysis(
target,
component,
@@ -121,6 +124,77 @@
return component;
}
+// Move instance field initializers with possible side-effects
+// into constructors. This makes fields self-contained and
+// simplifies tree-shaking of fields.
+class MoveFieldInitializers {
+ void transformComponent(Component component) {
+ for (Library library in component.libraries) {
+ for (Class cls in library.classes) {
+ transformClass(cls);
+ }
+ }
+ }
+
+ void transformClass(Class cls) {
+ if (cls.fields.isEmpty) return;
+
+ // Collect instance fields with non-trivial initializers.
+ // Those will be moved into constructors.
+ final List<Field> fields = [
+ for (Field f in cls.fields)
+ if (!f.isStatic &&
+ !f.isLate &&
+ f.initializer != null &&
+ mayHaveSideEffects(f.initializer))
+ f
+ ];
+ if (fields.isEmpty) return;
+
+ // Collect non-redirecting constructors.
+ final List<Constructor> constructors = [
+ for (Constructor c in cls.constructors)
+ if (!_isRedirectingConstructor(c)) c
+ ];
+
+ assert(constructors.isNotEmpty);
+
+ // Move field initializers to constructors.
+ // Clone AST for all constructors except the first.
+ bool isFirst = true;
+ for (Constructor c in constructors) {
+ // Avoid duplicate FieldInitializers in the constructor initializer list.
+ final Set<Field> initializedFields = {
+ for (Initializer init in c.initializers)
+ if (init is FieldInitializer) init.field
+ };
+ final List<Initializer> newInitializers = [];
+ for (Field f in fields) {
+ Expression initExpr = f.initializer;
+ if (!isFirst) {
+ initExpr = CloneVisitorNotMembers().clone(initExpr);
+ }
+ final Initializer newInit = initializedFields.contains(f)
+ ? LocalInitializer(VariableDeclaration(null, initializer: initExpr))
+ : FieldInitializer(f, initExpr);
+ newInit.parent = c;
+ newInitializers.add(newInit);
+ }
+ newInitializers.addAll(c.initializers);
+ c.initializers = newInitializers;
+ isFirst = false;
+ }
+
+ // Cleanup field initializers.
+ for (Field f in fields) {
+ f.initializer = null;
+ }
+ }
+
+ bool _isRedirectingConstructor(Constructor c) =>
+ c.initializers.last is RedirectingInitializer;
+}
+
// Pass which removes all annotations except @ExternalName and @pragma
// on variables, members, classes and libraries.
// May also keep @TagNumber which is used by protobuf handler.
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_case1.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_case1.dart.expect
index e0e9ca7..ca4d73c 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_case1.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/class_generics_case1.dart.expect
@@ -10,9 +10,9 @@
;
}
class InheritedElement extends self::Element {
-[@vm.inferred-type.metadata=dart.collection::_InternalLinkedHashMap<#lib::Element*, dart.core::Object*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] final field core::Map<self::Element*, core::Object*>* _dependents = <self::Element*, core::Object*>{};
+[@vm.inferred-type.metadata=dart.collection::_InternalLinkedHashMap<#lib::Element*, dart.core::Object*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] final field core::Map<self::Element*, core::Object*>* _dependents;
synthetic constructor •() → self::InheritedElement*
- : super self::Element::•()
+ : self::InheritedElement::_dependents = <self::Element*, core::Object*>{}, super self::Element::•()
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:2,getterSelectorId:3] method setDependencies([@vm.inferred-type.metadata=!] self::Element* dependent, [@vm.inferred-type.metadata=dart.core::_Smi?] core::Object* value) → void {
[@vm.call-site-attributes.metadata=receiverType:dart.core::Map<#lib::Element*, dart.core::Object*>*] [@vm.direct-call.metadata=dart.collection::__InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.[]=] [@vm.inferred-type.metadata=!? (skip check)] [@vm.direct-call.metadata=#lib::InheritedElement._dependents] [@vm.inferred-type.metadata=dart.collection::_InternalLinkedHashMap<#lib::Element*, dart.core::Object*>] this.{self::InheritedElement::_dependents}{core::Map<self::Element*, core::Object*>*}.{core::Map::[]=}(dependent, value){(self::Element*, core::Object*) →* void};
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/instance_fields_with_initializers_nnbd.dart b/pkg/vm/testcases/transformations/type_flow/transformer/instance_fields_with_initializers_nnbd.dart
new file mode 100644
index 0000000..bb66a2b
--- /dev/null
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/instance_fields_with_initializers_nnbd.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2021, 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.
+
+// Test for tree shaking of instance fields with initializers.
+
+// @dart = 2.12
+
+int sideEffect(int x) {
+ print(x);
+ return x;
+}
+
+class A {
+ int f1 = sideEffect(1);
+ int f2 = sideEffect(2);
+ int f3 = 3;
+ static int f4 = sideEffect(40); // Not evaluated in constructor.
+ late int f5 = sideEffect(50); // Not evaluated in constructor.
+ late final int f6 = sideEffect(60); // Not evaluated in constructor.
+ int f7 = sideEffect(7); // Used/retained.
+ int f8 = sideEffect(8);
+
+ A(this.f8)
+ : f1 = sideEffect(100),
+ f2 = sideEffect(200);
+
+ A.foo() : this(800);
+ A.bar(this.f1) : f8 = sideEffect(801);
+}
+
+main() {
+ // Use all constructors.
+ A(-8);
+ A.foo();
+ A.bar(-1);
+
+ // Use f4, f5, f6, f7.
+ A obj = A.foo();
+ print(A.f4 + obj.f5 + obj.f6 + obj.f7);
+}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/instance_fields_with_initializers_nnbd.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/instance_fields_with_initializers_nnbd.dart.expect
new file mode 100644
index 0000000..ea029df
--- /dev/null
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/instance_fields_with_initializers_nnbd.dart.expect
@@ -0,0 +1,30 @@
+library #lib /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+[@vm.inferred-type.metadata=dart.core::_Smi?] static field core::int f4 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 40)] self::sideEffect(40);
+[@vm.inferred-type.metadata=dart.core::_Smi (value: 50)] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1,getterSelectorId:2] [@vm.unboxing-info.metadata=(i)->i] late field core::int f5 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 50)] self::sideEffect(50);
+[@vm.inferred-type.metadata=dart.core::_Smi (value: 60)] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] [@vm.unboxing-info.metadata=()->i] late final field core::int f6 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 60)] self::sideEffect(60);
+[@vm.inferred-type.metadata=dart.core::_Smi (value: 7)] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:4,getterSelectorId:5] [@vm.unboxing-info.metadata=(i)->i] field core::int f7;
+ constructor •() → self::A
+ : dynamic #t1 = self::sideEffect(1), dynamic #t2 = self::sideEffect(2), self::A::f7 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 7)] self::sideEffect(7), dynamic #t3 = self::sideEffect(8), dynamic #t4 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 100)] self::sideEffect(100), dynamic #t5 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 200)] self::sideEffect(200), super core::Object::•()
+ ;
+ constructor foo() → self::A
+ : this self::A::•()
+ ;
+ constructor bar() → self::A
+ : dynamic #t6 = self::sideEffect(1), dynamic #t7 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 2)] self::sideEffect(2), self::A::f7 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 7)] self::sideEffect(7), dynamic #t8 = self::sideEffect(8), dynamic #t9 = [@vm.inferred-type.metadata=dart.core::_Smi (value: 801)] self::sideEffect(801), super core::Object::•()
+ ;
+}
+[@vm.unboxing-info.metadata=(i)->i]static method sideEffect([@vm.inferred-type.metadata=dart.core::_Smi] core::int x) → core::int {
+ core::print(x);
+ return x;
+}
+static method main() → dynamic {
+ let final core::int #t10 = [@vm.direct-call.metadata=dart.core::_IntegerImplementation.unary-] [@vm.inferred-type.metadata=int (skip check)] 8.{core::int::unary-}(){() → core::int} in new self::A::•();
+ new self::A::foo();
+ let final core::int #t11 = [@vm.direct-call.metadata=dart.core::_IntegerImplementation.unary-] [@vm.inferred-type.metadata=int (skip check)] 1.{core::int::unary-}(){() → core::int} in new self::A::bar();
+ self::A obj = new self::A::foo();
+ core::print([@vm.direct-call.metadata=dart.core::_IntegerImplementation.+] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+] [@vm.inferred-type.metadata=int (skip check)] [@vm.direct-call.metadata=dart.core::_IntegerImplementation.+??] [@vm.inferred-type.metadata=int (skip check)] [@vm.inferred-type.metadata=dart.core::_Smi?] self::A::f4.{core::num::+}([@vm.direct-call.metadata=#lib::A.f5] [@vm.inferred-type.metadata=dart.core::_Smi (value: 50)] obj.{self::A::f5}{core::int}){(core::num) → core::int}.{core::num::+}([@vm.direct-call.metadata=#lib::A.f6] [@vm.inferred-type.metadata=dart.core::_Smi (value: 60)] obj.{self::A::f6}{core::int}){(core::num) → core::int}.{core::num::+}([@vm.direct-call.metadata=#lib::A.f7] [@vm.inferred-type.metadata=dart.core::_Smi (value: 7)] obj.{self::A::f7}{core::int}){(core::num) → core::int});
+}
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
index 9549477..43bee1f 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_field_initializer.dart.expect
@@ -43,9 +43,9 @@
return self::field1;
}
class D extends core::Object {
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] field core::Object* field2 = [@vm.inferred-type.metadata=!] self::getValue();
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:11,getterSelectorId:12] field core::Object* field2;
synthetic constructor •() → self::D*
- : super core::Object::•()
+ : self::D::field2 = [@vm.inferred-type.metadata=!] self::getValue(), super core::Object::•()
;
}
class DeepCaller2 extends core::Object {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
index 85add1b..8a434a8 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/invalidation_set_field.dart.expect
@@ -13,10 +13,10 @@
;
}
class A extends core::Object {
-[@vm.inferred-type.metadata=#lib::T1] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1,getterSelectorId:2] field dynamic field1 = new self::T1::•();
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3,getterSelectorId:4] field dynamic field2 = new self::T1::•();
+[@vm.inferred-type.metadata=#lib::T1] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1,getterSelectorId:2] field dynamic field1;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3,getterSelectorId:4] field dynamic field2;
synthetic constructor •() → self::A*
- : super core::Object::•()
+ : self::A::field1 = new self::T1::•(), self::A::field2 = new self::T1::•(), super core::Object::•()
;
}
class DeepCaller1 extends core::Object {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/lists.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/lists.dart.expect
index d772a44..7381c74 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/lists.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/lists.dart.expect
@@ -4,27 +4,27 @@
import "dart:_internal" as _in;
class A extends core::Object {
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] final field core::List<core::int*>* literal1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::•<core::int*>(0);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] final field core::List<core::int*>* literal2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::_literal3<core::int*>(1, 2, 3);
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] final field core::List<core::int*>* literal1;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] final field core::List<core::int*>* literal2;
[@vm.inferred-type.metadata=dart.core::_ImmutableList (value: const <dart.core::int*>[])] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] final field core::List<core::int*>* constLiteral1 = #C1;
[@vm.inferred-type.metadata=dart.core::_ImmutableList (value: const <dart.core::int*>[1, 2])] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] final field core::List<core::int*>* constLiteral2 = #C4;
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:5] final field core::List<core::int*>* defaultConstructor1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::•<core::int*>(0);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:6] final field core::List<core::int*>* defaultConstructor2 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::•<core::int*>(3);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:7] final field core::List<core::int*>* filledFactory1 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::filled<core::int*>(2, 0);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:8] final field core::List<core::int*>* filledFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::filled<core::int*>();
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:9] final field core::List<core::int*>* filledFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::filled<core::int*>(2, 0);
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:10] final field core::List<core::int*>* filledFactory4 = let final core::bool #t1 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int*>(2, 0, #t1);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:11] final field core::List<core::int*>* filledFactory5 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::•<core::int*>(2);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:12] final field core::List<core::int*>* filledFactory6 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::•<core::int*>(2);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:13] final field core::List<core::int*>* filledFactory7 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::•<core::int*>(2);
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:14] final field core::List<core::int*>* filledFactory8 = let final core::bool #t2 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int*>(2, null, #t2);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:15] final field core::List<core::int*>* generateFactory1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::generate<core::int*>(2, (core::int* i) → core::int* => i);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:16] final field core::List<core::int*>* generateFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::generate<core::int*>(2, (core::int* i) → core::int* => i);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:17] final field core::List<core::int*>* generateFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::generate<core::int*>((core::int* i) → core::int* => i);
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:18] final field core::List<core::int*>* generateFactory4 = let final (core::int*) →* core::int* #t3 = (core::int* i) → core::int* => i in let final core::bool #t4 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::generate<core::int*>(#t3, #t4);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int*>*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:19] final field core::List<core::List<core::int*>*>* generateFactory5 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int*>*>] core::_GrowableList::generate<core::List<core::int*>*>(2, (core::int* _) → core::List<core::int*>* => core::_GrowableList::•<core::int*>(0));
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:5] final field core::List<core::int*>* defaultConstructor1;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:6] final field core::List<core::int*>* defaultConstructor2;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:7] final field core::List<core::int*>* filledFactory1;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:8] final field core::List<core::int*>* filledFactory2;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:9] final field core::List<core::int*>* filledFactory3;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:10] final field core::List<core::int*>* filledFactory4;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:11] final field core::List<core::int*>* filledFactory5;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:12] final field core::List<core::int*>* filledFactory6;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:13] final field core::List<core::int*>* filledFactory7;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:14] final field core::List<core::int*>* filledFactory8;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:15] final field core::List<core::int*>* generateFactory1;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:16] final field core::List<core::int*>* generateFactory2;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:17] final field core::List<core::int*>* generateFactory3;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:18] final field core::List<core::int*>* generateFactory4;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int*>*>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:19] final field core::List<core::List<core::int*>*>* generateFactory5;
synthetic constructor •() → self::A*
- : super core::Object::•()
+ : self::A::literal1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::•<core::int*>(0), self::A::literal2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::_literal3<core::int*>(1, 2, 3), self::A::defaultConstructor1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::•<core::int*>(0), self::A::defaultConstructor2 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::•<core::int*>(3), self::A::filledFactory1 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::filled<core::int*>(2, 0), self::A::filledFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::filled<core::int*>(), self::A::filledFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::filled<core::int*>(2, 0), self::A::filledFactory4 = let final core::bool #t1 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int*>(2, 0, #t1), self::A::filledFactory5 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::•<core::int*>(2), self::A::filledFactory6 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::•<core::int*>(2), self::A::filledFactory7 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::•<core::int*>(2), self::A::filledFactory8 = let final core::bool #t2 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int*>(2, null, #t2), self::A::generateFactory1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::generate<core::int*>(2, (core::int* i) → core::int* => i), self::A::generateFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int*>] core::_GrowableList::generate<core::int*>(2, (core::int* i) → core::int* => i), self::A::generateFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int*>] core::_List::generate<core::int*>((core::int* i) → core::int* => i), self::A::generateFactory4 = let final (core::int*) →* core::int* #t3 = (core::int* i) → core::int* => i in let final core::bool #t4 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::generate<core::int*>(#t3, #t4), self::A::generateFactory5 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int*>*>] core::_GrowableList::generate<core::List<core::int*>*>(2, (core::int* _) → core::List<core::int*>* => core::_GrowableList::•<core::int*>(0)), super core::Object::•()
;
}
static method nonConstant() → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/lists_nnbd.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/lists_nnbd.dart.expect
index 893475a..3d34f1b 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/lists_nnbd.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/lists_nnbd.dart.expect
@@ -4,25 +4,25 @@
import "dart:_internal" as _in;
class A extends core::Object {
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] final field core::List<core::int> literal1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::•<core::int>(0);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] final field core::List<core::int> literal2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::_literal3<core::int>(1, 2, 3);
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:1] final field core::List<core::int> literal1;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] final field core::List<core::int> literal2;
[@vm.inferred-type.metadata=dart.core::_ImmutableList (value: const <dart.core::int*>[])] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] final field core::List<core::int> constLiteral1 = #C1;
[@vm.inferred-type.metadata=dart.core::_ImmutableList (value: const <dart.core::int*>[1, 2])] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] final field core::List<core::int> constLiteral2 = #C4;
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:5] final field core::List<core::int> filledFactory1 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] core::_List::filled<core::int>(2, 0);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:6] final field core::List<core::int> filledFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::filled<core::int>();
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:7] final field core::List<core::int> filledFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] core::_List::filled<core::int>(2, 0);
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:8] final field core::List<core::int> filledFactory4 = let final core::bool #t1 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int>(2, 0, #t1);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:9] final field core::List<core::int?> filledFactory5 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] core::_List::•<core::int?>(2);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int?>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:10] final field core::List<core::int?> filledFactory6 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int?>] core::_GrowableList::•<core::int?>(2);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:11] final field core::List<core::int?> filledFactory7 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] core::_List::•<core::int?>(2);
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:12] final field core::List<core::int?> filledFactory8 = let final core::bool #t2 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int?>(2, null, #t2);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:13] final field core::List<core::int> generateFactory1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::generate<core::int>(2, (core::int i) → core::int => i);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:14] final field core::List<core::int> generateFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::generate<core::int>(2, (core::int i) → core::int => i);
-[@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:15] final field core::List<core::int> generateFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] core::_List::generate<core::int>((core::int i) → core::int => i);
-[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:16] final field core::List<core::int> generateFactory4 = let final (core::int) → core::int #t3 = (core::int i) → core::int => i in let final core::bool #t4 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::generate<core::int>(#t3, #t4);
-[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int>>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:17] final field core::List<core::List<core::int>> generateFactory5 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int>>] core::_GrowableList::generate<core::List<core::int>>(2, (core::int _) → core::List<core::int> => core::_GrowableList::•<core::int>(0));
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:5] final field core::List<core::int> filledFactory1;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:6] final field core::List<core::int> filledFactory2;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:7] final field core::List<core::int> filledFactory3;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:8] final field core::List<core::int> filledFactory4;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:9] final field core::List<core::int?> filledFactory5;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int?>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:10] final field core::List<core::int?> filledFactory6;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:11] final field core::List<core::int?> filledFactory7;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:12] final field core::List<core::int?> filledFactory8;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:13] final field core::List<core::int> generateFactory1;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:14] final field core::List<core::int> generateFactory2;
+[@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:15] final field core::List<core::int> generateFactory3;
+[@vm.inferred-type.metadata=!] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:16] final field core::List<core::int> generateFactory4;
+[@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int>>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:17] final field core::List<core::List<core::int>> generateFactory5;
synthetic constructor •() → self::A
- : super core::Object::•()
+ : self::A::literal1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::•<core::int>(0), self::A::literal2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::_literal3<core::int>(1, 2, 3), self::A::filledFactory1 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] core::_List::filled<core::int>(2, 0), self::A::filledFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::filled<core::int>(), self::A::filledFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] core::_List::filled<core::int>(2, 0), self::A::filledFactory4 = let final core::bool #t1 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int>(2, 0, #t1), self::A::filledFactory5 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] core::_List::•<core::int?>(2), self::A::filledFactory6 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int?>] core::_GrowableList::•<core::int?>(2), self::A::filledFactory7 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int?>] core::_List::•<core::int?>(2), self::A::filledFactory8 = let final core::bool #t2 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::filled<core::int?>(2, null, #t2), self::A::generateFactory1 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::generate<core::int>(2, (core::int i) → core::int => i), self::A::generateFactory2 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::int>] core::_GrowableList::generate<core::int>(2, (core::int i) → core::int => i), self::A::generateFactory3 = [@vm.inferred-type.metadata=dart.core::_List<dart.core::int>] core::_List::generate<core::int>((core::int i) → core::int => i), self::A::generateFactory4 = let final (core::int) → core::int #t3 = (core::int i) → core::int => i in let final core::bool #t4 = _in::unsafeCast<core::bool>([@vm.inferred-type.metadata=dart.core::bool] self::nonConstant()) in [@vm.inferred-type.metadata=!] core::List::generate<core::int>(#t3, #t4), self::A::generateFactory5 = [@vm.inferred-type.metadata=dart.core::_GrowableList<dart.core::List<dart.core::int>>] core::_GrowableList::generate<core::List<core::int>>(2, (core::int _) → core::List<core::int> => core::_GrowableList::•<core::int>(0)), super core::Object::•()
;
}
static method nonConstant() → dynamic
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/regress_41452_nnbd_strong.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/regress_41452_nnbd_strong.dart.expect
index 5baaf9c..89b2f4f 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/regress_41452_nnbd_strong.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/regress_41452_nnbd_strong.dart.expect
@@ -18,7 +18,7 @@
: super core::Object::•()
;
[@vm.procedure-attributes.metadata=getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3,getterSelectorId:4] method add(generic-covariant-impl self::_SplayTree::Node n) → dynamic {
- self::_SplayTree::Node? root = [@vm.direct-call.metadata=#lib::SplayTreeMap._root] [@vm.inferred-type.metadata=#lib::_SplayTreeMapNode] this.{self::_SplayTree::_root}{self::_SplayTree::Node?};
+ self::_SplayTree::Node? root = [@vm.direct-call.metadata=#lib::SplayTreeMap._root] [@vm.inferred-type.metadata=#lib::_SplayTreeMapNode<dynamic>] this.{self::_SplayTree::_root}{self::_SplayTree::Node?};
if(false)
return;
core::print([@vm.direct-call.metadata=#lib::_SplayTreeNode.left] [@vm.inferred-type.metadata=dart.core::Null? (value: null)] root{self::_SplayTree::Node}.{self::_SplayTreeNode::left}{self::_SplayTree::Node?});
@@ -26,9 +26,9 @@
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:5] abstract get /*isLegacy*/ _root() → self::_SplayTree::Node?;
}
class SplayTreeMap<V extends core::Object? = dynamic> extends self::_SplayTree<self::_SplayTreeMapNode<self::SplayTreeMap::V%>> {
-[@vm.inferred-type.metadata=#lib::_SplayTreeMapNode] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:6,getterSelectorId:5] generic-covariant-impl field self::_SplayTreeMapNode<self::SplayTreeMap::V%>? _root = new self::_SplayTreeMapNode::•<self::SplayTreeMap::V%>();
+[@vm.inferred-type.metadata=#lib::_SplayTreeMapNode<dynamic>] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:6,getterSelectorId:5] generic-covariant-impl field self::_SplayTreeMapNode<self::SplayTreeMap::V%>? _root;
synthetic constructor •() → self::SplayTreeMap<self::SplayTreeMap::V%>
- : super self::_SplayTree::•()
+ : self::SplayTreeMap::_root = new self::_SplayTreeMapNode::•<self::SplayTreeMap::V%>(), super self::_SplayTree::•()
;
}
static method main() → void {
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter16182.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter16182.dart.expect
index 7937844..15a6a84 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter16182.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/regress_flutter16182.dart.expect
@@ -24,9 +24,9 @@
}
}
class B1 extends core::Object {
-[@vm.inferred-type.metadata=#lib::A1] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] field self::A1* aa1 = new self::A1::•();
+[@vm.inferred-type.metadata=#lib::A1] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] field self::A1* aa1;
synthetic constructor •() → self::B1*
- : super core::Object::•()
+ : self::B1::aa1 = new self::A1::•(), super core::Object::•()
;
}
class T2 extends core::Object {
@@ -47,9 +47,9 @@
}
}
abstract class B2Base extends core::Object {
-[@vm.inferred-type.metadata=#lib::A2] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:15,getterSelectorId:16] field dynamic _aa = new self::A2::•();
+[@vm.inferred-type.metadata=#lib::A2] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:15,getterSelectorId:16] field dynamic _aa;
synthetic constructor •() → self::B2Base*
- : super core::Object::•()
+ : self::B2Base::_aa = new self::A2::•(), super core::Object::•()
;
[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:17] get aa2() → dynamic
return [@vm.direct-call.metadata=#lib::B2Base._aa] [@vm.inferred-type.metadata=#lib::A2] this.{self::B2Base::_aa}{dynamic};
@@ -80,9 +80,9 @@
}
}
class B3 extends core::Object {
-[@vm.inferred-type.metadata=#lib::A3] [@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:26,getterSelectorId:27] field self::A3* aa3 = new self::A3::•();
+[@vm.inferred-type.metadata=#lib::A3] [@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:26,getterSelectorId:27] field self::A3* aa3;
synthetic constructor •() → self::B3*
- : super core::Object::•()
+ : self::B3::aa3 = new self::A3::•(), super core::Object::•()
;
}
class T4 extends core::Object {
@@ -103,9 +103,9 @@
}
}
class B4 extends core::Object {
-[@vm.inferred-type.metadata=#lib::A4] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:34,getterSelectorId:35] field dynamic _aa = new self::A4::•();
+[@vm.inferred-type.metadata=#lib::A4] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:34,getterSelectorId:35] field dynamic _aa;
synthetic constructor •() → self::B4*
- : super core::Object::•()
+ : self::B4::_aa = new self::A4::•(), super core::Object::•()
;
[@vm.procedure-attributes.metadata=hasThisUses:false,hasTearOffUses:false,getterSelectorId:36] get aa4() → dynamic
return [@vm.direct-call.metadata=#lib::B4._aa] [@vm.inferred-type.metadata=#lib::A4] this.{self::B4::_aa}{dynamic};
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect
index 0fdf157..cc689dc 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field.dart.expect
@@ -9,10 +9,10 @@
}
}
class C extends core::Object {
-[@vm.inferred-type.metadata=#lib::B?] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1,getterSelectorId:2] field self::B* instanceField = new self::B::•();
synthetic constructor •() → self::C*
- : super core::Object::•()
+ : dynamic #t1 = new self::B::•(), super core::Object::•()
;
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1] set instanceField(self::B* value) → void;
}
static method main() → void {
null;
diff --git a/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field2.dart.expect b/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field2.dart.expect
index 9fe5d89..6e40a3c 100644
--- a/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field2.dart.expect
+++ b/pkg/vm/testcases/transformations/type_flow/transformer/write_only_field2.dart.expect
@@ -6,49 +6,48 @@
import "package:expect/expect.dart";
class A extends core::Object {
-[@vm.inferred-type.metadata=dart.core::Null? (value: null)] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1,getterSelectorId:2] field dynamic unused3 = [@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::foo();
synthetic constructor •() → self::A*
- : super core::Object::•()
+ : dynamic #t1 = [@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::foo(), super core::Object::•()
;
}
class B extends core::Object {
constructor •() → self::B*
- : dynamic #t1 = [@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::foo(), super core::Object::•()
+ : dynamic #t2 = [@vm.inferred-type.metadata=dart.core::Null? (value: null)] self::foo(), super core::Object::•()
;
}
abstract class C<T extends core::Object* = dynamic> extends core::Object {
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3] abstract set bar(generic-covariant-impl self::C::T* value) → void;
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1] abstract set bar(generic-covariant-impl self::C::T* value) → void;
}
class D extends core::Object implements self::C<core::int*> {
synthetic constructor •() → self::D*
: super core::Object::•()
;
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:3] set bar(generic-covariant-impl core::int* value) → void;
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:1] set bar(generic-covariant-impl core::int* value) → void;
}
abstract class E extends core::Object {
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] [@vm.unboxing-info.metadata=()->i] abstract get bar() → core::int*;
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] [@vm.unboxing-info.metadata=()->i] abstract get bar() → core::int*;
}
class F extends core::Object implements self::E {
synthetic constructor •() → self::F*
: super core::Object::•()
;
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:4] [@vm.unboxing-info.metadata=()->i] get bar() → core::int*
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:2] [@vm.unboxing-info.metadata=()->i] get bar() → core::int*
return 42;
}
class G extends core::Object /*hasConstConstructor*/ {
-[@vm.inferred-type.metadata=dart.core::_Smi] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:5] [@vm.unboxing-info.metadata=()->i] final field core::int* bazz;
+[@vm.inferred-type.metadata=dart.core::_Smi] [@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasNonThisUses:false,hasTearOffUses:false,getterSelectorId:3] [@vm.unboxing-info.metadata=()->i] final field core::int* bazz;
}
abstract class H extends core::Object {
synthetic constructor •() → self::H*
: super core::Object::•()
;
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:6] set unused6(core::int* value) → void;
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasNonThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:4] set unused6(core::int* value) → void;
}
class I extends self::H {
synthetic constructor •() → self::I*
: super self::H::•()
;
-[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:7,getterSelectorId:8] method foo() → dynamic {
+[@vm.procedure-attributes.metadata=methodOrSetterCalledDynamically:false,getterCalledDynamically:false,hasThisUses:false,hasTearOffUses:false,methodOrSetterSelectorId:5,getterSelectorId:6] method foo() → dynamic {
super.{self::H::unused6} = 3;
}
}
@@ -61,7 +60,7 @@
[@vm.call-site-attributes.metadata=receiverType:#lib::C<dart.core::num*>*] [@vm.direct-call.metadata=#lib::D.bar] c.{self::C::bar} = 3.14;
});
self::E* e = new self::F::•();
- let final core::int* #t2 = [@vm.direct-call.metadata=#lib::F.bar] [@vm.inferred-type.metadata=dart.core::_Smi (value: 42)] e.{self::E::bar}{core::int*} in exp::Expect::equals();
+ let final core::int* #t3 = [@vm.direct-call.metadata=#lib::F.bar] [@vm.inferred-type.metadata=dart.core::_Smi (value: 42)] e.{self::E::bar}{core::int*} in exp::Expect::equals();
exp::Expect::isTrue(![@vm.inferred-type.metadata=dart.core::bool] core::identical(#C2, #C4));
[@vm.direct-call.metadata=#lib::I.foo] [@vm.inferred-type.metadata=!? (skip check)] new self::I::•().{self::I::foo}(){() →* dynamic};
5;
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index fa6cc2a..bc87833 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -153,7 +153,28 @@
}
}
- if (!is_win) {
+ # Below are flags copied from ../build/config/compiler/BUILD.gn that should
+ # be preserved even when the Dart VM and runtime are compiled out-of-tree,
+ # for example in the Flutter Engine build. They ensure that the Dart VM
+ # and runtime are compiled with optimizations unless explicitly requested
+ # otherwise with the `dart_debug` and `dart_debug_optimization_level`
+ # flags.
+ if (is_win) {
+ if (dart_debug) {
+ cflags = [
+ "/O${dart_debug_optimization_level}",
+ "/Oy-",
+ ]
+ } else {
+ cflags = [
+ "/O2",
+ "/Ob2",
+ "/Oy-",
+ "/Oi",
+ "/Gw",
+ ]
+ }
+ } else {
cflags = [
"-Werror",
"-Wall",
diff --git a/runtime/tests/concurrency/generate_stress_test.dart b/runtime/tests/concurrency/generate_stress_test.dart
index 27610e4..e1616f0 100644
--- a/runtime/tests/concurrency/generate_stress_test.dart
+++ b/runtime/tests/concurrency/generate_stress_test.dart
@@ -57,40 +57,41 @@
''');
}
sb.writeln('');
- sb.writeln('final List<dynamic Function(dynamic)> wrappers = [');
+ sb.writeln(r'''
+ class Test {
+ final String name;
+ final dynamic Function(dynamic) fun;
+ Test(this.name, this.fun);
+ }
+ ''');
+ sb.writeln('final List<Test> tests = [');
for (int i = 0; i < testFiles.length; ++i) {
final testFile = testFiles[i];
- sb.writeln(' wrapper$i,');
- }
- sb.writeln('];');
- sb.writeln('final List<String> wrapperNames = [');
- for (int i = 0; i < testFiles.length; ++i) {
- final testFile = testFiles[i];
- sb.writeln(' "$testFile",');
+ sb.writeln(' Test("$testFile", wrapper$i),');
}
sb.writeln('];');
sb.writeln('');
+
sb.writeln('''
class Runner {
static const progressEvery = 100;
- final List<String> testNames;
- final List<dynamic Function(dynamic)> tests;
+ final List<Test> tests;
late final ReceivePort onExit;
late final List<ReceivePort> onExits;
late final List<ReceivePort> onErrors;
- Runner(this.testNames, this.tests) {
+ Runner(this.tests) {
onExit = ReceivePort();
onExits = List<ReceivePort>.generate(tests.length, (int i) {
return ReceivePort()..listen((_) {
- print('[\${testNames[i]}] finished');
+ print('[\${tests[i].name}] finished');
onExit.sendPort.send(null);
});
});
onErrors = List<ReceivePort>.generate(tests.length, (int i) {
return ReceivePort()..listen((error) {
- print('[\${testNames[i]}] error: \$error');
+ print('[\${tests[i].name}] error: \$error');
});
});
}
@@ -98,7 +99,7 @@
Future runWithUnlimitedParallelism() async {
for (int i = 0; i < tests.length; ++i) {
await Isolate.spawn(
- tests[i],
+ tests[i].fun,
null,
onExit: onExits[i].sendPort,
onError: onErrors[i].sendPort);
@@ -112,7 +113,7 @@
Future run() async {
final int current = _current++;
await Isolate.spawn(
- tests[current],
+ tests[current].fun,
null,
onExit: onExits[current].sendPort,
onError: onErrors[current].sendPort);
@@ -142,10 +143,22 @@
}
main() async {
- const int parallelism = const int.fromEnvironment(
+ final shards = int.fromEnvironment(
+ 'shards', defaultValue: 1);
+ final shard = int.fromEnvironment(
+ 'shard', defaultValue: 0);
+
+ final parallelism = int.fromEnvironment(
'parallelism', defaultValue: 0);
- final runner = Runner(wrapperNames, wrappers);
+ final filteredTests = <Test>[];
+ for (int i = 0; i < tests.length; ++i) {
+ if ((i % shards) == shard) {
+ filteredTests.add(tests[i]);
+ }
+ }
+
+ final runner = Runner(filteredTests);
if (parallelism <= 0) {
await runner.runWithUnlimitedParallelism();
} else {
diff --git a/runtime/tests/concurrency/run_stress_test_shards.dart b/runtime/tests/concurrency/run_stress_test_shards.dart
index d2cd67f..4ec29cf 100644
--- a/runtime/tests/concurrency/run_stress_test_shards.dart
+++ b/runtime/tests/concurrency/run_stress_test_shards.dart
@@ -6,8 +6,6 @@
import 'dart:convert';
import 'dart:io';
import 'dart:io' as io;
-import 'dart:isolate';
-import 'dart:math';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;
@@ -73,6 +71,8 @@
}
}
+const int tsanShards = 200;
+
final configurations = <TestRunner>[
JitTestRunner('out/DebugX64', [
'--disable-dart-dev',
@@ -91,13 +91,16 @@
'--deoptimize-on-runtime-call-every=3',
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
]),
- JitTestRunner('out/ReleaseTSANX64', [
- '--disable-dart-dev',
- '--no-sound-null-safety',
- '--enable-isolate-groups',
- '--experimental-enable-isolate-groups-jit',
- 'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
- ]),
+ for (int i = 0; i < tsanShards; ++i)
+ JitTestRunner('out/ReleaseTSANX64', [
+ '--disable-dart-dev',
+ '-Dshard=$i',
+ '-Dshards=$tsanShards',
+ '--no-sound-null-safety',
+ '--enable-isolate-groups',
+ '--experimental-enable-isolate-groups-jit',
+ 'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
+ ]),
AotTestRunner('out/ReleaseX64', [
'--no-sound-null-safety',
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
diff --git a/runtime/vm/heap/scavenger.cc b/runtime/vm/heap/scavenger.cc
index adbac5d..cf52ef4 100644
--- a/runtime/vm/heap/scavenger.cc
+++ b/runtime/vm/heap/scavenger.cc
@@ -219,7 +219,6 @@
scavenger_->IterateRoots(this);
} else {
ASSERT(scavenger_->abort_);
- thread_->ClearStickyError();
}
}
@@ -233,7 +232,6 @@
} while (HasWork());
} else {
ASSERT(scavenger_->abort_);
- thread_->ClearStickyError();
}
}
@@ -249,7 +247,6 @@
} while (HasWork());
} else {
ASSERT(scavenger_->abort_);
- thread_->ClearStickyError();
}
}
@@ -475,7 +472,9 @@
OS::PrintErr("Aborting scavenge\n");
}
scavenger_->abort_ = true;
- thread_->long_jump_base()->Jump(1, Object::out_of_memory_error());
+ // N.B. We must not set the sticky error, which may be a data race if
+ // that root slot was processed by a different worker.
+ thread_->long_jump_base()->Jump(1);
}
inline void ProcessToSpace();
diff --git a/runtime/vm/longjump.cc b/runtime/vm/longjump.cc
index e56106c..c778dc7 100644
--- a/runtime/vm/longjump.cc
+++ b/runtime/vm/longjump.cc
@@ -20,10 +20,18 @@
}
void LongJumpScope::Jump(int value, const Error& error) {
+ ASSERT(!error.IsNull());
+
+ // Remember the error in the sticky error of this isolate.
+ Thread::Current()->set_sticky_error(error);
+
+ Jump(value);
+}
+
+void LongJumpScope::Jump(int value) {
// A zero is the default return value from setting up a LongJumpScope
// using Set.
ASSERT(value != 0);
- ASSERT(!error.IsNull());
Thread* thread = Thread::Current();
DEBUG_ASSERT(thread->TopErrorHandlerIsSetJump());
@@ -35,9 +43,6 @@
#undef CHECK_REUSABLE_HANDLE
#endif // defined(DEBUG)
- // Remember the error in the sticky error of this isolate.
- thread->set_sticky_error(error);
-
// Destruct all the active StackResource objects.
StackResource::UnwindAbove(thread, top_);
longjmp(environment_, value);
diff --git a/runtime/vm/longjump.h b/runtime/vm/longjump.h
index a334f15..c551584 100644
--- a/runtime/vm/longjump.h
+++ b/runtime/vm/longjump.h
@@ -30,6 +30,7 @@
jmp_buf* Set();
DART_NORETURN void Jump(int value, const Error& error);
+ DART_NORETURN void Jump(int value);
private:
jmp_buf environment_;
diff --git a/sdk/lib/_http/http.dart b/sdk/lib/_http/http.dart
index 4a6c80d..47e481a 100644
--- a/sdk/lib/_http/http.dart
+++ b/sdk/lib/_http/http.dart
@@ -1593,7 +1593,7 @@
* [url].
*
* The `Host` header for the request will be set to the value
- * [Uri.host]:[Uri.port] from [url] (if [url.host] is an IP address, it will
+ * [Uri.host]:[Uri.port] from [url] (if `url.host` is an IP address, it will
* still be used in the `Host` header). This can be overridden through the
* [HttpClientRequest] interface before the request is sent.
*
@@ -1724,7 +1724,8 @@
* authentication.
*
* The URL requested, the authentication scheme and the security realm
- * from the server are passed in the arguments [url], [scheme] and [realm].
+ * from the server are passed in the arguments [f.url], [f.scheme] and
+ * [f.realm].
*
* The function returns a [Future] which should complete when the
* authentication has been resolved. If credentials cannot be
@@ -1844,7 +1845,7 @@
*
* Information on the proxy in use, the authentication scheme
* and the security realm for the authentication
- * are passed in the arguments [host], [port], [scheme] and [realm].
+ * are passed in the arguments [f.host], [f.port], [f.scheme] and [f.realm].
*
* The function returns a [Future] which should complete when the
* authentication has been resolved. If credentials cannot be
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart
index edc6264..2952ad3 100644
--- a/sdk/lib/async/future.dart
+++ b/sdk/lib/async/future.dart
@@ -717,7 +717,7 @@
/// unless the same future is awaited (or otherwise handled) elsewhere too.
/// Because of that, `unawaited` should only be used for futures that
/// are *expected* to complete with a value.
-/// You can use [FutureExtension.ignore] if you also don't want to know
+/// You can use [FutureExtensions.ignore] if you also don't want to know
/// about errors from this future.
@Since("2.15")
void unawaited(Future<void> future) {}
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart
index 07f1e2b..d4aed3f 100644
--- a/sdk/lib/collection/list.dart
+++ b/sdk/lib/collection/list.dart
@@ -35,7 +35,7 @@
///
/// Converts [list] to a string by converting each element to a string (by
/// calling [Object.toString]), joining them with ", ", and wrapping the
- /// result in "[" and "]".
+ /// result in `[` and `]`.
///
/// Handles circular references where converting one of the elements
/// to a string ends up converting [list] to a string again.
diff --git a/sdk/lib/collection/queue.dart b/sdk/lib/collection/queue.dart
index bb545b9..97252ba56 100644
--- a/sdk/lib/collection/queue.dart
+++ b/sdk/lib/collection/queue.dart
@@ -22,7 +22,7 @@
/// Creates a queue containing all [elements].
///
/// The element order in the queue is as if the elements were added using
- /// [addLast] in the order provided by [elements.iterator].
+ /// [addLast] in the order provided by [elements].iterator.
///
/// All the [elements] should be instances of [E].
/// The `elements` iterable itself may have any element type, so this
@@ -37,7 +37,7 @@
/// Creates a queue from [elements].
///
/// The element order in the queue is as if the elements were added using
- /// [addLast] in the order provided by [elements.iterator].
+ /// [addLast] in the order provided by [elements].iterator.
factory Queue.of(Iterable<E> elements) = ListQueue<E>.of;
/// Adapts [source] to be a `Queue<T>`.
@@ -278,11 +278,11 @@
/// Creates a double-linked queue containing all [elements].
///
/// The element order in the queue is as if the elements were added using
- /// [addLast] in the order provided by [elements.iterator].
+ /// [addLast] in the order provided by [elements].iterator.
///
/// All the [elements] should be instances of [E].
- /// The `elements` iterable itself may have any element type, so this
- /// constructor can be used to down-cast a `Queue`, for example as:
+ /// The [elements] iterable itself may have any element type, so this
+ /// constructor can be used to down-cast a [Queue], for example as:
/// ```dart
/// Queue<SuperType> superQueue = ...;
/// Queue<SubType> subQueue =
@@ -299,7 +299,7 @@
/// Creates a double-linked queue from [elements].
///
/// The element order in the queue is as if the elements were added using
- /// [addLast] in the order provided by [elements.iterator].
+ /// [addLast] in the order provided by [elements].iterator.
factory DoubleLinkedQueue.of(Iterable<E> elements) =>
DoubleLinkedQueue<E>()..addAll(elements);
diff --git a/sdk/lib/core/date_time.dart b/sdk/lib/core/date_time.dart
index 9c17ad6..ab353ba 100644
--- a/sdk/lib/core/date_time.dart
+++ b/sdk/lib/core/date_time.dart
@@ -717,7 +717,7 @@
/// ```
external int get year;
- /// The month [1..12].
+ /// The month `[1..12]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
@@ -726,7 +726,7 @@
/// ```
external int get month;
- /// The day of the month [1..31].
+ /// The day of the month `[1..31]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
@@ -734,7 +734,7 @@
/// ```
external int get day;
- /// The hour of the day, expressed as in a 24-hour clock [0..23].
+ /// The hour of the day, expressed as in a 24-hour clock `[0..23]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
@@ -742,7 +742,7 @@
/// ```
external int get hour;
- /// The minute [0...59].
+ /// The minute `[0...59]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
@@ -750,7 +750,7 @@
/// ```
external int get minute;
- /// The second [0...59].
+ /// The second `[0...59]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
@@ -758,7 +758,7 @@
/// ```
external int get second;
- /// The millisecond [0...999].
+ /// The millisecond `[0...999]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
@@ -766,7 +766,7 @@
/// ```
external int get millisecond;
- /// The microsecond [0...999].
+ /// The microsecond `[0...999]`.
///
/// ```dart
/// var moonLanding = DateTime.parse("1969-07-20 20:18:04Z");
diff --git a/sdk/lib/core/list.dart b/sdk/lib/core/list.dart
index 0014c2e..42db5d5 100644
--- a/sdk/lib/core/list.dart
+++ b/sdk/lib/core/list.dart
@@ -197,7 +197,7 @@
/// The range from [start] to [end] must be a valid range of [source],
/// and there must be room for `end - start` elements from position [at].
/// If [start] is omitted, it defaults to zero.
- /// If [end] is omitted, it defaults to [source.length].
+ /// If [end] is omitted, it defaults to [source].length.
///
/// If [source] and [target] is the same list, overlapping source and target
/// ranges are respected so that the target range ends up containing the
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart
index 7d22b20..2f955df 100644
--- a/sdk/lib/core/uri.dart
+++ b/sdk/lib/core/uri.dart
@@ -59,8 +59,8 @@
///
/// The host part of the authority component is set through
/// [host]. The host can either be a hostname, an IPv4 address or an
- /// IPv6 address, contained in '[' and ']'. If the host contains a
- /// ':' character, the '[' and ']' are added if not already provided.
+ /// IPv6 address, contained in `'['` and `']'`. If the host contains a
+ /// ':' character, the `'['` and `']'` are added if not already provided.
/// The host is normalized to all lowercase letters.
///
/// The port part of the authority component is set through
@@ -101,17 +101,17 @@
///
/// The percent-encoding of the keys and values encodes all characters
/// except for the unreserved characters, and replaces spaces with `+`.
- /// If `query` is the empty string, it is equivalent to omitting it.
+ /// If [query] is the empty string, it is equivalent to omitting it.
/// To have an actual empty query part,
- /// use an empty map for `queryParameters`.
+ /// use an empty map for [queryParameters].
///
- /// If both `query` and `queryParameters` are omitted or `null`,
+ /// If both [query] and [queryParameters] are omitted or `null`,
/// the URI has no query part.
///
/// The fragment component is set through [fragment].
/// It should be a valid URI fragment, but invalid characters other than
/// general delimiters, are escaped if necessary.
- /// If `fragment` is omitted or `null`, the URI has no fragment part.
+ /// If [fragment] is omitted or `null`, the URI has no fragment part.
factory Uri(
{String? scheme,
String? userInfo,
diff --git a/sdk/lib/developer/profiler.dart b/sdk/lib/developer/profiler.dart
index db0ae1d..66560f2 100644
--- a/sdk/lib/developer/profiler.dart
+++ b/sdk/lib/developer/profiler.dart
@@ -47,7 +47,7 @@
}
/// A measured value with a min and max. Initial value is min. Value will
-/// be clamped to the interval [min, max].
+/// be clamped to the interval `[min, max]`.
class Gauge extends Metric {
final double min;
final double max;
diff --git a/sdk/lib/ffi/dynamic_library.dart b/sdk/lib/ffi/dynamic_library.dart
index 0a4ee2e..737f28c 100644
--- a/sdk/lib/ffi/dynamic_library.dart
+++ b/sdk/lib/ffi/dynamic_library.dart
@@ -40,7 +40,7 @@
/// call.
///
/// The symbol must be provided by the dynamic library. To check whether
- /// the library provides such symbol, use [hasSymbol].
+ /// the library provides such symbol, use [providesSymbol].
external Pointer<T> lookup<T extends NativeType>(String symbolName);
/// Checks whether this dynamic library provides a symbol with the given
diff --git a/sdk/lib/ffi/struct.dart b/sdk/lib/ffi/struct.dart
index de45d6d..0a249f8 100644
--- a/sdk/lib/ffi/struct.dart
+++ b/sdk/lib/ffi/struct.dart
@@ -27,7 +27,7 @@
/// field in memory.
///
/// All field declarations in a [Struct] subclass declaration must either have
-/// type [int] or [float] and be annotated with a [NativeType] representing the
+/// type [int] or [double] and be annotated with a [NativeType] representing the
/// native type, or must be of type [Pointer]. For example:
///
/// ```c
diff --git a/sdk/lib/ffi/union.dart b/sdk/lib/ffi/union.dart
index d0c7a66..60242fe 100644
--- a/sdk/lib/ffi/union.dart
+++ b/sdk/lib/ffi/union.dart
@@ -14,7 +14,7 @@
/// field in memory.
///
/// All field declarations in a [Union] subclass declaration must either have
-/// type [int] or [float] and be annotated with a [NativeType] representing the
+/// type [int] or [double] and be annotated with a [NativeType] representing the
/// native type, or must be of type [Pointer]. For example:
///
/// ```c
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 6ade06e..7f6f21b 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -11,6 +11,7 @@
* For information on writing web apps with Dart, see https://dart.dev/web.
*
* {@category Web}
+ * {@canonicalFor dart:_internal.HttpStatus}
*/
library dart.dom.html;
@@ -2269,7 +2270,9 @@
/**
* An opaque canvas object representing a gradient.
*
- * Created by calling [createLinearGradient] or [createRadialGradient] on a
+ * Created by calling the methods
+ * [CanvasRenderingContext2D.createLinearGradient] or
+ * [CanvasRenderingContext2D.createRadialGradient] on a
* [CanvasRenderingContext2D] object.
*
* Example usage:
@@ -2321,7 +2324,8 @@
/**
* An opaque object representing a pattern of image, canvas, or video.
*
- * Created by calling [createPattern] on a [CanvasRenderingContext2D] object.
+ * Created by calling [CanvasRenderingContext2D.createPattern] on a
+ * [CanvasRenderingContext2D] object.
*
* Example usage:
*
@@ -2955,7 +2959,7 @@
* options, such as typeface and size, and the current
* [CanvasRenderingContext2D.fillStyle] for style options such as color.
* The current [CanvasRenderingContext2D.textAlign] and
- * [CanvasRenderingContext2D.textBaseLine] properties are also applied to the
+ * [CanvasRenderingContext2D.textBaseline] properties are also applied to the
* drawn text.
*/
void fillText(String text, num x, num y, [num? maxWidth]) {
@@ -11935,7 +11939,7 @@
CssStyleDeclarationBase get style;
/**
- * Access dimensions and position of the Elements in this list.
+ * Access dimensions and position of the [Element]s in this list.
*
* Setting the height or width properties will set the height or width
* property for all elements in the list. This returns a rectangle with the
@@ -11944,46 +11948,48 @@
* property. Getting the height or width returns the height or width of the
* first Element in this list.
*
- * Unlike [getBoundingClientRect], the dimensions of this rectangle
+ * Unlike [Element.getBoundingClientRect], the dimensions of this rectangle
* will return the same numerical height if the element is hidden or not.
*/
CssRect get contentEdge;
/**
- * Access dimensions and position of the first Element's content + padding box
- * in this list.
+ * Access dimensions and position of the first [Element]'s content + padding
+ * box in this list.
*
* This returns a rectangle with the dimensions actually available for content
* in this element, in pixels, regardless of this element's box-sizing
- * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
- * will return the same numerical height if the element is hidden or not. This
- * can be used to retrieve jQuery's `innerHeight` value for an element. This
- * is also a rectangle equalling the dimensions of clientHeight and
- * clientWidth.
+ * property. Unlike [Element.getBoundingClientRect], the dimensions of this
+ * rectangle will return the same numerical height if the element is hidden
+ * or not. This can be used to retrieve jQuery's `innerHeight` value for an
+ * element. This is also a rectangle equalling the dimensions of clientHeight
+ * and clientWidth.
*/
CssRect get paddingEdge;
/**
- * Access dimensions and position of the first Element's content + padding +
+ * Access dimensions and position of the first [Element]'s content + padding +
* border box in this list.
*
* This returns a rectangle with the dimensions actually available for content
* in this element, in pixels, regardless of this element's box-sizing
- * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
- * will return the same numerical height if the element is hidden or not. This
- * can be used to retrieve jQuery's `outerHeight` value for an element.
+ * property. Unlike [Element.getBoundingClientRect], the dimensions of this
+ * rectangle will return the same numerical height if the element is hidden
+ * or not. This can be used to retrieve jQuery's `outerHeight` value for an
+ * element.
*/
CssRect get borderEdge;
/**
- * Access dimensions and position of the first Element's content + padding +
+ * Access dimensions and position of the first [Element]'s content + padding +
* border + margin box in this list.
*
* This returns a rectangle with the dimensions actually available for content
* in this element, in pixels, regardless of this element's box-sizing
- * property. Unlike [getBoundingClientRect], the dimensions of this rectangle
- * will return the same numerical height if the element is hidden or not. This
- * can be used to retrieve jQuery's `outerHeight` value for an element.
+ * property. Unlike [Element.getBoundingClientRect], the dimensions of this
+ * rectangle will return the same numerical height if the element is hidden
+ * or not. This can be used to retrieve jQuery's `outerHeight` value for an
+ * element.
*/
CssRect get marginEdge;
@@ -13274,9 +13280,9 @@
*
* The [frames] parameter is an Iterable<Map>, where the
* map entries specify CSS animation effects. The
- * [timing] paramter can be a double, representing the number of milliseconds
- * for the transition, or a Map with fields corresponding to those
- * of the [Timing] object.
+ * [timing] parameter can be a double, representing the number of
+ * milliseconds for the transition, or a Map with fields corresponding to
+ * those of the [timing] object.
*/
@SupportedBrowser(SupportedBrowser.CHROME, '36')
Animation animate(Iterable<Map<String, dynamic>> frames, [timing]) {
@@ -13429,12 +13435,14 @@
* * 'beforeEnd': As the last child of this element.
* * 'afterEnd': Immediately after this element.
*
+ * ```dart
* var html = '<div class="something">content</div>';
* // Inserts as the first child
* document.body.insertAdjacentHtml('afterBegin', html);
* var createdElement = document.body.children[0];
* print(createdElement.classes[0]); // Prints 'something'
- *
+ * ```
+ *
* See also:
*
* * [insertAdjacentText]
@@ -18107,7 +18115,7 @@
* * Using credentials is only useful for cross-origin requests.
* * The `Access-Control-Allow-Origin` header of `url` cannot contain a wildcard (*).
* * The `Access-Control-Allow-Credentials` header of `url` must be set to true.
- * * If `Access-Control-Expose-Headers` has not been set to true, only a subset of all the response headers will be returned when calling [getAllRequestHeaders].
+ * * If `Access-Control-Expose-Headers` has not been set to true, only a subset of all the response headers will be returned when calling [getAllResponseHeaders].
*
* The following is equivalent to the [getString] sample above:
*
@@ -18507,7 +18515,8 @@
* Length of time in milliseconds before a request is automatically
* terminated.
*
- * When the time has passed, a [TimeoutEvent] is dispatched.
+ * When the time has passed, a [HttpRequestEventTarget.timeoutEvent] is
+ * dispatched.
*
* If [timeout] is set to 0, then the request will not time out.
*
@@ -18525,7 +18534,6 @@
/**
* [EventTarget] that can hold listeners to track the progress of the request.
- * The events fired will be members of [HttpRequestUploadEvents].
*/
@Unstable()
HttpRequestUpload get upload native;
@@ -19747,7 +19755,7 @@
}
/**
- * A control that when used with other [ReadioButtonInputElement] controls
+ * A control that when used with other [RadioButtonInputElement] controls
* forms a radio button group in which only one control can be checked at a
* time.
*
@@ -23367,7 +23375,7 @@
* * [COMMENT_NODE] if this node is a [Comment].
* * [DOCUMENT_FRAGMENT_NODE] if this node is a [DocumentFragment].
* * [DOCUMENT_NODE] if this node is a [Document].
- * * [DOCUMENT_TYPE_NODE] if this node is a [DocumentType] node.
+ * * [DOCUMENT_TYPE_NODE] if this node is a [_DocumentType] node.
* * [ELEMENT_NODE] if this node is an [Element].
* * [ENTITY_NODE] if this node is an entity.
* * [ENTITY_REFERENCE_NODE] if this node is an entity reference.
@@ -31669,7 +31677,7 @@
* The message event handler receives a [MessageEvent] object
* as its sole argument.
* You can also define open, close, and error handlers,
- * as specified by [WebSocketEvents].
+ * as specified by [Event]s.
*
* For more information, see the
* [WebSockets](http://www.dartlang.org/docs/library-tour/#html-websockets)
@@ -32186,8 +32194,8 @@
/**
* Gets an instance of the Indexed DB factory to being using Indexed DB.
*
- * Use [indexed_db.IdbFactory.supported] to check if Indexed DB is supported on the
- * current platform.
+ * Use [dart:indexed_db.IdbFactory.supported] to check if Indexed DB is
+ * supported on the current platform.
*/
@SupportedBrowser(SupportedBrowser.CHROME, '23.0')
@SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
@@ -36520,8 +36528,8 @@
*
* This is equivalent to the `height` function in jQuery and the calculated
* `height` CSS value, converted to a dimensionless num in pixels. Unlike
- * [getBoundingClientRect], `height` will return the same numerical width if
- * the element is hidden or not.
+ * [Element.getBoundingClientRect], `height` will return the same numerical
+ * width if the element is hidden or not.
*/
num get height;
@@ -36530,8 +36538,8 @@
*
* This is equivalent to the `width` function in jQuery and the calculated
* `width` CSS value, converted to a dimensionless num in pixels. Unlike
- * [getBoundingClientRect], `width` will return the same numerical width if
- * the element is hidden or not.
+ * [Element.getBoundingClientRect], `width` will return the same numerical
+ * width if the element is hidden or not.
*/
num get width;
@@ -37092,7 +37100,7 @@
new _EventStream<T>(e, _eventType, useCapture);
/**
- * Gets an [ElementEventStream] for this event type, on the specified element.
+ * Gets an [Stream] for this event type, on the specified element.
*
* This will always return a broadcast stream so multiple listeners can be
* used simultaneously.
diff --git a/sdk/lib/io/file.dart b/sdk/lib/io/file.dart
index 29b2810..05ecf7a 100644
--- a/sdk/lib/io/file.dart
+++ b/sdk/lib/io/file.dart
@@ -659,10 +659,10 @@
///
/// Reads bytes and writes then into the the range of [buffer]
/// from [start] to [end].
- /// The [start] must be non-negative and no greater than `buffer.length`.
- /// If [end] is omitted, it defaults to [buffer.length].
+ /// The [start] must be non-negative and no greater than [buffer].length.
+ /// If [end] is omitted, it defaults to [buffer].length.
/// Otherwise [end] must be no less than [start]
- /// and no greater than `buffer.length`.
+ /// and no greater than [buffer].length.
///
/// Returns the number of bytes read. This maybe be less than `end - start`
/// if the file doesn't have that many bytes to read.
@@ -672,10 +672,10 @@
///
/// Reads bytes and writes then into the the range of [buffer]
/// from [start] to [end].
- /// The [start] must be non-negative and no greater than `buffer.length`.
- /// If [end] is omitted, it defaults to [buffer.length].
+ /// The [start] must be non-negative and no greater than [buffer].length.
+ /// If [end] is omitted, it defaults to [buffer].length.
/// Otherwise [end] must be no less than [start]
- /// and no greater than `buffer.length`.
+ /// and no greater than [buffer].length.
///
/// Returns the number of bytes read. This maybe be less than `end - start`
/// if the file doesn't have that many bytes to read.
@@ -699,10 +699,10 @@
/// Writes from a [buffer] to the file.
///
/// Will read the buffer from index [start] to index [end].
- /// The [start] must be non-negative and no greater than `buffer.length`.
- /// If [end] is omitted, it defaults to [buffer.length].
+ /// The [start] must be non-negative and no greater than [buffer].length.
+ /// If [end] is omitted, it defaults to [buffer].length.
/// Otherwise [end] must be no less than [start]
- /// and no greater than `buffer.length`.
+ /// and no greater than [buffer].length.
///
/// Returns a `Future<RandomAccessFile>` that completes with this
/// [RandomAccessFile] when the write completes.
@@ -712,10 +712,10 @@
/// Synchronously writes from a [buffer] to the file.
///
/// Will read the buffer from index [start] to index [end].
- /// The [start] must be non-negative and no greater than `buffer.length`.
- /// If [end] is omitted, it defaults to [buffer.length].
+ /// The [start] must be non-negative and no greater than [buffer].length.
+ /// If [end] is omitted, it defaults to [buffer].length.
/// Otherwise [end] must be no less than [start]
- /// and no greater than `buffer.length`.
+ /// and no greater than [buffer].length.
///
/// Throws a [FileSystemException] if the operation fails.
void writeFromSync(List<int> buffer, [int start = 0, int? end]);
diff --git a/sdk/lib/io/process.dart b/sdk/lib/io/process.dart
index ccb9b44..81bf8e0 100644
--- a/sdk/lib/io/process.dart
+++ b/sdk/lib/io/process.dart
@@ -30,7 +30,7 @@
/// The handling of exit codes is platform specific.
///
/// On Linux and OS X an exit code for normal termination will always
-/// be in the range [0..255]. If an exit code outside this range is
+/// be in the range `[0..255]`. If an exit code outside this range is
/// set the actual exit code will be the lower 8 bits masked off and
/// treated as an unsigned value. E.g. using an exit code of -1 will
/// result in an actual exit code of 255 being reported.
@@ -244,8 +244,8 @@
/// The handling of exit codes is platform specific.
///
/// On Linux and OS X a normal exit code will be a positive value in
- /// the range [0..255]. If the process was terminated due to a signal
- /// the exit code will be a negative value in the range [-255..-1],
+ /// the range `[0..255]`. If the process was terminated due to a signal
+ /// the exit code will be a negative value in the range `[-255..-1]`,
/// where the absolute value of the exit code is the signal
/// number. For example, if a process crashes due to a segmentation
/// violation the exit code will be -11, as the signal SIGSEGV has the
diff --git a/sdk/lib/io/sync_socket.dart b/sdk/lib/io/sync_socket.dart
index e1e47e5..c5296df 100644
--- a/sdk/lib/io/sync_socket.dart
+++ b/sdk/lib/io/sync_socket.dart
@@ -38,10 +38,10 @@
///
/// Reads bytes and writes then into the the range of [buffer]
/// from [start] to [end].
- /// The [start] must be non-negative and no greater than `buffer.length`.
- /// If [end] is omitted, it defaults to [buffer.length].
+ /// The [start] must be non-negative and no greater than [buffer].length.
+ /// If [end] is omitted, it defaults to [buffer].length.
/// Otherwise [end] must be no less than [start]
- /// and no greater than `buffer.length`.
+ /// and no greater than [buffer].length.
///
/// Returns the number of bytes read. This maybe be less than `end - start`
/// if the file doesn't have that many bytes to read.
@@ -66,10 +66,10 @@
/// Writes from a [buffer] to the socket.
///
/// Will read the buffer from index [start] to index [end].
- /// The [start] must be non-negative and no greater than `buffer.length`.
- /// If [end] is omitted, it defaults to [buffer.length].
+ /// The [start] must be non-negative and no greater than [buffer].length.
+ /// If [end] is omitted, it defaults to [buffer].length.
/// Otherwise [end] must be no less than [start]
- /// and no greater than `buffer.length`.
+ /// and no greater than [buffer].length.
void writeFromSync(List<int> buffer, [int start = 0, int? end]);
/// The port used by this socket.
diff --git a/sdk/lib/mirrors/mirrors.dart b/sdk/lib/mirrors/mirrors.dart
index 8363b4a..a10dd80 100644
--- a/sdk/lib/mirrors/mirrors.dart
+++ b/sdk/lib/mirrors/mirrors.dart
@@ -390,8 +390,8 @@
* Let *o* be the object reflected by this mirror, let *f* be the simple name
* of the member denoted by [memberName], let *a1, ..., an* be the elements
* of [positionalArguments], let *k1, ..., km* be the identifiers denoted by
- * the elements of [namedArguments.keys], and let *v1, ..., vm* be the
- * elements of [namedArguments.values]. Then this method will perform the
+ * the elements of [namedArguments].keys, and let *v1, ..., vm* be the
+ * elements of [namedArguments].values. Then this method will perform the
* method invocation *o.f(a1, ..., an, k1: v1, ..., km: vm)* in a scope that
* has access to the private members of *o* (if *o* is a class or library) or
* the private members of the class of *o* (otherwise).
@@ -581,8 +581,8 @@
* Let *f* be the closure reflected by this mirror,
* let *a1, ..., an* be the elements of [positionalArguments],
* let *k1, ..., km* be the identifiers denoted by the elements of
- * [namedArguments.keys],
- * and let *v1, ..., vm* be the elements of [namedArguments.values].
+ * [namedArguments].keys,
+ * and let *v1, ..., vm* be the elements of [namedArguments].values.
*
* Then this method will perform the method invocation
* *f(a1, ..., an, k1: v1, ..., km: vm)*.
@@ -850,8 +850,8 @@
* Let *c* be the class reflected by this mirror,
* let *a1, ..., an* be the elements of [positionalArguments],
* let *k1, ..., km* be the identifiers denoted by the elements of
- * [namedArguments.keys],
- * and let *v1, ..., vm* be the elements of [namedArguments.values].
+ * [namedArguments].keys,
+ * and let *v1, ..., vm* be the elements of [namedArguments].values.
*
* If [constructorName] was created from the empty string, then this method
* will execute the instance creation expression
diff --git a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
index a12d2fe..506f9e6 100644
--- a/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
+++ b/sdk/lib/web_audio/dart2js/web_audio_dart2js.dart
@@ -1242,9 +1242,9 @@
/**
* Get a Stream that fires events when AudioProcessingEvents occur.
* This particular stream is special in that it only allows one listener to a
- * given stream. Converting the returned Stream [asBroadcast] will likely ruin
- * the soft-real-time properties which which these events are fired and can
- * be processed.
+ * given stream. Converting the returned [Stream.asBroadcastStream] will
+ * likely ruin the soft-real-time properties which which these events are
+ * fired and can be processed.
*/
Stream<AudioProcessingEvent> get onAudioProcess =>
audioProcessEvent.forTarget(this);
diff --git a/tests/language/operator/number_operator_typing_test.dart b/tests/language/operator/number_operator_typing_test.dart
index a6fcd7d..dcbacf3 100644
--- a/tests/language/operator/number_operator_typing_test.dart
+++ b/tests/language/operator/number_operator_typing_test.dart
@@ -1002,6 +1002,50 @@
}
}
+/// Creative combinations of types.
+void testComplex<I extends int, D extends double, N extends num,
+ O extends Object, NN extends N>(I i, D d, N n, O o, NN nn) {
+ O p = 1 as O;
+ if (p is! N) throw "promote to O&N";
+ if (p is! NN) throw "promote to O&N&NN";
+
+ checkIntersectionType<O, N>(p, p, p);
+ checkIntersectionType<N, NN>(p, p, p);
+
+ var result01 = p + p;
+ result01.expectStaticType<Exactly<num>>();
+
+ var clamp01 = p.clamp(p, p);
+ clamp01.expectStaticType<Exactly<num>>();
+
+ // Having different unrelated subtypes of int.
+ // Return the first operand's type.
+ N ni = n;
+ if (ni is! int) throw "promote ni to N&int";
+ (i + ni).expectStaticType<Exactly<int>>();
+ (i - ni).expectStaticType<Exactly<int>>();
+ (i * ni).expectStaticType<Exactly<int>>();
+ (i % ni).expectStaticType<Exactly<int>>();
+ i.remainder(ni).expectStaticType<Exactly<int>>();
+
+ // Use LUB for clamp.
+ i.clamp(ni, ni).expectStaticType<Exactly<int>>();
+ i.clamp(ni, i).expectStaticType<Exactly<int>>();
+
+ // Having different unrelated subtypes of double.
+ N nd = 1.0 as N;
+ if (nd is! double) throw "promote nd to N&double";
+ (d + nd).expectStaticType<Exactly<double>>();
+ (d - nd).expectStaticType<Exactly<double>>();
+ (d * nd).expectStaticType<Exactly<double>>();
+ (d % nd).expectStaticType<Exactly<double>>();
+ d.remainder(nd).expectStaticType<Exactly<double>>();
+
+ (d.clamp(nd, nd)).expectStaticType<Exactly<double>>();
+ (d.clamp(nd, d)).expectStaticType<Exactly<double>>();
+ (nd.clamp(d, d)).expectStaticType<Exactly<double>>();
+}
+
/// Perform constant operations and check that they are still valid.
class TestConst<I extends int, D extends double, N extends num> {
static const dynamic dyn = 1;
diff --git a/tools/VERSION b/tools/VERSION
index 70d8216..2a65555 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 252
+PRERELEASE 253
PRERELEASE_PATCH 0
\ No newline at end of file