Version 2.17.0-196.0.dev
Merge commit 'fc2ebe73108b3697230dc49815ba203518bf73db' into 'dev'
diff --git a/pkg/analysis_server/lib/src/protocol_server.dart b/pkg/analysis_server/lib/src/protocol_server.dart
index 9b829c7..7f8d2e5 100644
--- a/pkg/analysis_server/lib/src/protocol_server.dart
+++ b/pkg/analysis_server/lib/src/protocol_server.dart
@@ -14,7 +14,6 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/diagnostic/diagnostic.dart' as engine;
import 'package:analyzer/error/error.dart' as engine;
-import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/source/error_processor.dart';
import 'package:analyzer/src/generated/source.dart' as engine;
import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -299,25 +298,16 @@
/// Creates a new [Location].
Location _locationForArgs(
engine.CompilationUnitElement unitElement, engine.SourceRange range) {
- var startLine = 0;
- var startColumn = 0;
- var endLine = 0;
- var endColumn = 0;
- try {
- var lineInfo = unitElement.lineInfo;
- if (lineInfo != null) {
- var startLocation = lineInfo.getLocation(range.offset);
- startLine = startLocation.lineNumber;
- startColumn = startLocation.columnNumber;
+ var lineInfo = unitElement.lineInfo;
- var endLocation = lineInfo.getLocation(range.end);
- endLine = endLocation.lineNumber;
- endColumn = endLocation.columnNumber;
- }
- } on AnalysisException {
- // TODO(brianwilkerson) It doesn't look like the code in the try block
- // should be able to throw an exception. Try removing the try statement.
- }
+ var startLocation = lineInfo.getLocation(range.offset);
+ var endLocation = lineInfo.getLocation(range.end);
+
+ var startLine = startLocation.lineNumber;
+ var startColumn = startLocation.columnNumber;
+ var endLine = endLocation.lineNumber;
+ var endColumn = endLocation.columnNumber;
+
return Location(unitElement.source.fullName, range.offset, range.length,
startLine, startColumn,
endLine: endLine, endColumn: endColumn);
diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
index f818710..0a88729 100644
--- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
+++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
@@ -1956,13 +1956,6 @@
notes: |-
We can't guess at the names or number of the enum constants that should be
added.
-ParserErrorCode.ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS:
- status: noFix
- since: 2.17
- notes: |-
- We could potentially add `()`, but we generally don't have fixes for parse
- errors because we assume the user is still typing and will soon fix the
- problem.
ParserErrorCode.ENUM_IN_CLASS:
status: needsEvaluation
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND:
diff --git a/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart b/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart
index d066ac5..8a49420 100644
--- a/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart
+++ b/pkg/analysis_server/lib/src/services/snippets/dart/dart_snippet_producers.dart
@@ -2,12 +2,208 @@
// 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/util.dart';
+import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:analysis_server/src/services/snippets/dart/snippet_manager.dart';
import 'package:analyzer/src/dart/analysis/session_helper.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/lint/linter.dart' show LinterContextImpl;
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
+/// Produces a [Snippet] that creates a `do while` loop.
+class DartDoWhileLoopSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'do';
+ static const label = 'do while';
+
+ DartDoWhileLoopSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ builder.writeln('do {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndented('} while (');
+ builder.addEmptyLinkedEdit('expression');
+ builder.write(');');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert a do-while loop.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartDoWhileLoopSnippetProducer newInstance(
+ DartSnippetRequest request) =>
+ DartDoWhileLoopSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates a `for in` loop.
+class DartForInLoopSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'forin';
+ static const label = 'for in';
+
+ DartForInLoopSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+ final varOrFinal =
+ isLintEnabled(LintNames.prefer_final_locals) ? 'final' : 'var';
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ builder.write('for ($varOrFinal ');
+ builder.addEmptyLinkedEdit('variableName');
+ builder.write(' in ');
+ builder.addEmptyLinkedEdit('collectionName');
+ builder.writeln(') {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert a for-in loop.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartForInLoopSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartForInLoopSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates a `for` loop.
+class DartForLoopSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'for';
+ static const label = 'for';
+
+ DartForLoopSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ builder.write('for (var i = 0; i < ');
+ builder.addEmptyLinkedEdit('count');
+ builder.writeln('; i++) {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert a for loop.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartForLoopSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartForLoopSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates an if/else statement.
+class DartIfElseSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'ife';
+ static const label = 'ife';
+
+ DartIfElseSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ void writeIndentedln(String string) =>
+ builder.writeln('$indent$string');
+ builder.write('if (');
+ builder.addEmptyLinkedEdit('condition');
+ builder.writeln(') {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndentedln('} else {');
+ writeIndentedln(' ');
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert an if/else statement.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartIfElseSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartIfElseSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates an if statement.
+class DartIfSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'if';
+ static const label = 'if';
+
+ DartIfSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ builder.write('if (');
+ builder.addEmptyLinkedEdit('condition');
+ builder.writeln(') {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert an if statement.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartIfSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartIfSnippetProducer._(request);
+}
+
/// Produces a [Snippet] that creates a top-level `main` function.
///
/// A `List<String> args` parameter will be included when generating inside a
@@ -16,7 +212,8 @@
static const prefix = 'main';
static const label = 'main()';
- DartMainFunctionSnippetProducer(DartSnippetRequest request) : super(request);
+ DartMainFunctionSnippetProducer._(DartSnippetRequest request)
+ : super(request);
/// Whether to insert a `List<String> args` parameter in the generated
/// function.
@@ -64,13 +261,144 @@
static DartMainFunctionSnippetProducer newInstance(
DartSnippetRequest request) =>
- DartMainFunctionSnippetProducer(request);
+ DartMainFunctionSnippetProducer._(request);
}
abstract class DartSnippetProducer extends SnippetProducer {
final AnalysisSessionHelper sessionHelper;
+ final CorrectionUtils utils;
DartSnippetProducer(DartSnippetRequest request)
: sessionHelper = AnalysisSessionHelper(request.analysisSession),
+ utils = CorrectionUtils(request.unit),
super(request);
+
+ bool isLintEnabled(String name) {
+ var analysisOptions = sessionHelper.session.analysisContext.analysisOptions;
+ return analysisOptions.isLintEnabled(name);
+ }
+}
+
+/// Produces a [Snippet] that creates an if statement.
+class DartSwitchSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'switch';
+ static const label = 'switch case';
+
+ DartSwitchSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ void writeIndentedln(String string) =>
+ builder.writeln('$indent$string');
+ builder.write('switch (');
+ builder.addEmptyLinkedEdit('expression');
+ builder.writeln(') {');
+ writeIndented(' case ');
+ builder.addEmptyLinkedEdit('value');
+ builder.writeln(':');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndentedln(' break;');
+ writeIndentedln(' default:');
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert a switch statement.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartSwitchSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartSwitchSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates a try/catch statement.
+class DartTryCatchSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'try';
+ static const label = 'try';
+
+ DartTryCatchSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ void writeIndentedln(String string) =>
+ builder.writeln('$indent$string');
+ builder.writeln('try {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndented('} catch (');
+ builder.addLinkedEdit('exceptionName', (builder) {
+ builder.write('e');
+ });
+ builder.writeln(') {');
+ writeIndentedln(' ');
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert a try/catch statement.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartTryCatchSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartTryCatchSnippetProducer._(request);
+}
+
+/// Produces a [Snippet] that creates a `while` loop.
+class DartWhileLoopSnippetProducer extends DartSnippetProducer {
+ static const prefix = 'while';
+ static const label = 'while';
+
+ DartWhileLoopSnippetProducer._(DartSnippetRequest request) : super(request);
+
+ @override
+ Future<Snippet> compute() async {
+ final builder = ChangeBuilder(session: request.analysisSession);
+ final indent = utils.getLinePrefix(request.offset);
+
+ await builder.addDartFileEdit(request.filePath, (builder) {
+ builder.addReplacement(request.replacementRange, (builder) {
+ void writeIndented(String string) => builder.write('$indent$string');
+ builder.write('while (');
+ builder.addEmptyLinkedEdit('expression');
+ builder.writeln(') {');
+ writeIndented(' ');
+ builder.selectHere();
+ builder.writeln();
+ writeIndented('}');
+ });
+ });
+
+ return Snippet(
+ prefix,
+ label,
+ 'Insert a while loop.',
+ builder.sourceChange,
+ );
+ }
+
+ static DartWhileLoopSnippetProducer newInstance(DartSnippetRequest request) =>
+ DartWhileLoopSnippetProducer._(request);
}
diff --git a/pkg/analysis_server/lib/src/services/snippets/dart/flutter_snippet_producers.dart b/pkg/analysis_server/lib/src/services/snippets/dart/flutter_snippet_producers.dart
index 9792d8e..90b520d 100644
--- a/pkg/analysis_server/lib/src/services/snippets/dart/flutter_snippet_producers.dart
+++ b/pkg/analysis_server/lib/src/services/snippets/dart/flutter_snippet_producers.dart
@@ -53,7 +53,7 @@
late ClassElement? classBuildContext;
late ClassElement? classKey;
- FlutterStatefulWidgetSnippetProducer(DartSnippetRequest request)
+ FlutterStatefulWidgetSnippetProducer._(DartSnippetRequest request)
: super(request);
@override
@@ -172,7 +172,7 @@
static FlutterStatefulWidgetSnippetProducer newInstance(
DartSnippetRequest request) =>
- FlutterStatefulWidgetSnippetProducer(request);
+ FlutterStatefulWidgetSnippetProducer._(request);
}
/// Produces a [Snippet] that creates a Flutter StatefulWidget with a
@@ -189,7 +189,7 @@
late ClassElement? classAnimationController;
late ClassElement? classSingleTickerProviderStateMixin;
- FlutterStatefulWidgetWithAnimationControllerSnippetProducer(
+ FlutterStatefulWidgetWithAnimationControllerSnippetProducer._(
DartSnippetRequest request)
: super(request);
@@ -358,7 +358,8 @@
static FlutterStatefulWidgetWithAnimationControllerSnippetProducer
newInstance(DartSnippetRequest request) =>
- FlutterStatefulWidgetWithAnimationControllerSnippetProducer(request);
+ FlutterStatefulWidgetWithAnimationControllerSnippetProducer._(
+ request);
}
/// Produces a [Snippet] that creates a Flutter StatelessWidget.
@@ -370,7 +371,7 @@
late ClassElement? classBuildContext;
late ClassElement? classKey;
- FlutterStatelessWidgetSnippetProducer(DartSnippetRequest request)
+ FlutterStatelessWidgetSnippetProducer._(DartSnippetRequest request)
: super(request);
@override
@@ -465,5 +466,5 @@
static FlutterStatelessWidgetSnippetProducer newInstance(
DartSnippetRequest request) =>
- FlutterStatelessWidgetSnippetProducer(request);
+ FlutterStatelessWidgetSnippetProducer._(request);
}
diff --git a/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart b/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart
index 5c6d87d..4972b2d 100644
--- a/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart
+++ b/pkg/analysis_server/lib/src/services/snippets/dart/snippet_manager.dart
@@ -28,7 +28,17 @@
FlutterStatefulWidgetSnippetProducer.newInstance,
FlutterStatefulWidgetWithAnimationControllerSnippetProducer.newInstance,
FlutterStatelessWidgetSnippetProducer.newInstance,
- ]
+ ],
+ SnippetContext.inBlock: [
+ DartDoWhileLoopSnippetProducer.newInstance,
+ DartForInLoopSnippetProducer.newInstance,
+ DartForLoopSnippetProducer.newInstance,
+ DartIfElseSnippetProducer.newInstance,
+ DartIfSnippetProducer.newInstance,
+ DartSwitchSnippetProducer.newInstance,
+ DartTryCatchSnippetProducer.newInstance,
+ DartWhileLoopSnippetProducer.newInstance,
+ ],
};
Future<List<Snippet>> computeSnippets(
diff --git a/pkg/analysis_server/test/analysis/notification_errors_test.dart b/pkg/analysis_server/test/analysis/notification_errors_test.dart
index e2aa4c7..491d5b9 100644
--- a/pkg/analysis_server/test/analysis/notification_errors_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_errors_test.dart
@@ -92,9 +92,12 @@
expect(error.type, AnalysisErrorType.STATIC_WARNING);
// Write a package file that allows resolving the include.
- newDotPackagesFile(projectPath, content: '''
-pedantic:${pedanticFolder.toUri()}
-''');
+ newPackageConfigJsonFile(
+ projectPath,
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'pedantic', rootPath: pedanticFolder.parent.path))
+ .toContent(toUriStr: toUriStr),
+ );
// Ensure the errors disappear.
await waitForTasksFinished();
diff --git a/pkg/analysis_server/test/analysis/set_priority_files_test.dart b/pkg/analysis_server/test/analysis/set_priority_files_test.dart
index c39b2c1..9d3c505 100644
--- a/pkg/analysis_server/test/analysis/set_priority_files_test.dart
+++ b/pkg/analysis_server/test/analysis/set_priority_files_test.dart
@@ -83,8 +83,8 @@
}
Future<void> test_ignoredInAnalysisOptions_inChildContext() async {
- newDotPackagesFile(projectPath);
- newDotPackagesFile('$projectPath/child');
+ newPackageConfigJsonFile(projectPath);
+ newPackageConfigJsonFile('$projectPath/child');
var sampleFile = convertPath('$projectPath/child/samples/sample.dart');
newFile('$projectPath/child/${file_paths.analysisOptionsYaml}',
content: r'''
@@ -99,8 +99,8 @@
}
Future<void> test_ignoredInAnalysisOptions_inRootContext() async {
- newDotPackagesFile(projectPath);
- newDotPackagesFile('$projectPath/child');
+ newPackageConfigJsonFile(projectPath);
+ newPackageConfigJsonFile('$projectPath/child');
var sampleFile = convertPath('$projectPath/child/samples/sample.dart');
newFile('$projectPath/${file_paths.analysisOptionsYaml}', content: r'''
analyzer:
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index e2b363c..229f1ca 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -236,41 +236,6 @@
assertNoErrors(b_path);
}
- Future<void> test_fileSystem_addFile_dotPackagesFile() async {
- deleteTestPackageConfigJsonFile();
- var aaaLibPath = '/packages/aaa/lib';
- var a_path = '$aaaLibPath/a.dart';
-
- newFile(a_path, content: '''
-class A {}
-''');
-
- newFile(testFilePath, content: '''
-import 'package:aaa/a.dart';
-void f(A a) {}
-''');
-
- await setRoots(included: [workspaceRootPath], excluded: []);
- await server.onAnalysisComplete;
-
- // We cannot resolve `package:aaa/a.dart`
- assertHasErrors(testFilePath);
-
- // Write `.packages`, recreate analysis contexts.
- newDotPackagesFile(testPackageRootPath, content: '''
-aaa:${toUriStr(aaaLibPath)}
-''');
-
- await pumpEventQueue();
- await server.onAnalysisComplete;
-
- // We have `A` in 'package:aaa/a.dart', so no errors.
- assertNoErrors(testFilePath);
-
- // errors are not reported for packages
- assertNoErrorsNotification(a_path);
- }
-
Future<void> test_fileSystem_addFile_fixDataYaml() async {
var path = '$testPackageLibPath/fix_data.yaml';
@@ -564,44 +529,6 @@
assertNoErrors(b_path);
}
- Future<void> test_fileSystem_changeFile_dotPackagesFile() async {
- deleteTestPackageConfigJsonFile();
- var aaaLibPath = '/packages/aaa/lib';
- var a_path = '$aaaLibPath/a.dart';
-
- newFile(a_path, content: '''
-class A {}
-''');
-
- // Write `.packages` empty, without `package:aaa`.
- newDotPackagesFile(testPackageRootPath, content: '');
-
- newFile(testFilePath, content: '''
-import 'package:aaa/a.dart';
-void f(A a) {}
-''');
-
- await setRoots(included: [workspaceRootPath], excluded: []);
- await server.onAnalysisComplete;
-
- // We cannot resolve `package:aaa/a.dart`
- assertHasErrors(testFilePath);
-
- // Write `.packages`, recreate analysis contexts.
- newDotPackagesFile(testPackageRootPath, content: '''
-aaa:${toUriStr(aaaLibPath)}
-''');
-
- await pumpEventQueue();
- await server.onAnalysisComplete;
-
- // We have `A` in 'package:aaa/a.dart', so no errors.
- assertNoErrors(testFilePath);
-
- // errors are not reported for packages
- assertNoErrorsNotification(a_path);
- }
-
Future<void> test_fileSystem_changeFile_fixDataYaml() async {
var path = '$testPackageLibPath/fix_data.yaml';
@@ -833,43 +760,6 @@
assertHasErrors(b_path);
}
- Future<void> test_fileSystem_deleteFile_dotPackagesFile() async {
- deleteTestPackageConfigJsonFile();
- var aaaLibPath = '/packages/aaa/lib';
- var a_path = '$aaaLibPath/a.dart';
-
- newFile(a_path, content: '''
-class A {}
-''');
-
- newDotPackagesFile(testPackageRootPath, content: '''
-aaa:${toUriStr(aaaLibPath)}
-''');
-
- newFile(testFilePath, content: '''
-import 'package:aaa/a.dart';
-void f(A a) {}
-''');
-
- await setRoots(included: [workspaceRootPath], excluded: []);
- await server.onAnalysisComplete;
-
- // We have `A` in 'package:aaa/a.dart', so no errors.
- assertNoErrors(testFilePath);
-
- // Write `.packages`, recreate analysis contexts.
- deleteFile('$testPackageRootPath/.packages');
-
- await pumpEventQueue();
- await server.onAnalysisComplete;
-
- // We cannot resolve `package:aaa/a.dart`
- assertHasErrors(testFilePath);
-
- // errors are not reported for packages
- assertNoErrorsNotification(a_path);
- }
-
Future<void> test_fileSystem_deleteFile_fixDataYaml() async {
var path = '$testPackageLibPath/fix_data.yaml';
@@ -987,35 +877,6 @@
);
}
- Future<void> test_setRoots_dotPackagesFile() async {
- deleteTestPackageConfigJsonFile();
- var aaaLibPath = '/packages/aaa/lib';
- var a_path = '$aaaLibPath/a.dart';
-
- newFile(a_path, content: '''
-class A {}
-''');
-
- newDotPackagesFile(testPackageRootPath, content: '''
-aaa:${toUriStr(aaaLibPath)}
-''');
-
- newFile(testFilePath, content: '''
-import 'package:aaa/a.dart';
-void f(A a) {}
-''');
-
- // create project and wait for analysis
- await setRoots(included: [workspaceRootPath], excluded: []);
- await server.onAnalysisComplete;
-
- // We have `A` in 'package:aaa/a.dart', so no errors.
- assertNoErrors(testFilePath);
-
- // errors are not reported for packages
- assertNoErrorsNotification(a_path);
- }
-
Future<void> test_setRoots_excluded_notAbsolute() async {
var response = await handleRequest(
AnalysisSetAnalysisRootsParams(
@@ -1468,7 +1329,12 @@
library lib_a;
class A {}
''').path;
- newDotPackagesFile('/project', content: 'pkgA:file:///packages/pkgA/lib');
+ newPackageConfigJsonFile(
+ '/project',
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
+ .toContent(toUriStr: toUriStr),
+ );
//
addTestFile('''
import 'package:pkgA/libA.dart';
@@ -1518,7 +1384,12 @@
library lib_a;
class A {}
''').path;
- newDotPackagesFile('/project', content: 'pkgA:/packages/pkgA/lib');
+ newPackageConfigJsonFile(
+ '/project',
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
+ .toContent(toUriStr: toUriStr),
+ );
//
addTestFile('// no "pkgA" reference');
await createProject();
diff --git a/pkg/analysis_server/test/edit/fixes_test.dart b/pkg/analysis_server/test/edit/fixes_test.dart
index 8ffe486..b84a06c 100644
--- a/pkg/analysis_server/test/edit/fixes_test.dart
+++ b/pkg/analysis_server/test/edit/fixes_test.dart
@@ -6,6 +6,7 @@
import 'package:analysis_server/src/edit/edit_domain.dart';
import 'package:analysis_server/src/plugin/plugin_manager.dart';
import 'package:analyzer/instrumentation/service.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:analyzer_plugin/protocol/protocol.dart' as plugin;
import 'package:analyzer_plugin/protocol/protocol_common.dart';
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
@@ -149,20 +150,23 @@
}
Future<void> test_suggestImportFromDifferentAnalysisRoot() async {
- newFolder('/aaa');
- newDotPackagesFile('/aaa', content: '''
-aaa:${toUri('/aaa/lib')}
-bbb:${toUri('/bbb/lib')}
-''');
+ newPackageConfigJsonFile(
+ '/aaa',
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'aaa', rootPath: '/aaa')
+ ..add(name: 'bbb', rootPath: '/bbb'))
+ .toContent(toUriStr: toUriStr),
+ );
newPubspecYamlFile('/aaa', r'''
dependencies:
bbb: any
''');
- newFolder('/bbb');
- newDotPackagesFile('/bbb', content: '''
-bbb:${toUri('/bbb/lib')}
-''');
+ newPackageConfigJsonFile(
+ '/bbb',
+ content: (PackageConfigFileBuilder()..add(name: 'bbb', rootPath: '/bbb'))
+ .toContent(toUriStr: toUriStr),
+ );
newFile('/bbb/lib/target.dart', content: 'class Foo() {}');
newFile('/bbb/lib/target.generated.dart', content: 'class Foo() {}');
newFile('/bbb/lib/target.template.dart', content: 'class Foo() {}');
diff --git a/pkg/analysis_server/test/lsp/completion_dart_test.dart b/pkg/analysis_server/test/lsp/completion_dart_test.dart
index 3e0b30e..17744ff 100644
--- a/pkg/analysis_server/test/lsp/completion_dart_test.dart
+++ b/pkg/analysis_server/test/lsp/completion_dart_test.dart
@@ -2392,6 +2392,29 @@
);
}
+ Future<void> test_snippets_doWhile() async {
+ final content = '''
+void f() {
+ do^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartDoWhileLoopSnippetProducer.prefix,
+ label: DartDoWhileLoopSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ do {
+ $0
+ } while ($1);
+}
+''');
+ }
+
Future<void>
test_snippets_flutterStateless_notAvailable_notFlutterProject() async {
final content = '''
@@ -2409,6 +2432,100 @@
);
}
+ Future<void> test_snippets_for() async {
+ final content = '''
+void f() {
+ for^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartForLoopSnippetProducer.prefix,
+ label: DartForLoopSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ for (var i = 0; i < $1; i++) {
+ $0
+ }
+}
+''');
+ }
+
+ Future<void> test_snippets_forIn() async {
+ final content = '''
+void f() {
+ forin^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartForInLoopSnippetProducer.prefix,
+ label: DartForInLoopSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ for (var $1 in $2) {
+ $0
+ }
+}
+''');
+ }
+
+ Future<void> test_snippets_if() async {
+ final content = '''
+void f() {
+ if^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartIfSnippetProducer.prefix,
+ label: DartIfSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ if ($1) {
+ $0
+ }
+}
+''');
+ }
+
+ Future<void> test_snippets_ifElse() async {
+ final content = '''
+void f() {
+ if^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartIfElseSnippetProducer.prefix,
+ label: DartIfElseSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ if ($1) {
+ $0
+ } else {
+
+ }
+}
+''');
+ }
+
Future<void> test_snippets_mainFunction() async {
final content = '''
class A {}
@@ -2446,6 +2563,80 @@
final res = await getCompletion(mainFileUri, positionFromMarker(content));
expect(res.any((c) => c.kind == CompletionItemKind.Snippet), isFalse);
}
+
+ Future<void> test_snippets_switch() async {
+ final content = '''
+void f() {
+ swi^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartSwitchSnippetProducer.prefix,
+ label: DartSwitchSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ switch ($1) {
+ case $2:
+ $0
+ break;
+ default:
+ }
+}
+''');
+ }
+
+ Future<void> test_snippets_tryCatch() async {
+ final content = '''
+void f() {
+ tr^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartTryCatchSnippetProducer.prefix,
+ label: DartTryCatchSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ try {
+ $0
+ } catch (${1:e}) {
+
+ }
+}
+''');
+ }
+
+ Future<void> test_snippets_while() async {
+ final content = '''
+void f() {
+ while^
+}
+''';
+
+ await initializeWithSnippetSupportAndPreviewFlag();
+ final updated = await expectAndApplySnippet(
+ content,
+ prefix: DartWhileLoopSnippetProducer.prefix,
+ label: DartWhileLoopSnippetProducer.label,
+ );
+
+ expect(updated, r'''
+void f() {
+ while ($1) {
+ $0
+ }
+}
+''');
+ }
}
@reflectiveTest
diff --git a/pkg/analysis_server/test/search/type_hierarchy_test.dart b/pkg/analysis_server/test/search/type_hierarchy_test.dart
index c0d0616..2b1903c 100644
--- a/pkg/analysis_server/test/search/type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/search/type_hierarchy_test.dart
@@ -6,6 +6,7 @@
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analysis_server/src/domain_analysis.dart';
import 'package:analysis_server/src/search/search_domain.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -168,11 +169,19 @@
class A {}
class B extends A {}
''');
- newDotPackagesFile('/packages/pkgA',
- content: 'pkgA:${toUriStr('/packages/pkgA/lib')}');
+ newPackageConfigJsonFile(
+ '/packages/pkgA',
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
+ .toContent(toUriStr: toUriStr),
+ );
// reference the package from a project
- newDotPackagesFile(projectPath,
- content: 'pkgA:${toUriStr('/packages/pkgA/lib')}');
+ newPackageConfigJsonFile(
+ projectPath,
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'pkgA', rootPath: '/packages/pkgA'))
+ .toContent(toUriStr: toUriStr),
+ );
addTestFile('''
import 'package:pkgA/libA.dart';
class C extends A {}
diff --git a/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart b/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart
index 5ebb1ac..42fafb8 100644
--- a/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart
@@ -335,4 +335,23 @@
check(response).suggestions.isEmpty;
}
+
+ Future<void> test_constantName_typeArguments_dot_x_semicolon_named() async {
+ var response = await getTestCodeSuggestions('''
+enum E<T> {
+ v<int>.^;
+ const E.foo01();
+ const E.foo02();
+}
+''');
+
+ check(response).suggestions.matchesInAnyOrder([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo01')
+ ..isConstructorInvocation,
+ (suggestion) => suggestion
+ ..completion.isEqualTo('foo02')
+ ..isConstructorInvocation,
+ ]);
+ }
}
diff --git a/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart b/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart
index ea4ec7e..efc5a00 100644
--- a/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/relevance/named_argument_test.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 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../client/completion_driver_test.dart';
@@ -34,11 +35,10 @@
Future<void> setUp() async {
var metaLibFolder = MockPackages.instance.addMeta(resourceProvider);
- // TODO(scheglov) Use `writeTestPackageConfig` instead
- newDotPackagesFile(testPackageRootPath, content: '''
-meta:${metaLibFolder.toUri()}
-project:${toUri(testPackageLibPath)}
-''');
+ writeTestPackageConfig(
+ config: PackageConfigFileBuilder()
+ ..add(name: 'meta', rootPath: metaLibFolder.parent.path),
+ );
await super.setUp();
}
diff --git a/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart b/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart
index ac446c3..5482204 100644
--- a/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart
+++ b/pkg/analysis_server/test/services/snippets/dart/dart_snippet_producers_test.dart
@@ -13,11 +13,315 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(DartDoWhileLoopSnippetProducerTest);
+ defineReflectiveTests(DartForInLoopSnippetProducerTest);
+ defineReflectiveTests(DartForLoopSnippetProducerTest);
+ defineReflectiveTests(DartIfElseSnippetProducerTest);
+ defineReflectiveTests(DartIfSnippetProducerTest);
defineReflectiveTests(DartMainFunctionSnippetProducerTest);
+ defineReflectiveTests(DartSwitchSnippetProducerTest);
+ defineReflectiveTests(DartTryCatchSnippetProducerTest);
+ defineReflectiveTests(DartWhileLoopSnippetProducerTest);
});
}
@reflectiveTest
+class DartDoWhileLoopSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartDoWhileLoopSnippetProducer.newInstance;
+
+ @override
+ String get label => DartDoWhileLoopSnippetProducer.label;
+
+ @override
+ String get prefix => DartDoWhileLoopSnippetProducer.prefix;
+
+ Future<void> test_for() async {
+ var code = r'''
+void f() {
+ do^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ do {
+
+ } while ();
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 22);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 34},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
+
+@reflectiveTest
+class DartForInLoopSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartForInLoopSnippetProducer.newInstance;
+
+ @override
+ String get label => DartForInLoopSnippetProducer.label;
+
+ @override
+ String get prefix => DartForInLoopSnippetProducer.prefix;
+
+ Future<void> test_for() async {
+ var code = r'''
+void f() {
+ forin^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ for (var in ) {
+
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 34);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 22},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ },
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 26},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
+
+@reflectiveTest
+class DartForLoopSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartForLoopSnippetProducer.newInstance;
+
+ @override
+ String get label => DartForLoopSnippetProducer.label;
+
+ @override
+ String get prefix => DartForLoopSnippetProducer.prefix;
+
+ Future<void> test_for() async {
+ var code = r'''
+void f() {
+ for^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ for (var i = 0; i < ; i++) {
+
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 46);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 33},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
+
+@reflectiveTest
+class DartIfElseSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartIfElseSnippetProducer.newInstance;
+
+ @override
+ String get label => DartIfElseSnippetProducer.label;
+
+ @override
+ String get prefix => DartIfElseSnippetProducer.prefix;
+
+ Future<void> test_ifElse() async {
+ var code = r'''
+void f() {
+ if^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ if () {
+
+ } else {
+
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 25);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 17},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+
+ Future<void> test_ifElse_indentedInsideBlock() async {
+ var code = r'''
+void f() {
+ if (true) {
+ if^
+ }
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ if (true) {
+ if () {
+
+ } else {
+
+ }
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 43);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 33},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
+
+@reflectiveTest
+class DartIfSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartIfSnippetProducer.newInstance;
+
+ @override
+ String get label => DartIfSnippetProducer.label;
+
+ @override
+ String get prefix => DartIfSnippetProducer.prefix;
+
+ Future<void> test_if() async {
+ var code = r'''
+void f() {
+ if^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ if () {
+
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 25);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 17},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+
+ Future<void> test_if_indentedInsideBlock() async {
+ var code = r'''
+void f() {
+ if (true) {
+ if^
+ }
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ if (true) {
+ if () {
+
+ }
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 43);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 33},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
+
+@reflectiveTest
class DartMainFunctionSnippetProducerTest extends DartSnippetProducerTest {
@override
final generator = DartMainFunctionSnippetProducer.newInstance;
@@ -116,3 +420,230 @@
return producer.compute();
}
}
+
+@reflectiveTest
+class DartSwitchSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartSwitchSnippetProducer.newInstance;
+
+ @override
+ String get label => DartSwitchSnippetProducer.label;
+
+ @override
+ String get prefix => DartSwitchSnippetProducer.prefix;
+
+ Future<void> test_switch() async {
+ var code = r'''
+void f() {
+ sw^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ switch () {
+ case :
+
+ break;
+ default:
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 42);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ // expression
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 21},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ },
+ // value
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 34},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ },
+ ]);
+ }
+
+ Future<void> test_switch_indentedInsideBlock() async {
+ var code = r'''
+void f() {
+ if (true) {
+ sw^
+ }
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ if (true) {
+ switch () {
+ case :
+
+ break;
+ default:
+ }
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 62);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ // expression
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 37},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ },
+ // value
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 52},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ },
+ ]);
+ }
+}
+
+@reflectiveTest
+class DartTryCatchSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartTryCatchSnippetProducer.newInstance;
+
+ @override
+ String get label => DartTryCatchSnippetProducer.label;
+
+ @override
+ String get prefix => DartTryCatchSnippetProducer.prefix;
+
+ Future<void> test_tryCatch() async {
+ var code = r'''
+void f() {
+ tr^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ try {
+
+ } catch (e) {
+
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 23);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 35},
+ ],
+ 'length': 1,
+ 'suggestions': []
+ }
+ ]);
+ }
+
+ Future<void> test_tryCatch_indentedInsideBlock() async {
+ var code = r'''
+void f() {
+ if (true) {
+ tr^
+ }
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ if (true) {
+ try {
+
+ } catch (e) {
+
+ }
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 41);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 55},
+ ],
+ 'length': 1,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
+
+@reflectiveTest
+class DartWhileLoopSnippetProducerTest extends DartSnippetProducerTest {
+ @override
+ final generator = DartWhileLoopSnippetProducer.newInstance;
+
+ @override
+ String get label => DartWhileLoopSnippetProducer.label;
+
+ @override
+ String get prefix => DartWhileLoopSnippetProducer.prefix;
+
+ Future<void> test_for() async {
+ var code = r'''
+void f() {
+ while^
+}''';
+ final snippet = await expectValidSnippet(code);
+ expect(snippet.prefix, prefix);
+ expect(snippet.label, label);
+ expect(snippet.change.edits, hasLength(1));
+ code = withoutMarkers(code);
+ snippet.change.edits
+ .forEach((edit) => code = SourceEdit.applySequence(code, edit.edits));
+ expect(code, '''
+void f() {
+ while () {
+
+ }
+}''');
+ expect(snippet.change.selection!.file, testFile);
+ expect(snippet.change.selection!.offset, 28);
+ expect(snippet.change.linkedEditGroups.map((group) => group.toJson()), [
+ {
+ 'positions': [
+ {'file': testFile, 'offset': 20},
+ ],
+ 'length': 0,
+ 'suggestions': []
+ }
+ ]);
+ }
+}
diff --git a/pkg/analysis_server/test/services/snippets/dart/snippet_manager_test.dart b/pkg/analysis_server/test/services/snippets/dart/snippet_manager_test.dart
index 622d84f..c5ffb8a 100644
--- a/pkg/analysis_server/test/services/snippets/dart/snippet_manager_test.dart
+++ b/pkg/analysis_server/test/services/snippets/dart/snippet_manager_test.dart
@@ -69,7 +69,7 @@
/// A snippet producer that always returns `false` from [isValid] and throws
/// if [compute] is called.
class _NotValidSnippetProducer extends SnippetProducer {
- _NotValidSnippetProducer(DartSnippetRequest request) : super(request);
+ _NotValidSnippetProducer._(DartSnippetRequest request) : super(request);
@override
Future<Snippet> compute() {
@@ -83,7 +83,7 @@
Future<bool> isValid() async => false;
static _NotValidSnippetProducer newInstance(DartSnippetRequest request) =>
- _NotValidSnippetProducer(request);
+ _NotValidSnippetProducer._(request);
}
class _TestDartSnippetManager extends DartSnippetManager {
@@ -96,7 +96,7 @@
/// A snippet producer that always returns `true` from [isValid] and a simple
/// snippet from [compute].
class _ValidSnippetProducer extends SnippetProducer {
- _ValidSnippetProducer(DartSnippetRequest request) : super(request);
+ _ValidSnippetProducer._(DartSnippetRequest request) : super(request);
@override
Future<Snippet> compute() async {
@@ -112,5 +112,5 @@
Future<bool> isValid() async => true;
static _ValidSnippetProducer newInstance(DartSnippetRequest request) =>
- _ValidSnippetProducer(request);
+ _ValidSnippetProducer._(request);
}
diff --git a/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart b/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
index 25d24d3..d528d5f 100644
--- a/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
+++ b/pkg/analysis_server/test/src/domains/completion/available_suggestions_base.dart
@@ -7,6 +7,7 @@
import 'package:analysis_server/protocol/protocol_constants.dart';
import 'package:analysis_server/src/domain_completion.dart';
import 'package:analysis_server/src/protocol_server.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -78,9 +79,12 @@
testFile = convertPath('/home/test/lib/test.dart');
newPubspecYamlFile('/home/test', '');
- newDotPackagesFile('/home/test', content: '''
-test:${toUri('/home/test/lib')}
-''');
+ newPackageConfigJsonFile(
+ '/home/test',
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'test', rootPath: '/home/test'))
+ .toContent(toUriStr: toUriStr),
+ );
await createProject();
handler = server.handlers.whereType<CompletionDomainHandler>().single;
diff --git a/pkg/analysis_server/test/src/domains/flutter/base.dart b/pkg/analysis_server/test/src/domains/flutter/base.dart
index 3a9360a..659378f 100644
--- a/pkg/analysis_server/test/src/domains/flutter/base.dart
+++ b/pkg/analysis_server/test/src/domains/flutter/base.dart
@@ -4,6 +4,7 @@
import 'package:analysis_server/src/flutter/flutter_domain.dart';
import 'package:analysis_server/src/protocol_server.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -44,40 +45,19 @@
testFile = convertPath('/home/test/lib/test.dart');
newPubspecYamlFile('/home/test', '');
- newDotPackagesFile('/home/test', content: '''
-test:${toUri('/home/test/lib')}
-''');
- _addFlutterPackage();
+ var metaLib = MockPackages.instance.addMeta(resourceProvider);
+ var flutterLib = MockPackages.instance.addFlutter(resourceProvider);
+ newPackageConfigJsonFile(
+ '/home/test',
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'test', rootPath: '/home/test')
+ ..add(name: 'meta', rootPath: metaLib.parent.path)
+ ..add(name: 'flutter', rootPath: flutterLib.parent.path))
+ .toContent(toUriStr: toUriStr),
+ );
await createProject();
handler = server.handlers.whereType<FlutterDomainHandler>().single;
}
-
- void _addFlutterPackage() {
- _addMetaPackage();
- var libFolder = MockPackages.instance.addFlutter(resourceProvider);
- _addPackageDependency('flutter', libFolder.parent.path);
- }
-
- void _addMetaPackage() {
- var libFolder = MockPackages.instance.addMeta(resourceProvider);
- _addPackageDependency('meta', libFolder.parent.path);
- }
-
- void _addPackageDependency(String name, String rootPath) {
- var packagesFile = getFile('/home/test/.packages');
- var packagesContent =
- packagesFile.exists ? packagesFile.readAsStringSync() : '';
-
- // Ignore if there is already the same package dependency.
- if (packagesContent.contains('$name:file://')) {
- return;
- }
-
- rootPath = convertPath(rootPath);
- packagesContent += '$name:${toUri('$rootPath/lib')}\n';
-
- packagesFile.writeAsStringSync(packagesContent);
- }
}
diff --git a/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart b/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
index 25c479b..58b7f0e 100644
--- a/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
+++ b/pkg/analysis_server/test/src/flutter/flutter_outline_notification_test.dart
@@ -9,6 +9,7 @@
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analysis_server/src/flutter/flutter_domain.dart';
import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer/src/test_utilities/package_config_file_builder.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -72,9 +73,12 @@
}
Future<void> test_children() async {
- newDotPackagesFile(projectPath, content: '''
-flutter:${flutterFolder.toUri()}
-''');
+ newPackageConfigJsonFile(
+ projectPath,
+ content: (PackageConfigFileBuilder()
+ ..add(name: 'flutter', rootPath: flutterFolder.parent.path))
+ .toContent(toUriStr: toUriStr),
+ );
newAnalysisOptionsYamlFile(projectPath, content: '''
analyzer:
strong-mode: true
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 5692f14..ccc51f6 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -8,6 +8,8 @@
* Deprecated `AnalysisDriver.getParsedLibraryByUri`, use `getParsedLibraryByUri2` instead.
* Deprecated `AnalysisDriver.parseFileSync`, use `parseFile` instead.
* Deprecated `astFactory`, clients should not create AST nodes manually.
+* Changed `CompilationUnit.lineInfo` to be non-nullable.
+* Changed `CompilationUnitElement.lineInfo` to be non-nullable.
## 3.3.1
* Report HintCode.OVERRIDE_ON_NON_OVERRIDING_xyz on enum.
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index e0478a0..9c73621 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -413,8 +413,8 @@
@Deprecated('Not useful for clients')
bool get hasLoadLibraryFunction;
- /// Return the [LineInfo] for the [source], or `null` if not computed yet.
- LineInfo? get lineInfo;
+ /// Return the [LineInfo] for the [source].
+ LineInfo get lineInfo;
/// Return a list containing all of the mixins contained in this compilation
/// unit.
diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart
index 1e78252..b28918d 100644
--- a/pkg/analyzer/lib/error/error.dart
+++ b/pkg/analyzer/lib/error/error.dart
@@ -735,7 +735,6 @@
ParserErrorCode.DUPLICATE_PREFIX,
ParserErrorCode.DUPLICATED_MODIFIER,
ParserErrorCode.EMPTY_ENUM_BODY,
- ParserErrorCode.ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS,
ParserErrorCode.ENUM_IN_CLASS,
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND,
ParserErrorCode.EXPECTED_BODY,
diff --git a/pkg/analyzer/lib/src/clients/build_resolvers/build_resolvers.dart b/pkg/analyzer/lib/src/clients/build_resolvers/build_resolvers.dart
index 2667185..f32b90b 100644
--- a/pkg/analyzer/lib/src/clients/build_resolvers/build_resolvers.dart
+++ b/pkg/analyzer/lib/src/clients/build_resolvers/build_resolvers.dart
@@ -46,7 +46,7 @@
...uriResolvers,
]);
- var dataStore = SummaryDataStore.tmp();
+ var dataStore = SummaryDataStore();
dataStore.addBundle('', sdkBundle);
var logger = PerformanceLog(null);
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index 2cd6b2e..d3a04fe 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -72,7 +72,7 @@
SummaryDataStore? summaryData;
if (librarySummaryPaths != null) {
- summaryData = SummaryDataStore.tmp();
+ summaryData = SummaryDataStore();
for (var summaryPath in librarySummaryPaths) {
var bytes = resourceProvider.getFile(summaryPath).readAsBytesSync();
var bundle = PackageBundleReader(bytes);
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 6ec80ea..53cdde8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -39,7 +39,7 @@
final LibraryContextTestView testView;
final PerformanceLog logger;
final ByteStore byteStore;
- final SummaryDataStore store = SummaryDataStore.tmp();
+ final SummaryDataStore store = SummaryDataStore();
late final AnalysisContextImpl analysisContext;
late LinkedElementFactory elementFactory;
diff --git a/pkg/analyzer/lib/src/dart/analysis/search.dart b/pkg/analyzer/lib/src/dart/analysis/search.dart
index 6df7913..988d60f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/search.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/search.dart
@@ -259,7 +259,7 @@
try {
unitElement.accept(
_FunctionElementVisitor((element) {
- addDeclaration(unitElement.lineInfo!, element);
+ addDeclaration(unitElement.lineInfo, element);
}),
);
} on _MaxNumberOfDeclarationsError {
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 060903e..0f0720a 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -974,7 +974,7 @@
late Source source;
@override
- LineInfo? lineInfo;
+ late LineInfo lineInfo;
/// The source of the library containing this compilation unit.
///
diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
index 06dc036..1b0f41c 100644
--- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart
@@ -461,13 +461,6 @@
correctionMessage: "Try declaring a constant.",
);
- static const ParserErrorCode
- ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS = ParserErrorCode(
- 'ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS',
- "Missing arguments in enum constructor invocation.",
- correctionMessage: "Try adding an argument list.",
- );
-
static const ParserErrorCode ENUM_IN_CLASS = ParserErrorCode(
'ENUM_IN_CLASS',
"Enums can't be declared inside classes.",
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 9526d94..18f6f4c 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -78,7 +78,6 @@
TypeArgumentListImpl,
TypeParameterImpl;
import 'package:analyzer/src/dart/ast/ast_factory.dart';
-import 'package:analyzer/src/dart/error/syntactic_errors.dart';
import 'package:analyzer/src/fasta/error_converter.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:analyzer/src/summary2/ast_binary_tokens.dart';
@@ -2915,18 +2914,6 @@
name: constructorNameId,
);
}
- // enum E { v<int> }
- if (typeArguments != null && argumentList == null) {
- errorReporter.errorReporter?.reportErrorForNode(
- ParserErrorCode.ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS,
- typeArguments,
- );
- argumentList = _syntheticArgumentList(typeArguments.endToken);
- }
- // enum E { v.^ }
- if (constructorSelector != null) {
- argumentList ??= _syntheticArgumentList(constructorSelector.endToken);
- }
}
// Replace the constant to include arguments.
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
index cd89eef..5492b85 100644
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart
@@ -91,12 +91,12 @@
classTypeAlias(typeName, objectType, parameterNames);
static CompilationUnitElementImpl compilationUnit(String fileName,
- [Source? librarySource]) {
+ [Source? librarySource, LineInfo? lineInfo]) {
Source source = NonExistingSource(fileName, toUri(fileName));
CompilationUnitElementImpl unit = CompilationUnitElementImpl();
unit.source = source;
- librarySource ??= source;
- unit.librarySource = librarySource;
+ unit.librarySource = librarySource ?? source;
+ unit.lineInfo = lineInfo ?? LineInfo([0]);
return unit;
}
diff --git a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
index f9c96037..6b789f1 100644
--- a/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
+++ b/pkg/analyzer/lib/src/summary/package_bundle_reader.dart
@@ -4,9 +4,7 @@
import 'dart:io' as io;
import 'dart:math' show min;
-import 'dart:typed_data';
-import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/summary2/package_bundle_format.dart';
@@ -121,14 +119,9 @@
final Set<String> _libraryUris = <String>{};
final Set<String> _partUris = <String>{};
- /// Create a [SummaryDataStore] and populate it with the summaries in
- /// [summaryPaths].
- @Deprecated('Use tmp() and addBundle() instead')
- SummaryDataStore(Iterable<String> summaryPaths,
- {ResourceProvider? resourceProvider}) {
- summaryPaths.forEach((String path) => _fillMaps(path, resourceProvider));
- }
+ SummaryDataStore();
+ @Deprecated('Use SummaryDataStore() instead')
SummaryDataStore.tmp();
/// Add the given [bundle] loaded from the file with the given [path].
@@ -164,17 +157,4 @@
bool isPartUnit(String uri) {
return _partUris.contains(uri);
}
-
- void _fillMaps(String path, ResourceProvider? resourceProvider) {
- Uint8List bytes;
- if (resourceProvider != null) {
- var file = resourceProvider.getFile(path);
- bytes = file.readAsBytesSync();
- } else {
- io.File file = io.File(path);
- bytes = file.readAsBytesSync();
- }
- var bundle = PackageBundleReader(bytes);
- addBundle(path, bundle);
- }
}
diff --git a/pkg/analyzer/lib/src/summary/summary_sdk.dart b/pkg/analyzer/lib/src/summary/summary_sdk.dart
index 3713497..d48a21f 100644
--- a/pkg/analyzer/lib/src/summary/summary_sdk.dart
+++ b/pkg/analyzer/lib/src/summary/summary_sdk.dart
@@ -17,7 +17,7 @@
late final InSummaryUriResolver _uriResolver;
SummaryBasedDartSdk.forBundle(this._bundle) {
- var dataStore = SummaryDataStore.tmp();
+ var dataStore = SummaryDataStore();
// TODO(scheglov) We need a solution to avoid these paths at all.
dataStore.addBundle('', bundle);
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
index d1cb139..ba0dc02 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk.dart
@@ -71,6 +71,8 @@
}
static void run(void callback()) {}
}
+
+void unawaited(Future<void>? future) {}
''',
),
MockSdkLibraryUnit(
diff --git a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
index f289112..38630e9 100644
--- a/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
+++ b/pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
@@ -6,6 +6,7 @@
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/source/line_info.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/dart/element/type.dart';
@@ -872,6 +873,7 @@
var asyncUnit = CompilationUnitElementImpl();
var asyncSource = analysisContext.sourceFactory.forUri('dart:async')!;
asyncUnit.librarySource = asyncUnit.source = asyncSource;
+ asyncUnit.lineInfo = LineInfo([0]);
asyncLibrary.definingCompilationUnit = asyncUnit;
asyncUnit.classes = <ClassElement>[
@@ -890,6 +892,7 @@
var coreSource = analysisContext.sourceFactory.forUri('dart:core')!;
coreUnit.librarySource = coreUnit.source = coreSource;
+ coreUnit.lineInfo = LineInfo([0]);
coreUnit.classes = <ClassElement>[
boolElement,
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index 477c268..ad32254 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -20124,9 +20124,6 @@
EMPTY_ENUM_BODY:
problemMessage: An enum must declare at least one constant name.
correctionMessage: Try declaring a constant.
- ENUM_CONSTANT_WITH_TYPE_ARGUMENTS_WITHOUT_ARGUMENTS:
- problemMessage: Missing arguments in enum constructor invocation.
- correctionMessage: Try adding an argument list.
EXPECTED_CASE_OR_DEFAULT:
problemMessage: "Expected 'case' or 'default'."
correctionMessage: Try placing this code inside a case clause.
diff --git a/pkg/analyzer/test/generated/elements_types_mixin.dart b/pkg/analyzer/test/generated/elements_types_mixin.dart
index 8c01ffe..3f5b739 100644
--- a/pkg/analyzer/test/generated/elements_types_mixin.dart
+++ b/pkg/analyzer/test/generated/elements_types_mixin.dart
@@ -384,6 +384,7 @@
var definingUnit = CompilationUnitElementImpl();
definingUnit.source = source;
definingUnit.librarySource = source;
+ definingUnit.lineInfo = LineInfo([0]);
definingUnit.enclosingElement = library;
library.definingCompilationUnit = definingUnit;
diff --git a/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart b/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart
index 10b5c99..747cb36 100644
--- a/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/function_reference_test.dart
@@ -363,6 +363,7 @@
token: f
staticElement: f@61
staticType: void Function<U>(U)
+ alias: self::@typeAlias::Fn
staticType: void Function(int)
typeArgumentTypes
int
diff --git a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
index 41cc3bc..28c1a7f 100644
--- a/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/method_invocation_test.dart
@@ -3687,6 +3687,7 @@
token: foo
staticElement: self::@class::C::@getter::foo
staticType: double Function(int)
+ alias: self::@typeAlias::MyFunction
argumentList: ArgumentList
leftParenthesis: (
arguments
@@ -3696,6 +3697,7 @@
rightParenthesis: )
staticElement: <null>
staticInvokeType: double Function(int)
+ alias: self::@typeAlias::MyFunction
staticType: double
''');
} else {
@@ -3705,6 +3707,7 @@
token: foo
staticElement: self::@class::C::@getter::foo
staticType: double* Function(int*)*
+ alias: self::@typeAlias::MyFunction
argumentList: ArgumentList
leftParenthesis: (
arguments
@@ -3714,6 +3717,7 @@
rightParenthesis: )
staticElement: <null>
staticInvokeType: double* Function(int*)*
+ alias: self::@typeAlias::MyFunction
staticType: double*
''');
}
@@ -7696,11 +7700,13 @@
token: a
staticElement: a@39
staticType: void Function()
+ alias: self::@typeAlias::F
argumentList: ArgumentList
leftParenthesis: (
rightParenthesis: )
staticElement: <null>
staticInvokeType: void Function()
+ alias: self::@typeAlias::F
staticType: void
''');
} else {
@@ -7710,11 +7716,13 @@
token: a
staticElement: a@39
staticType: void Function()*
+ alias: self::@typeAlias::F
argumentList: ArgumentList
leftParenthesis: (
rightParenthesis: )
staticElement: <null>
staticInvokeType: void Function()*
+ alias: self::@typeAlias::F
staticType: void
''');
}
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 4fda1a5..869a97a 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -243,12 +243,6 @@
return components.join(';');
}
- String? _typeStr(DartType? type) {
- return type?.getDisplayString(
- withNullability: true,
- );
- }
-
void _withIndent(void Function() f) {
var savedIndent = indent;
indent = '$savedIndent ';
@@ -296,7 +290,7 @@
var supertype = e.supertype;
if (supertype != null &&
(supertype.element.name != 'Object' || e.mixins.isNotEmpty)) {
- _writeType(supertype, name: 'supertype');
+ _writeType('supertype', supertype);
}
if (e.isMixin) {
@@ -304,15 +298,11 @@
if (superclassConstraints.isEmpty) {
throw StateError('At least Object is expected.');
}
- _writeElements<DartType>(
- 'superclassConstraints',
- superclassConstraints,
- _writeType,
- );
+ _writeTypeList('superclassConstraints', superclassConstraints);
}
- _writeElements<DartType>('mixins', e.mixins, _writeType);
- _writeElements<DartType>('interfaces', e.interfaces, _writeType);
+ _writeTypeList('mixins', e.mixins);
+ _writeTypeList('interfaces', e.interfaces);
_writeElements('fields', e.fields, _writePropertyInducingElement);
@@ -484,7 +474,7 @@
_writeMetadata(e);
_writeCodeRange(e);
_writeTypeParameterElements(e.typeParameters);
- _writeType(e.extendedType, name: 'extendedType');
+ _writeType('extendedType', e.extendedType);
});
_withIndent(() {
@@ -522,7 +512,7 @@
_writeCodeRange(e);
_writeTypeParameterElements(e.typeParameters);
_writeParameterElements(e.parameters);
- _writeType(e.returnType, name: 'returnType');
+ _writeType('returnType', e.returnType);
});
_assertNonSyntheticElementSelf(e);
@@ -597,7 +587,7 @@
_writeTypeParameterElements(e.typeParameters);
_writeParameterElements(e.parameters);
- _writeType(e.returnType, name: 'returnType');
+ _writeType('returnType', e.returnType);
_writeNonSyntheticElement(e);
});
@@ -672,7 +662,7 @@
});
_withIndent(() {
- _writeType(e.type, name: 'type');
+ _writeType('type', e.type);
_writeMetadata(e);
_writeCodeRange(e);
_writeTypeParameterElements(e.typeParameters);
@@ -741,7 +731,7 @@
expect(e.typeParameters, isEmpty);
_writeParameterElements(e.parameters);
- _writeType(e.returnType, name: 'returnType');
+ _writeType('returnType', e.returnType);
_writeNonSyntheticElement(e);
});
}
@@ -783,7 +773,7 @@
_writeMetadata(e);
_writeCodeRange(e);
_writeTypeInferenceError(e);
- _writeType(e.type, name: 'type');
+ _writeType('type', e.type);
_writeConstantInitializer(e);
_writeNonSyntheticElement(e);
});
@@ -800,26 +790,8 @@
}
}
- void _writeType(DartType type, {String? name}) {
- var typeStr = _typeStr(type);
- if (name != null) {
- _writelnWithIndent('$name: $typeStr');
- } else {
- _writelnWithIndent('$typeStr');
- }
-
- var alias = type.alias;
- if (alias != null) {
- _withIndent(() {
- _createAstPrinter().writeElement('aliasElement', alias.element);
-
- _writeElements<DartType>(
- 'aliasArguments',
- alias.typeArguments,
- _writeType,
- );
- });
- }
+ void _writeType(String name, DartType type) {
+ _createAstPrinter().writeType(type, name: name);
}
void _writeTypeAliasElement(TypeAliasElement e) {
@@ -838,7 +810,7 @@
_writeTypeParameterElements(e.typeParameters);
var aliasedType = e.aliasedType;
- _writeType(aliasedType, name: 'aliasedType');
+ _writeType('aliasedType', aliasedType);
// TODO(scheglov) https://github.com/dart-lang/sdk/issues/44629
// TODO(scheglov) Remove it when we stop providing it everywhere.
if (aliasedType is FunctionType) {
@@ -851,7 +823,7 @@
_withIndent(() {
_writeTypeParameterElements(aliasedElement.typeParameters);
_writeParameterElements(aliasedElement.parameters);
- _writeType(aliasedElement.returnType, name: 'returnType');
+ _writeType('returnType', aliasedElement.returnType);
});
}
});
@@ -876,6 +848,10 @@
}
}
+ void _writeTypeList(String name, List<DartType> types) {
+ _createAstPrinter().writeTypeList(name, types);
+ }
+
void _writeTypeParameterElement(TypeParameterElement e) {
e as TypeParameterElementImpl;
@@ -889,12 +865,12 @@
var bound = e.bound;
if (bound != null) {
- _writeType(bound, name: 'bound');
+ _writeType('bound', bound);
}
var defaultType = e.defaultType;
if (defaultType != null) {
- _writeType(defaultType, name: 'defaultType');
+ _writeType('defaultType', defaultType);
}
_writeMetadata(e);
diff --git a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
index 18026d6..e0617b5 100644
--- a/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
+++ b/pkg/analyzer/test/src/summary/resolved_ast_printer.dart
@@ -1285,6 +1285,40 @@
_writeElement(name, element);
}
+ void writeType(DartType? type, {String? name}) {
+ _sink.write(_indent);
+
+ if (name != null) {
+ _sink.write('$name: ');
+ }
+
+ if (type != null) {
+ var typeStr = _typeStr(type);
+ _writeln(typeStr);
+
+ var alias = type.alias;
+ if (alias != null) {
+ _withIndent(() {
+ _writeElement('alias', alias.element);
+ _withIndent(() {
+ _writeTypeList('typeArguments', alias.typeArguments);
+ });
+ });
+ }
+ } else {
+ _writeln('null');
+ }
+ }
+
+ void writeTypeList(String name, List<DartType>? types) {
+ if (types != null && types.isNotEmpty) {
+ _writelnWithIndent(name);
+ _withIndent(() {
+ types.forEach(writeType);
+ });
+ }
+ }
+
/// Check that children entities of the [node] link to each other.
void _checkChildrenEntitiesLinking(AstNode node) {
Token? lastEnd;
@@ -1333,7 +1367,7 @@
return '{$entriesStr}';
}
- String? _typeStr(DartType type) {
+ String _typeStr(DartType type) {
return type.getDisplayString(withNullability: true);
}
@@ -1534,24 +1568,13 @@
void _writeType(String name, DartType? type) {
if (_withResolution) {
- if (type != null) {
- var typeStr = _typeStr(type);
- _writelnWithIndent('$name: $typeStr');
- } else {
- _writelnWithIndent('$name: null');
- }
+ writeType(type, name: name);
}
}
void _writeTypeList(String name, List<DartType>? types) {
- if (types != null && types.isNotEmpty) {
- _writelnWithIndent(name);
- _withIndent(() {
- for (var type in types) {
- var typeStr = _typeStr(type);
- _writelnWithIndent('$typeStr');
- }
- });
+ if (_withResolution) {
+ writeTypeList(name, types);
}
}
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 26542c5..d4e691d 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -1993,10 +1993,10 @@
covariant U @96
defaultType: dynamic
supertype: C<U, T>
- aliasElement: self::@typeAlias::A
- aliasArguments
- U
- T
+ alias: self::@typeAlias::A
+ typeArguments
+ U
+ T
constructors
named @121
periodOffset: 120
@@ -6412,13 +6412,13 @@
typeParameters
covariant X @42
bound: void Function(X*)*
- aliasElement: self::@typeAlias::F
- aliasArguments
- X*
+ alias: self::@typeAlias::F
+ typeArguments
+ X*
defaultType: void Function(Null*)*
- aliasElement: self::@typeAlias::F
- aliasArguments
- Null*
+ alias: self::@typeAlias::F
+ typeArguments
+ Null*
constructors
synthetic @-1
typeAliases
@@ -6449,13 +6449,13 @@
typeParameters
covariant X @42
bound: void Function(X)
- aliasElement: self::@typeAlias::F
- aliasArguments
- X
+ alias: self::@typeAlias::F
+ typeArguments
+ X
defaultType: void Function(Never)
- aliasElement: self::@typeAlias::F
- aliasArguments
- Never
+ alias: self::@typeAlias::F
+ typeArguments
+ Never
constructors
synthetic @-1
typeAliases
@@ -6486,13 +6486,13 @@
typeParameters
covariant X @38
bound: X Function()
- aliasElement: self::@typeAlias::F
- aliasArguments
- X
+ alias: self::@typeAlias::F
+ typeArguments
+ X
defaultType: dynamic Function()
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
constructors
synthetic @-1
typeAliases
@@ -6520,13 +6520,13 @@
typeParameters
covariant X @39
bound: X Function(X)
- aliasElement: self::@typeAlias::F
- aliasArguments
- X
+ alias: self::@typeAlias::F
+ typeArguments
+ X
defaultType: dynamic Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
constructors
synthetic @-1
typeAliases
@@ -6557,13 +6557,13 @@
typeParameters
covariant X @39
bound: X Function(X)
- aliasElement: self::@typeAlias::F
- aliasArguments
- X
+ alias: self::@typeAlias::F
+ typeArguments
+ X
defaultType: dynamic Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
constructors
synthetic @-1
typeAliases
@@ -6704,13 +6704,13 @@
typeParameters
covariant X @48
bound: List<void Function(X)>
- aliasElement: self::@typeAlias::A
- aliasArguments
- X
+ alias: self::@typeAlias::A
+ typeArguments
+ X
defaultType: List<void Function(Never)>
- aliasElement: self::@typeAlias::A
- aliasArguments
- Never
+ alias: self::@typeAlias::A
+ typeArguments
+ Never
constructors
synthetic @-1
typeAliases
@@ -6736,13 +6736,13 @@
typeParameters
covariant X @37
bound: Map<X, int>
- aliasElement: self::@typeAlias::A
- aliasArguments
- X
+ alias: self::@typeAlias::A
+ typeArguments
+ X
defaultType: Map<dynamic, int>
- aliasElement: self::@typeAlias::A
- aliasArguments
- dynamic
+ alias: self::@typeAlias::A
+ typeArguments
+ dynamic
constructors
synthetic @-1
typeAliases
@@ -15396,6 +15396,7 @@
staticElement: self::@typeAlias::F
staticType: null
type: int Function(String)
+ alias: self::@typeAlias::F
rightBracket: > @44
leftBracket: [ @45
rightBracket: ] @46
@@ -16086,17 +16087,17 @@
fields
final f @71
type: void Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
constructors
const @82
parameters
optionalNamed final this.f @90
type: void Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
constantInitializer
FunctionReference
function: SimpleIdentifier
@@ -16110,9 +16111,9 @@
accessors
synthetic get f @-1
returnType: void Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
typeAliases
functionTypeAliasBased F @13
typeParameters
@@ -16242,9 +16243,9 @@
parameters
optionalPositional compare @22
type: int* Function(dynamic, dynamic)*
- aliasElement: dart:core::@typeAlias::Comparator
- aliasArguments
- dynamic
+ alias: dart:core::@typeAlias::Comparator
+ typeArguments
+ dynamic
constantInitializer
PrefixedIdentifier
prefix: SimpleIdentifier
@@ -19715,7 +19716,7 @@
parameters
requiredPositional f @25
type: dynamic Function(int)
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: dynamic
''');
}
@@ -19865,45 +19866,55 @@
}
test_export_hide() async {
- addLibrary('dart:async');
- var library =
- await checkLibrary('export "dart:async" hide Stream, Future;');
+ testFile = convertPath('/home/test/lib/test.dart');
+ addLibrarySource('/home/test/lib/a.dart', r'''
+class A {}
+class B {}
+class C {}
+class D {}
+''');
+ var library = await checkLibrary(r'''
+export 'a.dart' hide A, C;
+''');
checkElementText(
library,
r'''
library
exports
- dart:async
+ package:test/a.dart
combinators
- hide: Stream, Future
+ hide: A, C
definingUnit
exportScope
- Completer: dart:async;Completer
- FutureOr: dart:async;FutureOr
- StreamIterator: dart:async;dart:async/stream.dart;StreamIterator
- StreamSubscription: dart:async;dart:async/stream.dart;StreamSubscription
- StreamTransformer: dart:async;dart:async/stream.dart;StreamTransformer
- Timer: dart:async;Timer
+ B: package:test/a.dart;B
+ D: package:test/a.dart;D
''',
withExportScope: true);
}
test_export_multiple_combinators() async {
- addLibrary('dart:async');
- var library =
- await checkLibrary('export "dart:async" hide Stream show Future;');
+ testFile = convertPath('/home/test/lib/test.dart');
+ addLibrarySource('/home/test/lib/a.dart', r'''
+class A {}
+class B {}
+class C {}
+class D {}
+''');
+ var library = await checkLibrary(r'''
+export 'a.dart' hide A show C;
+''');
checkElementText(
library,
r'''
library
exports
- dart:async
+ package:test/a.dart
combinators
- hide: Stream
- show: Future
+ hide: A
+ show: C
definingUnit
exportScope
- Future: dart:async;Future
+ C: package:test/a.dart;C
''',
withExportScope: true);
}
@@ -19925,21 +19936,28 @@
}
test_export_show() async {
- addLibrary('dart:async');
- var library =
- await checkLibrary('export "dart:async" show Future, Stream;');
+ testFile = convertPath('/home/test/lib/test.dart');
+ addLibrarySource('/home/test/lib/a.dart', r'''
+class A {}
+class B {}
+class C {}
+class D {}
+''');
+ var library = await checkLibrary(r'''
+export 'a.dart' show A, C;
+''');
checkElementText(
library,
r'''
library
exports
- dart:async
+ package:test/a.dart
combinators
- show: Future, Stream
+ show: A, C
definingUnit
exportScope
- Future: dart:async;Future
- Stream: dart:async;dart:async/stream.dart;Stream
+ A: package:test/a.dart;A
+ C: package:test/a.dart;C
''',
withExportScope: true);
}
@@ -20723,9 +20741,9 @@
aliasedType: void Function(T) Function()
aliasedElement: GenericFunctionTypeElement
returnType: void Function(T)
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
''');
}
@@ -20745,9 +20763,9 @@
aliasedType: void Function(T) Function()
aliasedElement: GenericFunctionTypeElement
returnType: void Function(T)
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
functionTypeAliasBased F1 @36
typeParameters
contravariant T @39
@@ -20820,9 +20838,9 @@
aliasedType: T Function() Function()
aliasedElement: GenericFunctionTypeElement
returnType: T Function()
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
''');
}
@@ -20854,9 +20872,9 @@
parameters
requiredPositional a @50
type: void Function(T)
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
returnType: void
''');
}
@@ -20908,9 +20926,9 @@
requiredPositional a @41
type: T
returnType: T Function()
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
''');
}
@@ -21805,9 +21823,9 @@
parameters
requiredPositional @-1
type: V1 Function()
- aliasElement: self::@typeAlias::F2
- aliasArguments
- V1
+ alias: self::@typeAlias::F2
+ typeArguments
+ V1
returnType: dynamic
F2 @43
typeParameters
@@ -22645,9 +22663,9 @@
parameters
requiredPositional f @65
type: D<V, U> Function<U>()
- aliasElement: self::@typeAlias::F
- aliasArguments
- V
+ alias: self::@typeAlias::F
+ typeArguments
+ V
class D @77
typeParameters
covariant T @79
@@ -22722,7 +22740,7 @@
parameters
requiredPositional f @54
type: D<T> Function<T>()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
class D @66
typeParameters
covariant T @68
@@ -23266,31 +23284,31 @@
fields
v @49
type: int Function(String)
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
constructors
synthetic @-1
superConstructor: self::@class::D::@constructor::•
accessors
synthetic get v @-1
returnType: int Function(String)
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic set v @-1
parameters
requiredPositional _v @-1
type: int Function(String)
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
abstract class D @69
fields
synthetic v @-1
type: int Function(String)
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
constructors
synthetic @-1
accessors
abstract get v @79
returnType: int Function(String)
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
typeAliases
functionTypeAliasBased F @12
aliasedType: int Function(String)
@@ -23489,7 +23507,7 @@
parameters
requiredPositional f @37
type: void Function(int Function(String))
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: dynamic
''');
}
@@ -24533,9 +24551,9 @@
methods
f @31
returnType: O Function(O)
- aliasElement: a.dart::@typeAlias::F
- aliasArguments
- O
+ alias: a.dart::@typeAlias::F
+ typeArguments
+ O
''');
}
@@ -24562,22 +24580,22 @@
topLevelVariables
static f @33
type: dynamic Function(num)
- aliasElement: self::@typeAlias::F
- aliasArguments
- num
+ alias: self::@typeAlias::F
+ typeArguments
+ num
accessors
synthetic static get f @-1
returnType: dynamic Function(num)
- aliasElement: self::@typeAlias::F
- aliasArguments
- num
+ alias: self::@typeAlias::F
+ typeArguments
+ num
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function(num)
- aliasElement: self::@typeAlias::F
- aliasArguments
- num
+ alias: self::@typeAlias::F
+ typeArguments
+ num
returnType: void
''');
}
@@ -24647,22 +24665,22 @@
topLevelVariables
static f @49
type: S Function<S>(num)
- aliasElement: self::@typeAlias::F
- aliasArguments
- num
+ alias: self::@typeAlias::F
+ typeArguments
+ num
accessors
synthetic static get f @-1
returnType: S Function<S>(num)
- aliasElement: self::@typeAlias::F
- aliasArguments
- num
+ alias: self::@typeAlias::F
+ typeArguments
+ num
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: S Function<S>(num)
- aliasElement: self::@typeAlias::F
- aliasArguments
- num
+ alias: self::@typeAlias::F
+ typeArguments
+ num
returnType: void
''');
}
@@ -33398,7 +33416,7 @@
type: E
static f @49
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -33416,12 +33434,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
''');
}
@@ -33442,7 +33460,7 @@
type: E
static f @38
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -33460,12 +33478,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
parts
a.dart
@@ -33586,7 +33604,7 @@
type: E
static f @23
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -33604,12 +33622,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
''');
}
@@ -33682,7 +33700,7 @@
type: E
static f @23
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -33700,12 +33718,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
''');
}
@@ -33776,7 +33794,7 @@
type: E
static f @60
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -33794,12 +33812,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
''');
}
@@ -33956,7 +33974,7 @@
type: E
static f @29
type: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -33974,12 +33992,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
returnType: void
''');
}
@@ -34000,7 +34018,7 @@
type: E
static f @29
type: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34018,12 +34036,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
returnType: void
''');
}
@@ -34045,7 +34063,7 @@
type: E
static f @29
type: dynamic Function()
- aliasElement: c.dart::@typeAlias::F
+ alias: c.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34063,12 +34081,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: c.dart::@typeAlias::F
+ alias: c.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: c.dart::@typeAlias::F
+ alias: c.dart::@typeAlias::F
returnType: void
''');
}
@@ -34090,7 +34108,7 @@
type: E
static f @31
type: dynamic Function()
- aliasElement: c.dart::@typeAlias::F
+ alias: c.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34108,12 +34126,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: c.dart::@typeAlias::F
+ alias: c.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: c.dart::@typeAlias::F
+ alias: c.dart::@typeAlias::F
returnType: void
''');
}
@@ -34134,7 +34152,7 @@
type: E
static f @31
type: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34152,12 +34170,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
returnType: void
''');
}
@@ -34178,7 +34196,7 @@
type: E
static f @29
type: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34196,12 +34214,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
returnType: void
''');
}
@@ -34255,7 +34273,7 @@
type: E
static f @31
type: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34273,12 +34291,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: b.dart::@typeAlias::F
+ alias: b.dart::@typeAlias::F
returnType: void
''');
}
@@ -34298,7 +34316,7 @@
type: E
static f @29
type: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
accessors
synthetic static get c @-1
returnType: C
@@ -34316,12 +34334,12 @@
returnType: void
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: a.dart::@typeAlias::F
+ alias: a.dart::@typeAlias::F
returnType: void
''');
}
@@ -34339,16 +34357,16 @@
topLevelVariables
static f @15
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
accessors
synthetic static get f @-1
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
''');
}
@@ -34375,25 +34393,25 @@
topLevelVariables
static f @39
type: String Function(int)
- aliasElement: self::@typeAlias::F
- aliasArguments
- int
- String
+ alias: self::@typeAlias::F
+ typeArguments
+ int
+ String
accessors
synthetic static get f @-1
returnType: String Function(int)
- aliasElement: self::@typeAlias::F
- aliasArguments
- int
- String
+ alias: self::@typeAlias::F
+ typeArguments
+ int
+ String
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: String Function(int)
- aliasElement: self::@typeAlias::F
- aliasArguments
- int
- String
+ alias: self::@typeAlias::F
+ typeArguments
+ int
+ String
returnType: void
''');
}
@@ -34419,25 +34437,25 @@
topLevelVariables
static f @26
type: dynamic Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
+ dynamic
accessors
synthetic static get f @-1
returnType: dynamic Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
+ dynamic
synthetic static set f @-1
parameters
requiredPositional _f @-1
type: dynamic Function(dynamic)
- aliasElement: self::@typeAlias::F
- aliasArguments
- dynamic
- dynamic
+ alias: self::@typeAlias::F
+ typeArguments
+ dynamic
+ dynamic
returnType: void
''');
}
@@ -34554,9 +34572,9 @@
aliasedType: void Function(T) Function()
aliasedElement: GenericFunctionTypeElement
returnType: void Function(T)
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
''');
}
@@ -34619,9 +34637,9 @@
aliasedType: T Function() Function()
aliasedElement: GenericFunctionTypeElement
returnType: T Function()
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
''');
}
@@ -34653,9 +34671,9 @@
parameters
requiredPositional @-1
type: void Function(T)
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
returnType: void
''');
}
@@ -34708,7 +34726,7 @@
parameters
requiredPositional @-1
type: void Function()
- aliasElement: self::@typeAlias::F
+ alias: self::@typeAlias::F
returnType: void
''');
}
@@ -34760,9 +34778,9 @@
requiredPositional @-1
type: T
returnType: T Function()
- aliasElement: self::@typeAlias::F1
- aliasArguments
- T
+ alias: self::@typeAlias::F1
+ typeArguments
+ T
''');
}
@@ -34909,24 +34927,24 @@
fields
f @58
type: int Function<T>(T)
- aliasElement: self::@typeAlias::Foo
- aliasArguments
- int
+ alias: self::@typeAlias::Foo
+ typeArguments
+ int
constructors
synthetic @-1
accessors
synthetic get f @-1
returnType: int Function<T>(T)
- aliasElement: self::@typeAlias::Foo
- aliasArguments
- int
+ alias: self::@typeAlias::Foo
+ typeArguments
+ int
synthetic set f @-1
parameters
requiredPositional _f @-1
type: int Function<T>(T)
- aliasElement: self::@typeAlias::Foo
- aliasArguments
- int
+ alias: self::@typeAlias::Foo
+ typeArguments
+ int
returnType: void
typeAliases
Foo @8
@@ -35620,15 +35638,15 @@
parameters
requiredPositional a @71
type: void Function()
- aliasElement: self::@typeAlias::A1
+ alias: self::@typeAlias::A1
returnType: void
f2 @82
parameters
requiredPositional a @93
type: int Function()
- aliasElement: self::@typeAlias::A2
- aliasArguments
- int
+ alias: self::@typeAlias::A2
+ typeArguments
+ int
returnType: void
''');
}
@@ -35659,16 +35677,16 @@
parameters
requiredPositional a @65
type: List<int>
- aliasElement: self::@typeAlias::A1
+ alias: self::@typeAlias::A1
returnType: void
f2 @76
parameters
requiredPositional a @95
type: Map<int, String>
- aliasElement: self::@typeAlias::A2
- aliasArguments
- int
- String
+ alias: self::@typeAlias::A2
+ typeArguments
+ int
+ String
returnType: void
''');
}
@@ -35715,9 +35733,9 @@
parameters
requiredPositional a @33
type: U
- aliasElement: self::@typeAlias::A
- aliasArguments
- U
+ alias: self::@typeAlias::A
+ typeArguments
+ U
returnType: void
''');
}
@@ -35759,9 +35777,9 @@
class B @49
interfaces
A<int, String>
- aliasElement: self::@typeAlias::X
- aliasArguments
- String
+ alias: self::@typeAlias::X
+ typeArguments
+ String
constructors
synthetic @-1
typeAliases
@@ -35840,9 +35858,9 @@
interfaces
B
A<int?>
- aliasElement: self::@typeAlias::X
- aliasArguments
- int
+ alias: self::@typeAlias::X
+ typeArguments
+ int
C
constructors
synthetic @-1
@@ -35975,7 +35993,7 @@
supertype: Object
mixins
A<int>
- aliasElement: self::@typeAlias::X
+ alias: self::@typeAlias::X
constructors
synthetic @-1
typeAliases
@@ -36049,7 +36067,7 @@
mixins
M1
A<int?>
- aliasElement: self::@typeAlias::X
+ alias: self::@typeAlias::X
M2
constructors
synthetic @-1
@@ -36106,7 +36124,7 @@
synthetic @-1
class B @40
supertype: A<int>
- aliasElement: self::@typeAlias::X
+ alias: self::@typeAlias::X
constructors
synthetic @-1
superConstructor: ConstructorMember
@@ -36136,9 +36154,9 @@
synthetic @-1
class B @38
supertype: A<int>
- aliasElement: self::@typeAlias::X
- aliasArguments
- A<int>
+ alias: self::@typeAlias::X
+ typeArguments
+ A<int>
constructors
synthetic @-1
superConstructor: ConstructorMember
@@ -36214,7 +36232,7 @@
synthetic @-1
class D @41
supertype: A<int?>
- aliasElement: self::@typeAlias::X
+ alias: self::@typeAlias::X
constructors
synthetic @-1
superConstructor: ConstructorMember
@@ -36303,7 +36321,7 @@
parameters
requiredPositional a @26
type: dynamic Function()
- aliasElement: self::@typeAlias::A
+ alias: self::@typeAlias::A
returnType: void
''');
}
@@ -36324,7 +36342,7 @@
parameters
requiredPositional a @26
type: int
- aliasElement: self::@typeAlias::A
+ alias: self::@typeAlias::A
returnType: void
''');
}
@@ -36348,7 +36366,7 @@
parameters
requiredPositional a @41
type: List<int*>*
- aliasElement: a.dart::@typeAlias::A
+ alias: a.dart::@typeAlias::A
returnType: void
''');
}
@@ -36369,7 +36387,7 @@
parameters
requiredPositional a @27
type: int?
- aliasElement: self::@typeAlias::A
+ alias: self::@typeAlias::A
returnType: void
''');
}
@@ -36393,9 +36411,9 @@
parameters
requiredPositional a @45
type: Map<int, String>
- aliasElement: self::@typeAlias::A
- aliasArguments
- String
+ alias: self::@typeAlias::A
+ typeArguments
+ String
returnType: void
''');
}
@@ -36465,9 +36483,9 @@
parameters
requiredPositional a @49
type: int
- aliasElement: self::@typeAlias::A
- aliasArguments
- int
+ alias: self::@typeAlias::A
+ typeArguments
+ int
returnType: void
''');
}
@@ -36497,9 +36515,9 @@
parameters
requiredPositional a @50
type: int?
- aliasElement: self::@typeAlias::A
- aliasArguments
- int
+ alias: self::@typeAlias::A
+ typeArguments
+ int
returnType: void
''');
}
diff --git a/pkg/analyzer/test/src/summary/top_level_inference_test.dart b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
index 3974511..5cc3ab8 100644
--- a/pkg/analyzer/test/src/summary/top_level_inference_test.dart
+++ b/pkg/analyzer/test/src/summary/top_level_inference_test.dart
@@ -4689,9 +4689,9 @@
fields
synthetic x @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
- aliasArguments
- T
+ alias: self::@typeAlias::F
+ typeArguments
+ T
synthetic y @-1
type: List<dynamic Function()>
constructors
@@ -4699,9 +4699,9 @@
accessors
get x @41
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
- aliasArguments
- T
+ alias: self::@typeAlias::F
+ typeArguments
+ T
get y @69
returnType: List<dynamic Function()>
class B @89
@@ -4709,9 +4709,9 @@
fields
synthetic x @-1
type: dynamic Function()
- aliasElement: self::@typeAlias::F
- aliasArguments
- int
+ alias: self::@typeAlias::F
+ typeArguments
+ int
synthetic y @-1
type: List<dynamic Function()>
constructors
@@ -4722,9 +4722,9 @@
accessors
get x @114
returnType: dynamic Function()
- aliasElement: self::@typeAlias::F
- aliasArguments
- int
+ alias: self::@typeAlias::F
+ typeArguments
+ int
get y @131
returnType: List<dynamic Function()>
typeAliases
diff --git a/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart b/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
index 575cd5b..32445d5 100644
--- a/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
+++ b/pkg/analyzer_plugin/lib/utilities/analyzer_converter.dart
@@ -6,7 +6,6 @@
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/diagnostic/diagnostic.dart' as analyzer;
import 'package:analyzer/error/error.dart' as analyzer;
-import 'package:analyzer/exception/exception.dart' as analyzer;
import 'package:analyzer/source/error_processor.dart' as analyzer;
import 'package:analyzer/src/generated/engine.dart' as analyzer;
import 'package:analyzer/src/generated/source.dart' as analyzer;
@@ -386,27 +385,18 @@
plugin.Location? _locationForArgs(
analyzer.CompilationUnitElement? unitElement,
analyzer.SourceRange range) {
- var startLine = 0;
- var startColumn = 0;
- var endLine = 0;
- var endColumn = 0;
-
if (unitElement == null) {
return null;
}
- try {
- var lineInfo = unitElement.lineInfo;
- if (lineInfo != null) {
- var offsetLocation = lineInfo.getLocation(range.offset);
- startLine = offsetLocation.lineNumber;
- startColumn = offsetLocation.columnNumber;
- var endLocation = lineInfo.getLocation(range.offset + range.length);
- endLine = endLocation.lineNumber;
- endColumn = endLocation.columnNumber;
- }
- } on analyzer.AnalysisException {
- // Ignore exceptions
- }
+
+ var lineInfo = unitElement.lineInfo;
+ var offsetLocation = lineInfo.getLocation(range.offset);
+ var endLocation = lineInfo.getLocation(range.offset + range.length);
+ var startLine = offsetLocation.lineNumber;
+ var startColumn = offsetLocation.columnNumber;
+ var endLine = endLocation.lineNumber;
+ var endColumn = endLocation.columnNumber;
+
return plugin.Location(unitElement.source.fullName, range.offset,
range.length, startLine, startColumn,
endLine: endLine, endColumn: endColumn);
diff --git a/pkg/front_end/analysis_options_no_lints.yaml b/pkg/front_end/analysis_options_no_lints.yaml
index 810d473..6b78932 100644
--- a/pkg/front_end/analysis_options_no_lints.yaml
+++ b/pkg/front_end/analysis_options_no_lints.yaml
@@ -14,6 +14,7 @@
- test/language_versioning/data/**
- test/macros/application/data/**
- test/macros/declaration/data/**
+ - test/macros/incremental/data/**
- test/patching/data/**
- test/predicates/data/**
- test/static_types/data/**
diff --git a/pkg/front_end/lib/src/fasta/incremental_compiler.dart b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
index e876c78..d6c6a97 100644
--- a/pkg/front_end/lib/src/fasta/incremental_compiler.dart
+++ b/pkg/front_end/lib/src/fasta/incremental_compiler.dart
@@ -55,6 +55,8 @@
import 'package:package_config/package_config.dart' show Package, PackageConfig;
+import '../api_prototype/compiler_options.dart' show CompilerOptions;
+
import '../api_prototype/experimental_flags.dart';
import '../api_prototype/file_system.dart' show FileSystem, FileSystemEntity;
@@ -71,6 +73,10 @@
import '../base/nnbd_mode.dart';
+import '../base/processed_options.dart' show ProcessedOptions;
+
+import '../kernel_generator_impl.dart' show precompileMacros;
+
import 'builder/builder.dart' show Builder;
import 'builder/class_builder.dart' show ClassBuilder;
@@ -110,6 +116,8 @@
import 'incremental_serializer.dart' show IncrementalSerializer;
+import 'kernel/macro.dart' show enableMacros, MacroClass, NeededPrecompilations;
+
import 'scope.dart' show Scope;
import 'source/source_class_builder.dart' show SourceClassBuilder;
@@ -276,6 +284,7 @@
// Figure out what to keep and what to throw away.
Set<Uri?> invalidatedUris = this._invalidatedUris.toSet();
+ _invalidatePrecompiledMacros(c.options, invalidatedUris);
_invalidateNotKeptUserBuilders(invalidatedUris);
ReusageResult? reusedResult = _computeReusedLibraries(
lastGoodKernelTarget,
@@ -328,21 +337,29 @@
// For each computeDelta call we create a new kernel target which needs
// to be setup, and in the case of experimental invalidation some of the
// builders needs to be patched up.
- IncrementalKernelTarget currentKernelTarget = _setupNewKernelTarget(
- c,
- uriTranslator,
- hierarchy,
- reusedLibraries,
- experimentalInvalidation,
- entryPoints!.first);
- Map<LibraryBuilder, List<LibraryBuilder>>? rebuildBodiesMap =
- _experimentalInvalidationCreateRebuildBodiesBuilders(
- currentKernelTarget, experimentalInvalidation, uriTranslator);
- entryPoints = currentKernelTarget.setEntryPoints(entryPoints!);
- await currentKernelTarget.loader.buildOutlines();
- _experimentalInvalidationPatchUpScopes(
- experimentalInvalidation, rebuildBodiesMap);
- rebuildBodiesMap = null;
+ IncrementalKernelTarget currentKernelTarget;
+ while (true) {
+ currentKernelTarget = _setupNewKernelTarget(c, uriTranslator, hierarchy,
+ reusedLibraries, experimentalInvalidation, entryPoints!.first);
+ Map<LibraryBuilder, List<LibraryBuilder>>? rebuildBodiesMap =
+ _experimentalInvalidationCreateRebuildBodiesBuilders(
+ currentKernelTarget, experimentalInvalidation, uriTranslator);
+ entryPoints = currentKernelTarget.setEntryPoints(entryPoints!);
+
+ // TODO(johnniwinther,jensj): Ensure that the internal state of the
+ // incremental compiler is consistent across 1 or more macro
+ // precompilations.
+ NeededPrecompilations? neededPrecompilations =
+ await currentKernelTarget.computeNeededPrecompilations();
+ if (enableMacros &&
+ await precompileMacros(neededPrecompilations, c.options)) {
+ continue;
+ }
+ _experimentalInvalidationPatchUpScopes(
+ experimentalInvalidation, rebuildBodiesMap);
+ rebuildBodiesMap = null;
+ break;
+ }
// Checkpoint: Build the actual outline.
// Note that the [Component] is not the "full" component.
@@ -1381,6 +1398,23 @@
}
}
+ void _invalidatePrecompiledMacros(
+ ProcessedOptions processedOptions, Set<Uri?> invalidatedUris) {
+ if (invalidatedUris.isEmpty) {
+ return;
+ }
+ CompilerOptions compilerOptions = processedOptions.rawOptionsForTesting;
+ Map<MacroClass, Uri>? precompiledMacroUris =
+ compilerOptions.precompiledMacroUris;
+ if (precompiledMacroUris != null) {
+ for (MacroClass macroClass in precompiledMacroUris.keys.toList()) {
+ if (invalidatedUris.contains(macroClass.importUri)) {
+ precompiledMacroUris.remove(macroClass);
+ }
+ }
+ }
+ }
+
/// Internal method.
void _invalidateNotKeptUserBuilders(Set<Uri?> invalidatedUris) {
if (_modulesToLoad != null && _userBuilders != null) {
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index 146909d..c12f2a1 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -551,8 +551,8 @@
addProblem(
templateExperimentNotEnabled.withArguments(
'macros', libraryBuilder.enableMacrosVersionInLibrary.toText()),
- augmentToken.next!.charOffset,
- augmentToken.next!.length);
+ augmentToken.charOffset,
+ augmentToken.length);
augmentToken = null;
}
}
@@ -835,8 +835,8 @@
addProblem(
templateExperimentNotEnabled.withArguments(
'macros', libraryBuilder.enableMacrosVersionInLibrary.toText()),
- macroToken.next!.charOffset,
- macroToken.next!.length);
+ macroToken.charOffset,
+ macroToken.length);
macroToken = null;
}
}
diff --git a/pkg/front_end/lib/src/kernel_generator_impl.dart b/pkg/front_end/lib/src/kernel_generator_impl.dart
index 07c4b09..2f6adc1 100644
--- a/pkg/front_end/lib/src/kernel_generator_impl.dart
+++ b/pkg/front_end/lib/src/kernel_generator_impl.dart
@@ -93,20 +93,8 @@
kernelTarget.setEntryPoints(options.inputs);
NeededPrecompilations? neededPrecompilations =
await kernelTarget.computeNeededPrecompilations();
- if (neededPrecompilations != null) {
- if (enableMacros) {
- // TODO(johnniwinther): Avoid using [rawOptionsForTesting] to compute
- // the compiler options for the precompilation.
- if (options.rawOptionsForTesting.macroTarget != null) {
- await _compileMacros(
- neededPrecompilations, options.rawOptionsForTesting);
- // TODO(johnniwinther): Assert that some works has been done.
- // TODO(johnniwinther): Stop in case of compile-time errors.
- continue;
- }
- } else {
- throw new UnsupportedError('Macro precompilation is not supported');
- }
+ if (await precompileMacros(neededPrecompilations, options)) {
+ continue;
}
return _buildInternal(
options: options,
@@ -276,6 +264,33 @@
/// compilation below.
Uri _defaultDir = Uri.parse('org-dartlang-macro:///a/b/c/');
+/// Compiles the libraries for the macro classes in [neededPrecompilations].
+///
+/// Returns `true` if macro classes were compiled and added to the
+/// [CompilerOptions.precompiledMacroUris] of the provided [options].
+///
+/// Returns `false` if no macro classes needed precompilation or if macro
+/// precompilation is not supported.
+Future<bool> precompileMacros(NeededPrecompilations? neededPrecompilations,
+ ProcessedOptions options) async {
+ if (neededPrecompilations != null) {
+ if (enableMacros) {
+ // TODO(johnniwinther): Avoid using [rawOptionsForTesting] to compute
+ // the compiler options for the precompilation.
+ if (options.rawOptionsForTesting.macroTarget != null) {
+ await _compileMacros(
+ neededPrecompilations, options.rawOptionsForTesting);
+ // TODO(johnniwinther): Assert that some works has been done.
+ // TODO(johnniwinther): Stop in case of compile-time errors.
+ return true;
+ }
+ } else {
+ throw new UnsupportedError('Macro precompilation is not supported');
+ }
+ }
+ return false;
+}
+
Future<void> _compileMacros(NeededPrecompilations neededPrecompilations,
CompilerOptions options) async {
assert(options.macroSerializer != null);
@@ -305,7 +320,8 @@
fs.entityForUri(uri).writeAsStringSync(bootstrapMacroIsolate(
macroDeclarations, SerializationMode.byteDataClient));
- precompilationOptions..fileSystem = new HybridFileSystem(fs);
+ precompilationOptions
+ ..fileSystem = new HybridFileSystem(fs, options.fileSystem);
CompilerResult? compilerResult =
await kernelForProgramInternal(uri, precompilationOptions);
Uri precompiledUri = await options.macroSerializer!
diff --git a/pkg/front_end/lib/src/testing/compiler_common.dart b/pkg/front_end/lib/src/testing/compiler_common.dart
index 407f814..f8cebf7 100644
--- a/pkg/front_end/lib/src/testing/compiler_common.dart
+++ b/pkg/front_end/lib/src/testing/compiler_common.dart
@@ -86,7 +86,7 @@
/// * specify the location of the sdk summaries.
Future<Null> setup(CompilerOptions options, Map<String, dynamic> sources,
{List<String> additionalDills: const []}) async {
- MemoryFileSystem fs = new MemoryFileSystem(_defaultDir);
+ MemoryFileSystem fs = createMemoryFileSystem();
sources.forEach((name, data) {
MemoryFileSystemEntity entity = fs.entityForUri(toTestUri(name));
if (data is String) {
@@ -114,6 +114,8 @@
}
}
+MemoryFileSystem createMemoryFileSystem() => new MemoryFileSystem(_defaultDir);
+
const String _testUriScheme = 'org-dartlang-test';
bool isTestUri(Uri uri) => uri.isScheme(_testUriScheme);
diff --git a/pkg/front_end/test/macros/incremental/data/package_config.json b/pkg/front_end/test/macros/incremental/data/package_config.json
new file mode 100644
index 0000000..2e8365d
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/package_config.json
@@ -0,0 +1,18 @@
+{
+ "configVersion": 2,
+ "packages": [
+ {
+ "name": "macro",
+ "rootUri": "pkgs/macro/lib/"
+ },
+ {
+ "name": "meta",
+ "rootUri": "../../../../../meta/",
+ "packageUri": "lib/"
+ },
+ {
+ "name": "_fe_analyzer_shared",
+ "rootUri": "../../../../../_fe_analyzer_shared/lib/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart b/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart
new file mode 100644
index 0000000..dcfe2f7
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/pkgs/macro/lib/macro.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2022, 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 'dart:async';
+import 'package:_fe_analyzer_shared/src/macros/api.dart';
+
+macro
+
+class ToStringMacro implements ClassDeclarationsMacro {
+ const ToStringMacro();
+
+ @override
+ FutureOr<void> buildDeclarationsForClass(ClassDeclaration clazz,
+ ClassMemberDeclarationBuilder builder) async {
+ Iterable<MethodDeclaration> methods = await builder.methodsOf(clazz);
+ if (!methods.any((m) => m.identifier.name == 'toString')) {
+ Iterable<FieldDeclaration> fields = await builder.fieldsOf(clazz);
+ Uri dartCore = Uri.parse('dart:core');
+ Identifier stringClass =
+ await builder.resolveIdentifier(dartCore, 'String');
+ List<Object> parts = [stringClass, '''
+ toString() {
+ return "${clazz.identifier.name}('''
+ ];
+ String comma = '';
+ for (FieldDeclaration field in fields) {
+ parts.add(comma);
+ parts.add('${field.identifier.name}=\${');
+ parts.add(field.identifier.name);
+ parts.add('}');
+ comma = ',';
+ }
+ parts.add(''')";
+ }''');
+ builder.declareInClass(new DeclarationCode.fromParts(parts));
+ }
+ }
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/data_class.0.dart b/pkg/front_end/test/macros/incremental/data/tests/data_class.0.dart
new file mode 100644
index 0000000..40eda1a
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/data_class.0.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2022, 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:macro/macro.dart';
+
+class DataClass {
+ final String string;
+
+ DataClass({required this.string});
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/data_class.0.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/data_class.0.dart.expect
new file mode 100644
index 0000000..4b63cfd
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/data_class.0.dart.expect
@@ -0,0 +1,16 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+class DataClass extends core::Object {
+ final field core::String string;
+ constructor •({required core::String string = #C1}) → self::DataClass
+ : self::DataClass::string = string, super core::Object::•()
+ ;
+}
+
+constants {
+ #C1 = null
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/data_class.1.dart b/pkg/front_end/test/macros/incremental/data/tests/data_class.1.dart
new file mode 100644
index 0000000..75ac97b
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/data_class.1.dart
@@ -0,0 +1,12 @@
+// Copyright (c) 2022, 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:macro/macro.dart';
+
+@ToStringMacro()
+class DataClass {
+ final String string;
+
+ DataClass({required this.string});
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/data_class.1.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/data_class.1.dart.expect
new file mode 100644
index 0000000..401567c
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/data_class.1.dart.expect
@@ -0,0 +1,22 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "package:macro/macro.dart" as mac;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+@#C1
+class DataClass extends core::Object {
+ final field core::String string;
+ constructor •({required core::String string = #C2}) → self::DataClass
+ : self::DataClass::string = string, super core::Object::•()
+ ;
+ method /* from org-dartlang-augmentation:/a/b/c/data_class.dart-0 */ toString() → core::String {
+ return "DataClass(string=${this.{self::DataClass::string}{core::String}})";
+ }
+}
+
+constants {
+ #C1 = #lib1::ToStringMacro {}
+ #C2 = null
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/data_class.2.dart b/pkg/front_end/test/macros/incremental/data/tests/data_class.2.dart
new file mode 100644
index 0000000..7ae60b6
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/data_class.2.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2022, 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:macro/macro.dart';
+
+@ToStringMacro()
+class DataClass {
+ final String string;
+ final int integer;
+
+ DataClass({required this.string, required this.integer});
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/data_class.2.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/data_class.2.dart.expect
new file mode 100644
index 0000000..bf0544d
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/data_class.2.dart.expect
@@ -0,0 +1,23 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "package:macro/macro.dart" as mac;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+@#C1
+class DataClass extends core::Object {
+ final field core::String string;
+ final field core::int integer;
+ constructor •({required core::String string = #C2, required core::int integer = #C2}) → self::DataClass
+ : self::DataClass::string = string, self::DataClass::integer = integer, super core::Object::•()
+ ;
+ method /* from org-dartlang-augmentation:/a/b/c/data_class.dart-0 */ toString() → core::String {
+ return "DataClass(string=${this.{self::DataClass::string}{core::String}},integer=${this.{self::DataClass::integer}{core::int}})";
+ }
+}
+
+constants {
+ #C1 = #lib1::ToStringMacro {}
+ #C2 = null
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/in_body_change.0.dart b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.0.dart
new file mode 100644
index 0000000..87a023f
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.0.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2022, 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:macro/macro.dart';
+
+@ToStringMacro()
+class Class {
+ final int field;
+
+ Class(this.field);
+
+ void method() {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/in_body_change.0.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.0.dart.expect
new file mode 100644
index 0000000..469fe1a
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.0.dart.expect
@@ -0,0 +1,22 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "package:macro/macro.dart" as mac;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+@#C1
+class Class extends core::Object {
+ final field core::int field;
+ constructor •(core::int field) → self::Class
+ : self::Class::field = field, super core::Object::•()
+ ;
+ method /* from org-dartlang-augmentation:/a/b/c/in_body_change.dart-0 */ toString() → core::String {
+ return "Class(field=${this.{self::Class::field}{core::int}})";
+ }
+ method method() → void {}
+}
+
+constants {
+ #C1 = #lib1::ToStringMacro {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/in_body_change.1.dart b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.1.dart
new file mode 100644
index 0000000..0b1a729
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.1.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2022, 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:macro/macro.dart';
+
+@ToStringMacro()
+class Class {
+ final int field;
+
+ Class(this.field);
+
+ void method() {
+ print('method');
+ }
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/in_body_change.1.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.1.dart.expect
new file mode 100644
index 0000000..f95a86f
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/in_body_change.1.dart.expect
@@ -0,0 +1,24 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "package:macro/macro.dart" as mac;
+import "dart:core" as core;
+
+import "package:macro/macro.dart";
+
+@#C1
+class Class extends core::Object {
+ final field core::int field;
+ constructor •(core::int field) → self::Class
+ : self::Class::field = field, super core::Object::•()
+ ;
+ method /* from org-dartlang-augmentation:/a/b/c/in_body_change.dart-0 */ toString() → core::String {
+ return "Class(field=${this.{self::Class::field}{core::int}})";
+ }
+ method method() → void {
+ core::print("method");
+ }
+}
+
+constants {
+ #C1 = #lib1::ToStringMacro {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/user_macro/macro.0.dart b/pkg/front_end/test/macros/incremental/data/tests/user_macro/macro.0.dart
new file mode 100644
index 0000000..73a3a2d
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/user_macro/macro.0.dart
@@ -0,0 +1,16 @@
+// Copyright (c) 2022, 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 'dart:async';
+import 'package:_fe_analyzer_shared/src/macros/api.dart';
+
+macro
+
+class MethodMacro implements ClassDeclarationsMacro {
+ const MethodMacro();
+
+ @override
+ FutureOr<void> buildDeclarationsForClass(ClassDeclaration clazz,
+ ClassMemberDeclarationBuilder builder) async {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/user_macro/macro.1.dart b/pkg/front_end/test/macros/incremental/data/tests/user_macro/macro.1.dart
new file mode 100644
index 0000000..0129964
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/user_macro/macro.1.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2022, 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 'dart:async';
+import 'package:_fe_analyzer_shared/src/macros/api.dart';
+
+macro
+
+class MethodMacro implements ClassDeclarationsMacro {
+ const MethodMacro();
+
+ @override
+ FutureOr<void> buildDeclarationsForClass(ClassDeclaration clazz,
+ ClassMemberDeclarationBuilder builder) async {
+ builder.declareInClass(new DeclarationCode.fromString('''
+ void method() {}
+'''));
+ }
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.0.dart b/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.0.dart
new file mode 100644
index 0000000..9e7e582
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.0.dart
@@ -0,0 +1,8 @@
+// Copyright (c) 2022, 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 'macro.dart';
+
+@MethodMacro()
+class Class {}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.0.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.0.dart.expect
new file mode 100644
index 0000000..3b13cdd
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.0.dart.expect
@@ -0,0 +1,34 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "macro.dart" as mac;
+import "dart:core" as core;
+
+import "org-dartlang-test:///a/b/c/user_macro/macro.dart";
+
+@#C1
+class Class extends core::Object {
+ synthetic constructor •() → self::Class
+ : super core::Object::•()
+ ;
+}
+
+library /*isNonNullableByDefault*/;
+import self as mac;
+import "dart:core" as core;
+import "package:_fe_analyzer_shared/src/macros/api.dart" as api;
+
+import "dart:async";
+import "package:_fe_analyzer_shared/src/macros/api.dart";
+
+macro class MethodMacro extends core::Object implements api::ClassDeclarationsMacro /*hasConstConstructor*/ {
+ const constructor •() → mac::MethodMacro
+ : super core::Object::•()
+ ;
+ @#C2
+ method buildDeclarationsForClass(api::ClassDeclaration clazz, api::ClassMemberDeclarationBuilder builder) → FutureOr<void> async {}
+}
+
+constants {
+ #C1 = mac::MethodMacro {}
+ #C2 = dart.core::_Override {}
+}
diff --git a/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.1.dart.expect b/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.1.dart.expect
new file mode 100644
index 0000000..9a9c376
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/data/tests/user_macro/main.1.dart.expect
@@ -0,0 +1,37 @@
+library /*isNonNullableByDefault*/;
+import self as self;
+import "macro.dart" as mac;
+import "dart:core" as core;
+
+import "org-dartlang-test:///a/b/c/user_macro/macro.dart";
+
+@#C1
+class Class extends core::Object {
+ synthetic constructor •() → self::Class
+ : super core::Object::•()
+ ;
+ method /* from org-dartlang-augmentation:/a/b/c/user_macro/main.dart-0 */ method() → void {}
+}
+
+library /*isNonNullableByDefault*/;
+import self as mac;
+import "dart:core" as core;
+import "package:_fe_analyzer_shared/src/macros/api.dart" as api;
+
+import "dart:async";
+import "package:_fe_analyzer_shared/src/macros/api.dart";
+
+macro class MethodMacro extends core::Object implements api::ClassDeclarationsMacro /*hasConstConstructor*/ {
+ const constructor •() → mac::MethodMacro
+ : super core::Object::•()
+ ;
+ @#C2
+ method buildDeclarationsForClass(api::ClassDeclaration clazz, api::ClassMemberDeclarationBuilder builder) → FutureOr<void> async {
+ builder.{api::ClassMemberDeclarationBuilder::declareInClass}(new api::DeclarationCode::fromString(" void method() {}\n")){(api::DeclarationCode) → void};
+ }
+}
+
+constants {
+ #C1 = mac::MethodMacro {}
+ #C2 = dart.core::_Override {}
+}
diff --git a/pkg/front_end/test/macros/incremental/incremental_macro_test.dart b/pkg/front_end/test/macros/incremental/incremental_macro_test.dart
new file mode 100644
index 0000000..e6fd95e
--- /dev/null
+++ b/pkg/front_end/test/macros/incremental/incremental_macro_test.dart
@@ -0,0 +1,174 @@
+// Copyright (c) 2022, 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 'dart:io';
+
+import 'package:_fe_analyzer_shared/src/macros/executor/isolated_executor.dart'
+ as isolatedExecutor;
+import 'package:_fe_analyzer_shared/src/macros/executor/serialization.dart';
+import 'package:front_end/src/api_prototype/compiler_options.dart';
+import 'package:front_end/src/api_prototype/experimental_flags.dart';
+import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
+import 'package:front_end/src/api_prototype/memory_file_system.dart';
+import 'package:front_end/src/base/processed_options.dart';
+import 'package:front_end/src/compute_platform_binaries_location.dart';
+import 'package:front_end/src/fasta/compiler_context.dart';
+import 'package:front_end/src/fasta/hybrid_file_system.dart';
+import 'package:front_end/src/fasta/incremental_compiler.dart';
+import 'package:front_end/src/fasta/kernel/macro.dart';
+import 'package:front_end/src/isolate_macro_serializer.dart';
+import 'package:front_end/src/macro_serializer.dart';
+import 'package:front_end/src/testing/compiler_common.dart';
+import 'package:kernel/ast.dart';
+import 'package:kernel/target/targets.dart';
+import 'package:kernel/text/ast_to_text.dart';
+import 'package:vm/target/vm.dart';
+
+import '../../utils/kernel_chain.dart';
+
+Future<void> main(List<String> args) async {
+ Map<String, Test> tests = {};
+ Map<String, Map<Uri, Map<int, String>>> testData = {};
+ Directory dataDir =
+ new Directory.fromUri(Platform.script.resolve('data/tests'));
+
+ void addFile(Test? test, FileSystemEntity file, String fileName) {
+ if (file is! File || !fileName.endsWith('.dart')) {
+ return;
+ }
+ String testFileName = fileName.substring(0, fileName.length - 5);
+ int dotIndex = testFileName.lastIndexOf('.');
+ int index = 1;
+ if (dotIndex != -1) {
+ index = int.parse(testFileName.substring(dotIndex + 1));
+ testFileName = testFileName.substring(0, dotIndex);
+ }
+ String testName = testFileName;
+ testFileName += '.dart';
+ Uri uri = toTestUri(testFileName);
+ test ??= new Test(testName, uri);
+ tests[test.name] ??= test;
+ Map<Uri, Map<int, String>> updates = testData[test.name] ??= {};
+ (updates[uri] ??= {})[index] = file.readAsStringSync();
+ }
+
+ for (FileSystemEntity file in dataDir.listSync()) {
+ String fileName = file.uri.pathSegments.last;
+ if (file is Directory) {
+ Directory dir = file;
+ // Note that the last segment of a directory uri is the empty string!
+ String dirName = dir.uri.pathSegments[dir.uri.pathSegments.length - 2];
+ Test test = new Test('$dirName/main', toTestUri('$dirName/main.dart'));
+ for (FileSystemEntity file in dir.listSync()) {
+ addFile(test, file, '$dirName/${file.uri.pathSegments.last}');
+ }
+ } else {
+ addFile(null, file, fileName);
+ }
+ }
+
+ testData.forEach((String testName, Map<Uri, Map<int, String>> files) {
+ Test test = tests[testName]!;
+ Map<int, Map<Uri, String>> updatesMap = {};
+ files.forEach((Uri uri, Map<int, String> updates) {
+ test.uris.add(uri);
+ updates.forEach((int index, String source) {
+ (updatesMap[index] ??= {})[uri] = source;
+ });
+ });
+ for (int index in updatesMap.keys.toList()..sort()) {
+ test.updates.add(new TestUpdate(index, updatesMap[index]!));
+ }
+ });
+
+ args = args.toList();
+ bool generateExpectations = args.remove('-g');
+ enableMacros = true;
+ MacroSerializer macroSerializer = new IsolateMacroSerializer();
+ MemoryFileSystem memoryFileSystem = createMemoryFileSystem();
+ CompilerOptions compilerOptions = new CompilerOptions()
+ ..sdkRoot = computePlatformBinariesLocation(forceBuildDir: true)
+ ..packagesFileUri = Platform.script.resolve('data/package_config.json')
+ ..explicitExperimentalFlags = {ExperimentalFlag.macros: true}
+ ..macroSerializer = macroSerializer
+ ..precompiledMacroUris = {}
+ ..macroExecutorProvider = () async {
+ return await isolatedExecutor.start(SerializationMode.byteDataServer);
+ }
+ ..macroTarget = new VmTarget(new TargetFlags())
+ ..fileSystem = new HybridFileSystem(memoryFileSystem);
+
+ ProcessedOptions processedOptions =
+ new ProcessedOptions(options: compilerOptions);
+
+ await CompilerContext.runWithOptions(processedOptions,
+ (CompilerContext context) async {
+ IncrementalCompiler compiler = new IncrementalCompiler(context);
+ for (Test test in tests.values) {
+ if (args.isNotEmpty && !args.contains(test.name)) {
+ print('Skipped ${test.name}');
+ continue;
+ }
+ Uri entryPoint = test.entryPoint;
+ for (TestUpdate update in test.updates) {
+ print('Running ${test.name} update ${update.index}');
+ update.files.forEach((Uri uri, String source) {
+ memoryFileSystem.entityForUri(uri).writeAsStringSync(source);
+ compiler.invalidate(uri);
+ });
+ IncrementalCompilerResult incrementalCompilerResult =
+ await compiler.computeDelta(entryPoints: [entryPoint]);
+ Component component = incrementalCompilerResult.component;
+ StringBuffer buffer = new StringBuffer();
+ Printer printer = new Printer(buffer)
+ ..writeProblemsAsJson(
+ "Problems in component", component.problemsAsJson);
+ component.libraries.forEach((Library library) {
+ if (test.uris.contains(library.importUri)) {
+ printer.writeLibraryFile(library);
+ printer.endLine();
+ }
+ });
+ printer.writeConstantTable(component);
+ String actual = buffer.toString();
+ String expectationFileName = '${test.name}.${update.index}.dart.expect';
+ Uri expectedUri = dataDir.uri.resolve(expectationFileName);
+ File expectationFile = new File.fromUri(expectedUri);
+ if (expectationFile.existsSync()) {
+ String expected = expectationFile.readAsStringSync();
+ if (expected != actual) {
+ if (generateExpectations) {
+ expectationFile.writeAsStringSync(actual);
+ } else {
+ String diff = await runDiff(expectedUri, actual);
+ throw "${expectationFileName} don't match ${expectedUri}\n$diff";
+ }
+ }
+ } else if (generateExpectations) {
+ expectationFile.writeAsStringSync(actual);
+ } else {
+ throw 'Please use -g option to create file ${expectationFileName} '
+ 'with this content:\n$actual';
+ }
+ }
+ }
+ }, errorOnMissingInput: false);
+ await macroSerializer.close();
+}
+
+class Test {
+ final String name;
+ final Uri entryPoint;
+ final Set<Uri> uris = {};
+ final List<TestUpdate> updates = [];
+
+ Test(this.name, this.entryPoint);
+}
+
+class TestUpdate {
+ final int index;
+ final Map<Uri, String> files;
+
+ TestUpdate(this.index, this.files);
+}
diff --git a/pkg/front_end/testcases/general/macro_class.dart.weak.expect b/pkg/front_end/testcases/general/macro_class.dart.weak.expect
index ce6b7bb..11f0500 100644
--- a/pkg/front_end/testcases/general/macro_class.dart.weak.expect
+++ b/pkg/front_end/testcases/general/macro_class.dart.weak.expect
@@ -2,15 +2,15 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/macro_class.dart:8:7: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:8:1: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// macro class Class1 {}
-// ^^^^^
+// ^^^^^
//
-// pkg/front_end/testcases/general/macro_class.dart:9:16: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:9:10: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// abstract macro class Class2 {}
-// ^^^^^
+// ^^^^^
//
// pkg/front_end/testcases/general/macro_class.dart:10:7: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
diff --git a/pkg/front_end/testcases/general/macro_class.dart.weak.modular.expect b/pkg/front_end/testcases/general/macro_class.dart.weak.modular.expect
index ce6b7bb..11f0500 100644
--- a/pkg/front_end/testcases/general/macro_class.dart.weak.modular.expect
+++ b/pkg/front_end/testcases/general/macro_class.dart.weak.modular.expect
@@ -2,15 +2,15 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/macro_class.dart:8:7: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:8:1: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// macro class Class1 {}
-// ^^^^^
+// ^^^^^
//
-// pkg/front_end/testcases/general/macro_class.dart:9:16: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:9:10: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// abstract macro class Class2 {}
-// ^^^^^
+// ^^^^^
//
// pkg/front_end/testcases/general/macro_class.dart:10:7: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
diff --git a/pkg/front_end/testcases/general/macro_class.dart.weak.outline.expect b/pkg/front_end/testcases/general/macro_class.dart.weak.outline.expect
index 614ee32..96f69a5 100644
--- a/pkg/front_end/testcases/general/macro_class.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/macro_class.dart.weak.outline.expect
@@ -2,15 +2,15 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/macro_class.dart:8:7: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:8:1: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// macro class Class1 {}
-// ^^^^^
+// ^^^^^
//
-// pkg/front_end/testcases/general/macro_class.dart:9:16: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:9:10: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// abstract macro class Class2 {}
-// ^^^^^
+// ^^^^^
//
// pkg/front_end/testcases/general/macro_class.dart:10:7: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
diff --git a/pkg/front_end/testcases/general/macro_class.dart.weak.transformed.expect b/pkg/front_end/testcases/general/macro_class.dart.weak.transformed.expect
index 7f71bca..248efad 100644
--- a/pkg/front_end/testcases/general/macro_class.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/macro_class.dart.weak.transformed.expect
@@ -2,15 +2,15 @@
//
// Problems in library:
//
-// pkg/front_end/testcases/general/macro_class.dart:8:7: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:8:1: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// macro class Class1 {}
-// ^^^^^
+// ^^^^^
//
-// pkg/front_end/testcases/general/macro_class.dart:9:16: Error: This requires the 'macros' language feature to be enabled.
+// pkg/front_end/testcases/general/macro_class.dart:9:10: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
// abstract macro class Class2 {}
-// ^^^^^
+// ^^^^^
//
// pkg/front_end/testcases/general/macro_class.dart:10:7: Error: This requires the 'macros' language feature to be enabled.
// Try updating your pubspec.yaml to set the minimum SDK constraint to 2.17 or higher, and running 'pub get'.
diff --git a/pkg/front_end/testing.json b/pkg/front_end/testing.json
index 38037dc..0b67866 100644
--- a/pkg/front_end/testing.json
+++ b/pkg/front_end/testing.json
@@ -468,6 +468,7 @@
"test/language_versioning/data/",
"test/macros/application/data/",
"test/macros/declaration/data/",
+ "test/macros/incremental/data/",
"test/patching/data",
"test/predicates/data",
"test/static_types/data/",
diff --git a/pkg/nnbd_migration/lib/instrumentation.dart b/pkg/nnbd_migration/lib/instrumentation.dart
index afb9bd9..4326006 100644
--- a/pkg/nnbd_migration/lib/instrumentation.dart
+++ b/pkg/nnbd_migration/lib/instrumentation.dart
@@ -48,7 +48,7 @@
var path = unitElement.source.fullName;
var offset = element.nameOffset;
- var location = unitElement.lineInfo!.getLocation(offset);
+ var location = unitElement.lineInfo.getLocation(offset);
return CodeReference(path, offset, location.lineNumber,
location.columnNumber, _computeElementFullName(element));
}
diff --git a/pkg/vm_service/CHANGELOG.md b/pkg/vm_service/CHANGELOG.md
index 52ee6d0..a5a8f8b 100644
--- a/pkg/vm_service/CHANGELOG.md
+++ b/pkg/vm_service/CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog
## 8.2.1
+- Changed type of `UriList.uris` from `dynamic` to `List<String?>?`.
- Remove `example/vm_service_asserts.dart'
## 8.2.0
diff --git a/pkg/vm_service/lib/src/vm_service.dart b/pkg/vm_service/lib/src/vm_service.dart
index f22ff9d..b8b3cb6 100644
--- a/pkg/vm_service/lib/src/vm_service.dart
+++ b/pkg/vm_service/lib/src/vm_service.dart
@@ -8119,15 +8119,14 @@
json == null ? null : UriList._fromJson(json);
/// A list of URIs.
- List<dynamic>? uris;
+ List<String?>? uris;
UriList({
required this.uris,
});
UriList._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
- uris = List<dynamic>.from(
- createServiceObject(json['uris'], const ['dynamic']) as List? ?? []);
+ uris = List<String?>.from(json['uris']);
}
@override
@@ -8138,7 +8137,7 @@
final json = <String, dynamic>{};
json['type'] = type;
json.addAll({
- 'uris': uris?.map((f) => f.toJson()).toList(),
+ 'uris': uris?.map((f) => f).toList(),
});
return json;
}
diff --git a/pkg/vm_service/test/serialization_smoke_tests/uri_list_smoke_test.dart b/pkg/vm_service/test/serialization_smoke_tests/uri_list_smoke_test.dart
new file mode 100644
index 0000000..b5c514f
--- /dev/null
+++ b/pkg/vm_service/test/serialization_smoke_tests/uri_list_smoke_test.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test/test.dart';
+import 'package:vm_service/vm_service.dart';
+
+// Regression test for https://github.com/dart-lang/sdk/issues/48521.
+
+void main() {
+ const expectedUris = <String?>[
+ 'file:///a/b/c',
+ 'dart:io',
+ 'package:foo/bar.dart',
+ null,
+ ];
+
+ test('UriList serialization', () {
+ final uriList = UriList(uris: expectedUris);
+ final serialized = uriList.toJson();
+ expect(serialized['type'], 'UriList');
+ expect(serialized['uris'], isA<List>());
+ final uris = serialized['uris'].cast<String?>();
+ expect(uris.length, 4);
+ for (int i = 0; i < uris.length; ++i) {
+ expect(expectedUris[i], uris[i]);
+ }
+ });
+
+ test('UriList deserialization', () {
+ final json = <String, dynamic>{
+ 'type': 'UriList',
+ 'uris': expectedUris,
+ };
+
+ final uriList = UriList.parse(json);
+ expect(uriList, isNotNull);
+ expect(uriList!.uris, expectedUris);
+ });
+}
diff --git a/pkg/vm_service/test/uri_mappings_lookup_test.dart b/pkg/vm_service/test/uri_mappings_lookup_test.dart
index 0155833..accc20c 100644
--- a/pkg/vm_service/test/uri_mappings_lookup_test.dart
+++ b/pkg/vm_service/test/uri_mappings_lookup_test.dart
@@ -35,7 +35,7 @@
result = await service.lookupPackageUris(
isolateId,
[
- ...uris.sublist(0, 3),
+ ...uris.sublist(0, 3).cast<String>(),
'does_not_exist.dart',
],
);
diff --git a/pkg/vm_service/tool/dart/generate_dart.dart b/pkg/vm_service/tool/dart/generate_dart.dart
index c907438..e15328c 100644
--- a/pkg/vm_service/tool/dart/generate_dart.dart
+++ b/pkg/vm_service/tool/dart/generate_dart.dart
@@ -1091,16 +1091,30 @@
// foo|bar[]|baz
// (@Instance|Sentinel)[]
bool loop = true;
+ bool nullable = false;
this.isReturnType = isReturnType;
+ final unionTypes = <String>[];
while (loop) {
if (parser.consume('(')) {
while (parser.peek()!.text != ')') {
- // @Instance | Sentinel
- parser.advance();
+ if (parser.consume('Null')) {
+ nullable = true;
+ } else {
+ // @Instance | Sentinel
+ final token = parser.advance()!;
+ if (token.isName) {
+ unionTypes.add(_coerceRefType(token.text)!);
+ }
+ }
}
parser.consume(')');
- TypeRef ref = TypeRef('dynamic');
+ TypeRef ref;
+ if (unionTypes.length == 1) {
+ ref = TypeRef(unionTypes.first)..nullable = nullable;
+ } else {
+ ref = TypeRef('dynamic');
+ }
while (parser.consume('[')) {
parser.expect(']');
ref.arrayDepth++;
@@ -1148,15 +1162,16 @@
class TypeRef {
String? name;
int arrayDepth = 0;
+ bool nullable = false;
List<TypeRef>? genericTypes;
TypeRef(this.name);
String get ref {
if (arrayDepth == 2) {
- return 'List<List<${name}>>';
+ return 'List<List<${name}${nullable ? "?" : ""}>>';
} else if (arrayDepth == 1) {
- return 'List<${name}>';
+ return 'List<${name}${nullable ? "?" : ""}>';
} else if (genericTypes != null) {
return '$name<${genericTypes!.join(', ')}>';
} else {
@@ -1168,13 +1183,15 @@
assert(arrayDepth == 1);
if (isListTypeSimple) {
- return 'List<$name>';
+ return 'List<$name${nullable ? "?" : ""}>';
} else {
return 'List<String>';
}
}
- String? get listTypeArg => arrayDepth == 2 ? 'List<$name>' : name;
+ String? get listTypeArg => arrayDepth == 2
+ ? 'List<$name${nullable ? "?" : ""}>'
+ : '$name${nullable ? "?" : ""}';
bool get isArray => arrayDepth > 0;
diff --git a/tests/web/regress/if_method_call_test.dart b/tests/web/if_method_call_test.dart
similarity index 100%
rename from tests/web/regress/if_method_call_test.dart
rename to tests/web/if_method_call_test.dart
diff --git a/tests/web/10216a_test.dart b/tests/web/regress/issue/10216a_test.dart
similarity index 100%
rename from tests/web/10216a_test.dart
rename to tests/web/regress/issue/10216a_test.dart
diff --git a/tests/web/10216b_test.dart b/tests/web/regress/issue/10216b_test.dart
similarity index 100%
rename from tests/web/10216b_test.dart
rename to tests/web/regress/issue/10216b_test.dart
diff --git a/tests/web/11673_test.dart b/tests/web/regress/issue/11673_test.dart
similarity index 100%
rename from tests/web/11673_test.dart
rename to tests/web/regress/issue/11673_test.dart
diff --git a/tests/web/12320_test.dart b/tests/web/regress/issue/12320_test.dart
similarity index 100%
rename from tests/web/12320_test.dart
rename to tests/web/regress/issue/12320_test.dart
diff --git a/tests/web/12_test.dart b/tests/web/regress/issue/12_test.dart
similarity index 100%
rename from tests/web/12_test.dart
rename to tests/web/regress/issue/12_test.dart
diff --git a/tests/web/16400_test.dart b/tests/web/regress/issue/16400_test.dart
similarity index 100%
rename from tests/web/16400_test.dart
rename to tests/web/regress/issue/16400_test.dart
diff --git a/tests/web/16407_test.dart b/tests/web/regress/issue/16407_test.dart
similarity index 100%
rename from tests/web/16407_test.dart
rename to tests/web/regress/issue/16407_test.dart
diff --git a/tests/web/16967_test.dart b/tests/web/regress/issue/16967_test.dart
similarity index 100%
rename from tests/web/16967_test.dart
rename to tests/web/regress/issue/16967_test.dart
diff --git a/tests/web/17094_test.dart b/tests/web/regress/issue/17094_test.dart
similarity index 100%
rename from tests/web/17094_test.dart
rename to tests/web/regress/issue/17094_test.dart
diff --git a/tests/web/17645_test.dart b/tests/web/regress/issue/17645_test.dart
similarity index 100%
rename from tests/web/17645_test.dart
rename to tests/web/regress/issue/17645_test.dart
diff --git a/tests/web/17856_test.dart b/tests/web/regress/issue/17856_test.dart
similarity index 100%
rename from tests/web/17856_test.dart
rename to tests/web/regress/issue/17856_test.dart
diff --git a/tests/web/18175_test.dart b/tests/web/regress/issue/18175_test.dart
similarity index 100%
rename from tests/web/18175_test.dart
rename to tests/web/regress/issue/18175_test.dart
diff --git a/tests/web/18383_test.dart b/tests/web/regress/issue/18383_test.dart
similarity index 100%
rename from tests/web/18383_test.dart
rename to tests/web/regress/issue/18383_test.dart
diff --git a/tests/web/regress/190814734a_test.dart b/tests/web/regress/issue/190814734a_test.dart
similarity index 100%
rename from tests/web/regress/190814734a_test.dart
rename to tests/web/regress/issue/190814734a_test.dart
diff --git a/tests/web/regress/190814734b_test.dart b/tests/web/regress/issue/190814734b_test.dart
similarity index 100%
rename from tests/web/regress/190814734b_test.dart
rename to tests/web/regress/issue/190814734b_test.dart
diff --git a/tests/web/19191_test.dart b/tests/web/regress/issue/19191_test.dart
similarity index 100%
rename from tests/web/19191_test.dart
rename to tests/web/regress/issue/19191_test.dart
diff --git a/tests/web/regress/192964907a_test.dart b/tests/web/regress/issue/192964907a_test.dart
similarity index 100%
rename from tests/web/regress/192964907a_test.dart
rename to tests/web/regress/issue/192964907a_test.dart
diff --git a/tests/web/regress/192964907b_test.dart b/tests/web/regress/issue/192964907b_test.dart
similarity index 100%
rename from tests/web/regress/192964907b_test.dart
rename to tests/web/regress/issue/192964907b_test.dart
diff --git a/tests/web/21351_test.dart b/tests/web/regress/issue/21351_test.dart
similarity index 100%
rename from tests/web/21351_test.dart
rename to tests/web/regress/issue/21351_test.dart
diff --git a/tests/web/21579_test.dart b/tests/web/regress/issue/21579_test.dart
similarity index 100%
rename from tests/web/21579_test.dart
rename to tests/web/regress/issue/21579_test.dart
diff --git a/tests/web/22487_test.dart b/tests/web/regress/issue/22487_test.dart
similarity index 100%
rename from tests/web/22487_test.dart
rename to tests/web/regress/issue/22487_test.dart
diff --git a/tests/web/22776_test.dart b/tests/web/regress/issue/22776_test.dart
similarity index 100%
rename from tests/web/22776_test.dart
rename to tests/web/regress/issue/22776_test.dart
diff --git a/tests/web/22868_test.dart b/tests/web/regress/issue/22868_test.dart
similarity index 100%
rename from tests/web/22868_test.dart
rename to tests/web/regress/issue/22868_test.dart
diff --git a/tests/web/22917_test.dart b/tests/web/regress/issue/22917_test.dart
similarity index 100%
rename from tests/web/22917_test.dart
rename to tests/web/regress/issue/22917_test.dart
diff --git a/tests/web/23404_test.dart b/tests/web/regress/issue/23404_test.dart
similarity index 100%
rename from tests/web/23404_test.dart
rename to tests/web/regress/issue/23404_test.dart
diff --git a/tests/web/23432_test.dart b/tests/web/regress/issue/23432_test.dart
similarity index 100%
rename from tests/web/23432_test.dart
rename to tests/web/regress/issue/23432_test.dart
diff --git a/tests/web/23486_helper.dart b/tests/web/regress/issue/23486_helper.dart
similarity index 100%
rename from tests/web/23486_helper.dart
rename to tests/web/regress/issue/23486_helper.dart
diff --git a/tests/web/23486_test.dart b/tests/web/regress/issue/23486_test.dart
similarity index 100%
rename from tests/web/23486_test.dart
rename to tests/web/regress/issue/23486_test.dart
diff --git a/tests/web/23804_test.dart b/tests/web/regress/issue/23804_test.dart
similarity index 100%
rename from tests/web/23804_test.dart
rename to tests/web/regress/issue/23804_test.dart
diff --git a/tests/web/23828_test.dart b/tests/web/regress/issue/23828_test.dart
similarity index 100%
rename from tests/web/23828_test.dart
rename to tests/web/regress/issue/23828_test.dart
diff --git a/tests/web/26243_test.dart b/tests/web/regress/issue/26243_test.dart
similarity index 100%
rename from tests/web/26243_test.dart
rename to tests/web/regress/issue/26243_test.dart
diff --git a/tests/web/27198_test.dart b/tests/web/regress/issue/27198_test.dart
similarity index 100%
rename from tests/web/27198_test.dart
rename to tests/web/regress/issue/27198_test.dart
diff --git a/tests/web/27199_test.dart b/tests/web/regress/issue/27199_test.dart
similarity index 100%
rename from tests/web/27199_test.dart
rename to tests/web/regress/issue/27199_test.dart
diff --git a/tests/web/27323_test.dart b/tests/web/regress/issue/27323_test.dart
similarity index 100%
rename from tests/web/27323_test.dart
rename to tests/web/regress/issue/27323_test.dart
diff --git a/tests/web/27354_test.dart b/tests/web/regress/issue/27354_test.dart
similarity index 100%
rename from tests/web/27354_test.dart
rename to tests/web/regress/issue/27354_test.dart
diff --git a/tests/web/28749_test.dart b/tests/web/regress/issue/28749_test.dart
similarity index 100%
rename from tests/web/28749_test.dart
rename to tests/web/regress/issue/28749_test.dart
diff --git a/tests/web/28919_test.dart b/tests/web/regress/issue/28919_test.dart
similarity index 100%
rename from tests/web/28919_test.dart
rename to tests/web/regress/issue/28919_test.dart
diff --git a/tests/web/29130_test.dart b/tests/web/regress/issue/29130_test.dart
similarity index 100%
rename from tests/web/29130_test.dart
rename to tests/web/regress/issue/29130_test.dart
diff --git a/tests/web/regression_2913_test.dart b/tests/web/regress/issue/2913_test.dart
similarity index 100%
rename from tests/web/regression_2913_test.dart
rename to tests/web/regress/issue/2913_test.dart
diff --git a/tests/web/31803_test.dart b/tests/web/regress/issue/31803_test.dart
similarity index 100%
rename from tests/web/31803_test.dart
rename to tests/web/regress/issue/31803_test.dart
diff --git a/tests/web/regress_32069_test.dart b/tests/web/regress/issue/32069_test.dart
similarity index 100%
rename from tests/web/regress_32069_test.dart
rename to tests/web/regress/issue/32069_test.dart
diff --git a/tests/web/32770a_test.dart b/tests/web/regress/issue/32770a_test.dart
similarity index 100%
rename from tests/web/32770a_test.dart
rename to tests/web/regress/issue/32770a_test.dart
diff --git a/tests/web/32770b_test.dart b/tests/web/regress/issue/32770b_test.dart
similarity index 100%
rename from tests/web/32770b_test.dart
rename to tests/web/regress/issue/32770b_test.dart
diff --git a/tests/web/32770c_test.dart b/tests/web/regress/issue/32770c_test.dart
similarity index 100%
rename from tests/web/32770c_test.dart
rename to tests/web/regress/issue/32770c_test.dart
diff --git a/tests/web/32774_test.dart b/tests/web/regress/issue/32774_test.dart
similarity index 100%
rename from tests/web/32774_test.dart
rename to tests/web/regress/issue/32774_test.dart
diff --git a/tests/web/32828_test.dart b/tests/web/regress/issue/32828_test.dart
similarity index 100%
rename from tests/web/32828_test.dart
rename to tests/web/regress/issue/32828_test.dart
diff --git a/tests/web/32853_test.dart b/tests/web/regress/issue/32853_test.dart
similarity index 99%
rename from tests/web/32853_test.dart
rename to tests/web/regress/issue/32853_test.dart
index ccf8dab..8c32ce6 100644
--- a/tests/web/32853_test.dart
+++ b/tests/web/regress/issue/32853_test.dart
@@ -6,10 +6,9 @@
// Regression test for issue 32853.
-
int foo<T extends Comparable<T>>(T a, T b) => a.compareTo(b);
main() {
int Function<T extends Comparable<T>>(T, T) f = foo;
print(f<num>(1, 2));
-}
\ No newline at end of file
+}
diff --git a/tests/web/32928_test.dart b/tests/web/regress/issue/32928_test.dart
similarity index 100%
rename from tests/web/32928_test.dart
rename to tests/web/regress/issue/32928_test.dart
diff --git a/tests/web/32969_test.dart b/tests/web/regress/issue/32969_test.dart
similarity index 100%
rename from tests/web/32969_test.dart
rename to tests/web/regress/issue/32969_test.dart
diff --git a/tests/web/32997a_lib.dart b/tests/web/regress/issue/32997a_lib.dart
similarity index 100%
rename from tests/web/32997a_lib.dart
rename to tests/web/regress/issue/32997a_lib.dart
diff --git a/tests/web/32997a_test.dart b/tests/web/regress/issue/32997a_test.dart
similarity index 100%
rename from tests/web/32997a_test.dart
rename to tests/web/regress/issue/32997a_test.dart
diff --git a/tests/web/32997b_lib.dart b/tests/web/regress/issue/32997b_lib.dart
similarity index 100%
rename from tests/web/32997b_lib.dart
rename to tests/web/regress/issue/32997b_lib.dart
diff --git a/tests/web/32997b_test.dart b/tests/web/regress/issue/32997b_test.dart
similarity index 100%
rename from tests/web/32997b_test.dart
rename to tests/web/regress/issue/32997b_test.dart
diff --git a/tests/web/33296_test.dart b/tests/web/regress/issue/33296_test.dart
similarity index 100%
rename from tests/web/33296_test.dart
rename to tests/web/regress/issue/33296_test.dart
diff --git a/tests/web/33572_test.dart b/tests/web/regress/issue/33572_test.dart
similarity index 100%
rename from tests/web/33572_test.dart
rename to tests/web/regress/issue/33572_test.dart
diff --git a/tests/web/33_test.dart b/tests/web/regress/issue/33_test.dart
similarity index 100%
rename from tests/web/33_test.dart
rename to tests/web/regress/issue/33_test.dart
diff --git a/tests/web/34156_test.dart b/tests/web/regress/issue/34156_test.dart
similarity index 100%
rename from tests/web/34156_test.dart
rename to tests/web/regress/issue/34156_test.dart
diff --git a/tests/web/34701_test.dart b/tests/web/regress/issue/34701_test.dart
similarity index 100%
rename from tests/web/34701_test.dart
rename to tests/web/regress/issue/34701_test.dart
diff --git a/tests/web/35341_test.dart b/tests/web/regress/issue/35341_test.dart
similarity index 100%
rename from tests/web/35341_test.dart
rename to tests/web/regress/issue/35341_test.dart
diff --git a/tests/web/35356_test.dart b/tests/web/regress/issue/35356_test.dart
similarity index 100%
rename from tests/web/35356_test.dart
rename to tests/web/regress/issue/35356_test.dart
diff --git a/tests/web/35853_test.dart b/tests/web/regress/issue/35853_test.dart
similarity index 100%
rename from tests/web/35853_test.dart
rename to tests/web/regress/issue/35853_test.dart
diff --git a/tests/web/35965a_test.dart b/tests/web/regress/issue/35965a_test.dart
similarity index 100%
rename from tests/web/35965a_test.dart
rename to tests/web/regress/issue/35965a_test.dart
diff --git a/tests/web/regress_36222_test.dart b/tests/web/regress/issue/36222_test.dart
similarity index 100%
rename from tests/web/regress_36222_test.dart
rename to tests/web/regress/issue/36222_test.dart
diff --git a/tests/web/issue36562_test.dart b/tests/web/regress/issue/36562_test.dart
similarity index 100%
rename from tests/web/issue36562_test.dart
rename to tests/web/regress/issue/36562_test.dart
diff --git a/tests/web/37494_test.dart b/tests/web/regress/issue/37494_test.dart
similarity index 100%
rename from tests/web/37494_test.dart
rename to tests/web/regress/issue/37494_test.dart
diff --git a/tests/web/37576_test.dart b/tests/web/regress/issue/37576_test.dart
similarity index 100%
rename from tests/web/37576_test.dart
rename to tests/web/regress/issue/37576_test.dart
diff --git a/tests/web/38005_test.dart b/tests/web/regress/issue/38005_test.dart
similarity index 100%
rename from tests/web/38005_test.dart
rename to tests/web/regress/issue/38005_test.dart
diff --git a/tests/web/38949_test.dart b/tests/web/regress/issue/38949_test.dart
similarity index 100%
rename from tests/web/38949_test.dart
rename to tests/web/regress/issue/38949_test.dart
diff --git a/tests/web/3_test.dart b/tests/web/regress/issue/3_test.dart
similarity index 100%
rename from tests/web/3_test.dart
rename to tests/web/regress/issue/3_test.dart
diff --git a/tests/web/40152a_test.dart b/tests/web/regress/issue/40152a_test.dart
similarity index 100%
rename from tests/web/40152a_test.dart
rename to tests/web/regress/issue/40152a_test.dart
diff --git a/tests/web/regress_40349_test.dart b/tests/web/regress/issue/40349_test.dart
similarity index 100%
rename from tests/web/regress_40349_test.dart
rename to tests/web/regress/issue/40349_test.dart
diff --git a/tests/web/40902_test.dart b/tests/web/regress/issue/40902_test.dart
similarity index 100%
rename from tests/web/40902_test.dart
rename to tests/web/regress/issue/40902_test.dart
diff --git a/tests/web/41449a_test.dart b/tests/web/regress/issue/41449a_test.dart
similarity index 100%
rename from tests/web/41449a_test.dart
rename to tests/web/regress/issue/41449a_test.dart
diff --git a/tests/web/41449b_test.dart b/tests/web/regress/issue/41449b_test.dart
similarity index 100%
rename from tests/web/41449b_test.dart
rename to tests/web/regress/issue/41449b_test.dart
diff --git a/tests/web/41449c_test.dart b/tests/web/regress/issue/41449c_test.dart
similarity index 100%
rename from tests/web/41449c_test.dart
rename to tests/web/regress/issue/41449c_test.dart
diff --git a/tests/web/41449d_test.dart b/tests/web/regress/issue/41449d_test.dart
similarity index 100%
rename from tests/web/41449d_test.dart
rename to tests/web/regress/issue/41449d_test.dart
diff --git a/tests/web/regress/41781_test.dart b/tests/web/regress/issue/41781_test.dart
similarity index 100%
rename from tests/web/regress/41781_test.dart
rename to tests/web/regress/issue/41781_test.dart
diff --git a/tests/web/42088_test.dart b/tests/web/regress/issue/42088_test.dart
similarity index 100%
rename from tests/web/42088_test.dart
rename to tests/web/regress/issue/42088_test.dart
diff --git a/tests/web/42189_test.dart b/tests/web/regress/issue/42189_test.dart
similarity index 100%
rename from tests/web/42189_test.dart
rename to tests/web/regress/issue/42189_test.dart
diff --git a/tests/web/regress_42281_test.dart b/tests/web/regress/issue/42281_test.dart
similarity index 100%
rename from tests/web/regress_42281_test.dart
rename to tests/web/regress/issue/42281_test.dart
diff --git a/tests/web/42501_test.dart b/tests/web/regress/issue/42501_test.dart
similarity index 100%
rename from tests/web/42501_test.dart
rename to tests/web/regress/issue/42501_test.dart
diff --git a/tests/web/42531_test.dart b/tests/web/regress/issue/42531_test.dart
similarity index 100%
rename from tests/web/42531_test.dart
rename to tests/web/regress/issue/42531_test.dart
diff --git a/tests/web/regress/43520_safari_test.dart b/tests/web/regress/issue/43520_safari_test.dart
similarity index 100%
rename from tests/web/regress/43520_safari_test.dart
rename to tests/web/regress/issue/43520_safari_test.dart
diff --git a/tests/web/43_test.dart b/tests/web/regress/issue/43_test.dart
similarity index 100%
rename from tests/web/43_test.dart
rename to tests/web/regress/issue/43_test.dart
diff --git a/tests/web/regress/4434_lib.dart b/tests/web/regress/issue/4434_lib.dart
similarity index 100%
rename from tests/web/regress/4434_lib.dart
rename to tests/web/regress/issue/4434_lib.dart
diff --git a/tests/web/regress/4434_test.dart b/tests/web/regress/issue/4434_test.dart
similarity index 100%
rename from tests/web/regress/4434_test.dart
rename to tests/web/regress/issue/4434_test.dart
diff --git a/tests/web/regress/44818_test.dart b/tests/web/regress/issue/44818_test.dart
similarity index 100%
rename from tests/web/regress/44818_test.dart
rename to tests/web/regress/issue/44818_test.dart
diff --git a/tests/web/regress/4492_test.dart b/tests/web/regress/issue/4492_test.dart
similarity index 100%
rename from tests/web/regress/4492_test.dart
rename to tests/web/regress/issue/4492_test.dart
diff --git a/tests/web/45046_test.dart b/tests/web/regress/issue/45046_test.dart
similarity index 100%
rename from tests/web/45046_test.dart
rename to tests/web/regress/issue/45046_test.dart
diff --git a/tests/web/regress/4515_1_test.dart b/tests/web/regress/issue/4515_1_test.dart
similarity index 100%
rename from tests/web/regress/4515_1_test.dart
rename to tests/web/regress/issue/4515_1_test.dart
diff --git a/tests/web/regress/4515_2_test.dart b/tests/web/regress/issue/4515_2_test.dart
similarity index 100%
rename from tests/web/regress/4515_2_test.dart
rename to tests/web/regress/issue/4515_2_test.dart
diff --git a/tests/web/regress/4515_3_test.dart b/tests/web/regress/issue/4515_3_test.dart
similarity index 100%
rename from tests/web/regress/4515_3_test.dart
rename to tests/web/regress/issue/4515_3_test.dart
diff --git a/tests/web/regress/45413_test.dart b/tests/web/regress/issue/45413_test.dart
similarity index 100%
rename from tests/web/regress/45413_test.dart
rename to tests/web/regress/issue/45413_test.dart
diff --git a/tests/web/regress/45943_test.dart b/tests/web/regress/issue/45943_test.dart
similarity index 100%
rename from tests/web/regress/45943_test.dart
rename to tests/web/regress/issue/45943_test.dart
diff --git a/tests/web/regress/4639_test.dart b/tests/web/regress/issue/4639_test.dart
similarity index 100%
rename from tests/web/regress/4639_test.dart
rename to tests/web/regress/issue/4639_test.dart
diff --git a/tests/web/regress/46417_test.dart b/tests/web/regress/issue/46417_test.dart
similarity index 100%
rename from tests/web/regress/46417_test.dart
rename to tests/web/regress/issue/46417_test.dart
diff --git a/tests/web/regress/46589_test.dart b/tests/web/regress/issue/46589_test.dart
similarity index 100%
rename from tests/web/regress/46589_test.dart
rename to tests/web/regress/issue/46589_test.dart
diff --git a/tests/web/47691_test.dart b/tests/web/regress/issue/47691_test.dart
similarity index 100%
rename from tests/web/47691_test.dart
rename to tests/web/regress/issue/47691_test.dart
diff --git a/tests/web/regress/48317_test.dart b/tests/web/regress/issue/48317_test.dart
similarity index 100%
rename from tests/web/regress/48317_test.dart
rename to tests/web/regress/issue/48317_test.dart
diff --git a/tests/web/48383_test.dart b/tests/web/regress/issue/48383_test.dart
similarity index 100%
rename from tests/web/48383_test.dart
rename to tests/web/regress/issue/48383_test.dart
diff --git a/tests/web/48442_test.dart b/tests/web/regress/issue/48442_test.dart
similarity index 100%
rename from tests/web/48442_test.dart
rename to tests/web/regress/issue/48442_test.dart
diff --git a/tests/web/7_test.dart b/tests/web/regress/issue/7_test.dart
similarity index 100%
rename from tests/web/7_test.dart
rename to tests/web/regress/issue/7_test.dart
diff --git a/tests/web/881_test.dart b/tests/web/regress/issue/881_test.dart
similarity index 100%
rename from tests/web/881_test.dart
rename to tests/web/regress/issue/881_test.dart
diff --git a/tests/web/regress_null_aware_test.dart b/tests/web/regress/null_aware_test.dart
similarity index 100%
rename from tests/web/regress_null_aware_test.dart
rename to tests/web/regress/null_aware_test.dart
diff --git a/tests/web/regress/regression_type_variables_is_test.dart b/tests/web/regress/type_variables_is_test.dart
similarity index 100%
rename from tests/web/regress/regression_type_variables_is_test.dart
rename to tests/web/regress/type_variables_is_test.dart
diff --git a/tests/web/regress/scope_info_field_loop_test.dart b/tests/web/scope_info_field_loop_test.dart
similarity index 100%
rename from tests/web/regress/scope_info_field_loop_test.dart
rename to tests/web/scope_info_field_loop_test.dart
diff --git a/tests/web/regress/unused_generator_type_parameter_test.dart b/tests/web/unused_generator_type_parameter_test.dart
similarity index 100%
rename from tests/web/regress/unused_generator_type_parameter_test.dart
rename to tests/web/unused_generator_type_parameter_test.dart
diff --git a/tests/web_2/regress/if_method_call_test.dart b/tests/web_2/if_method_call_test.dart
similarity index 100%
rename from tests/web_2/regress/if_method_call_test.dart
rename to tests/web_2/if_method_call_test.dart
diff --git a/tests/web_2/10216a_test.dart b/tests/web_2/regress/issue/10216a_test.dart
similarity index 100%
rename from tests/web_2/10216a_test.dart
rename to tests/web_2/regress/issue/10216a_test.dart
diff --git a/tests/web_2/10216b_test.dart b/tests/web_2/regress/issue/10216b_test.dart
similarity index 100%
rename from tests/web_2/10216b_test.dart
rename to tests/web_2/regress/issue/10216b_test.dart
diff --git a/tests/web_2/11673_test.dart b/tests/web_2/regress/issue/11673_test.dart
similarity index 100%
rename from tests/web_2/11673_test.dart
rename to tests/web_2/regress/issue/11673_test.dart
diff --git a/tests/web_2/12320_test.dart b/tests/web_2/regress/issue/12320_test.dart
similarity index 100%
rename from tests/web_2/12320_test.dart
rename to tests/web_2/regress/issue/12320_test.dart
diff --git a/tests/web_2/12_test.dart b/tests/web_2/regress/issue/12_test.dart
similarity index 100%
rename from tests/web_2/12_test.dart
rename to tests/web_2/regress/issue/12_test.dart
diff --git a/tests/web_2/16400_test.dart b/tests/web_2/regress/issue/16400_test.dart
similarity index 100%
rename from tests/web_2/16400_test.dart
rename to tests/web_2/regress/issue/16400_test.dart
diff --git a/tests/web_2/16407_test.dart b/tests/web_2/regress/issue/16407_test.dart
similarity index 100%
rename from tests/web_2/16407_test.dart
rename to tests/web_2/regress/issue/16407_test.dart
diff --git a/tests/web_2/16967_test.dart b/tests/web_2/regress/issue/16967_test.dart
similarity index 100%
rename from tests/web_2/16967_test.dart
rename to tests/web_2/regress/issue/16967_test.dart
diff --git a/tests/web_2/17094_test.dart b/tests/web_2/regress/issue/17094_test.dart
similarity index 100%
rename from tests/web_2/17094_test.dart
rename to tests/web_2/regress/issue/17094_test.dart
diff --git a/tests/web_2/17645_test.dart b/tests/web_2/regress/issue/17645_test.dart
similarity index 100%
rename from tests/web_2/17645_test.dart
rename to tests/web_2/regress/issue/17645_test.dart
diff --git a/tests/web_2/17856_test.dart b/tests/web_2/regress/issue/17856_test.dart
similarity index 100%
rename from tests/web_2/17856_test.dart
rename to tests/web_2/regress/issue/17856_test.dart
diff --git a/tests/web_2/regress/183227419_test.dart b/tests/web_2/regress/issue/183227419_test.dart
similarity index 100%
rename from tests/web_2/regress/183227419_test.dart
rename to tests/web_2/regress/issue/183227419_test.dart
diff --git a/tests/web_2/18383_test.dart b/tests/web_2/regress/issue/18383_test.dart
similarity index 100%
rename from tests/web_2/18383_test.dart
rename to tests/web_2/regress/issue/18383_test.dart
diff --git a/tests/web_2/19191_test.dart b/tests/web_2/regress/issue/19191_test.dart
similarity index 100%
rename from tests/web_2/19191_test.dart
rename to tests/web_2/regress/issue/19191_test.dart
diff --git a/tests/web_2/21351_test.dart b/tests/web_2/regress/issue/21351_test.dart
similarity index 100%
rename from tests/web_2/21351_test.dart
rename to tests/web_2/regress/issue/21351_test.dart
diff --git a/tests/web_2/21579_test.dart b/tests/web_2/regress/issue/21579_test.dart
similarity index 100%
rename from tests/web_2/21579_test.dart
rename to tests/web_2/regress/issue/21579_test.dart
diff --git a/tests/web_2/22487_test.dart b/tests/web_2/regress/issue/22487_test.dart
similarity index 100%
rename from tests/web_2/22487_test.dart
rename to tests/web_2/regress/issue/22487_test.dart
diff --git a/tests/web_2/22776_test.dart b/tests/web_2/regress/issue/22776_test.dart
similarity index 100%
rename from tests/web_2/22776_test.dart
rename to tests/web_2/regress/issue/22776_test.dart
diff --git a/tests/web_2/22868_test.dart b/tests/web_2/regress/issue/22868_test.dart
similarity index 100%
rename from tests/web_2/22868_test.dart
rename to tests/web_2/regress/issue/22868_test.dart
diff --git a/tests/web_2/22917_test.dart b/tests/web_2/regress/issue/22917_test.dart
similarity index 100%
rename from tests/web_2/22917_test.dart
rename to tests/web_2/regress/issue/22917_test.dart
diff --git a/tests/web_2/23404_test.dart b/tests/web_2/regress/issue/23404_test.dart
similarity index 100%
rename from tests/web_2/23404_test.dart
rename to tests/web_2/regress/issue/23404_test.dart
diff --git a/tests/web_2/23432_test.dart b/tests/web_2/regress/issue/23432_test.dart
similarity index 100%
rename from tests/web_2/23432_test.dart
rename to tests/web_2/regress/issue/23432_test.dart
diff --git a/tests/web_2/23486_helper.dart b/tests/web_2/regress/issue/23486_helper.dart
similarity index 100%
rename from tests/web_2/23486_helper.dart
rename to tests/web_2/regress/issue/23486_helper.dart
diff --git a/tests/web_2/23486_test.dart b/tests/web_2/regress/issue/23486_test.dart
similarity index 100%
rename from tests/web_2/23486_test.dart
rename to tests/web_2/regress/issue/23486_test.dart
diff --git a/tests/web_2/23804_test.dart b/tests/web_2/regress/issue/23804_test.dart
similarity index 100%
rename from tests/web_2/23804_test.dart
rename to tests/web_2/regress/issue/23804_test.dart
diff --git a/tests/web_2/23828_test.dart b/tests/web_2/regress/issue/23828_test.dart
similarity index 100%
rename from tests/web_2/23828_test.dart
rename to tests/web_2/regress/issue/23828_test.dart
diff --git a/tests/web_2/26243_test.dart b/tests/web_2/regress/issue/26243_test.dart
similarity index 100%
rename from tests/web_2/26243_test.dart
rename to tests/web_2/regress/issue/26243_test.dart
diff --git a/tests/web_2/27198_test.dart b/tests/web_2/regress/issue/27198_test.dart
similarity index 100%
rename from tests/web_2/27198_test.dart
rename to tests/web_2/regress/issue/27198_test.dart
diff --git a/tests/web_2/27199_test.dart b/tests/web_2/regress/issue/27199_test.dart
similarity index 100%
rename from tests/web_2/27199_test.dart
rename to tests/web_2/regress/issue/27199_test.dart
diff --git a/tests/web_2/27323_test.dart b/tests/web_2/regress/issue/27323_test.dart
similarity index 100%
rename from tests/web_2/27323_test.dart
rename to tests/web_2/regress/issue/27323_test.dart
diff --git a/tests/web_2/27354_test.dart b/tests/web_2/regress/issue/27354_test.dart
similarity index 100%
rename from tests/web_2/27354_test.dart
rename to tests/web_2/regress/issue/27354_test.dart
diff --git a/tests/web_2/28749_test.dart b/tests/web_2/regress/issue/28749_test.dart
similarity index 100%
rename from tests/web_2/28749_test.dart
rename to tests/web_2/regress/issue/28749_test.dart
diff --git a/tests/web_2/28919_test.dart b/tests/web_2/regress/issue/28919_test.dart
similarity index 100%
rename from tests/web_2/28919_test.dart
rename to tests/web_2/regress/issue/28919_test.dart
diff --git a/tests/web_2/29130_test.dart b/tests/web_2/regress/issue/29130_test.dart
similarity index 100%
rename from tests/web_2/29130_test.dart
rename to tests/web_2/regress/issue/29130_test.dart
diff --git a/tests/web_2/regression_2913_test.dart b/tests/web_2/regress/issue/2913_test.dart
similarity index 100%
rename from tests/web_2/regression_2913_test.dart
rename to tests/web_2/regress/issue/2913_test.dart
diff --git a/tests/web_2/31803_test.dart b/tests/web_2/regress/issue/31803_test.dart
similarity index 100%
rename from tests/web_2/31803_test.dart
rename to tests/web_2/regress/issue/31803_test.dart
diff --git a/tests/web_2/regress_32069_test.dart b/tests/web_2/regress/issue/32069_test.dart
similarity index 100%
rename from tests/web_2/regress_32069_test.dart
rename to tests/web_2/regress/issue/32069_test.dart
diff --git a/tests/web_2/32770a_test.dart b/tests/web_2/regress/issue/32770a_test.dart
similarity index 100%
rename from tests/web_2/32770a_test.dart
rename to tests/web_2/regress/issue/32770a_test.dart
diff --git a/tests/web_2/32770b_test.dart b/tests/web_2/regress/issue/32770b_test.dart
similarity index 100%
rename from tests/web_2/32770b_test.dart
rename to tests/web_2/regress/issue/32770b_test.dart
diff --git a/tests/web_2/32770c_test.dart b/tests/web_2/regress/issue/32770c_test.dart
similarity index 100%
rename from tests/web_2/32770c_test.dart
rename to tests/web_2/regress/issue/32770c_test.dart
diff --git a/tests/web_2/32774_test.dart b/tests/web_2/regress/issue/32774_test.dart
similarity index 100%
rename from tests/web_2/32774_test.dart
rename to tests/web_2/regress/issue/32774_test.dart
diff --git a/tests/web_2/32828_test.dart b/tests/web_2/regress/issue/32828_test.dart
similarity index 100%
rename from tests/web_2/32828_test.dart
rename to tests/web_2/regress/issue/32828_test.dart
diff --git a/tests/web_2/32853_test.dart b/tests/web_2/regress/issue/32853_test.dart
similarity index 99%
rename from tests/web_2/32853_test.dart
rename to tests/web_2/regress/issue/32853_test.dart
index f90fb71..80819b3 100644
--- a/tests/web_2/32853_test.dart
+++ b/tests/web_2/regress/issue/32853_test.dart
@@ -8,10 +8,9 @@
// Regression test for issue 32853.
-
int foo<T extends Comparable<T>>(T a, T b) => a.compareTo(b);
main() {
int Function<T extends Comparable<T>>(T, T) f = foo;
print(f<num>(1, 2));
-}
\ No newline at end of file
+}
diff --git a/tests/web_2/32928_test.dart b/tests/web_2/regress/issue/32928_test.dart
similarity index 100%
rename from tests/web_2/32928_test.dart
rename to tests/web_2/regress/issue/32928_test.dart
diff --git a/tests/web_2/32969_test.dart b/tests/web_2/regress/issue/32969_test.dart
similarity index 100%
rename from tests/web_2/32969_test.dart
rename to tests/web_2/regress/issue/32969_test.dart
diff --git a/tests/web_2/32997a_lib.dart b/tests/web_2/regress/issue/32997a_lib.dart
similarity index 100%
rename from tests/web_2/32997a_lib.dart
rename to tests/web_2/regress/issue/32997a_lib.dart
diff --git a/tests/web_2/32997a_test.dart b/tests/web_2/regress/issue/32997a_test.dart
similarity index 100%
rename from tests/web_2/32997a_test.dart
rename to tests/web_2/regress/issue/32997a_test.dart
diff --git a/tests/web_2/32997b_lib.dart b/tests/web_2/regress/issue/32997b_lib.dart
similarity index 100%
rename from tests/web_2/32997b_lib.dart
rename to tests/web_2/regress/issue/32997b_lib.dart
diff --git a/tests/web_2/32997b_test.dart b/tests/web_2/regress/issue/32997b_test.dart
similarity index 100%
rename from tests/web_2/32997b_test.dart
rename to tests/web_2/regress/issue/32997b_test.dart
diff --git a/tests/web_2/33296_test.dart b/tests/web_2/regress/issue/33296_test.dart
similarity index 100%
rename from tests/web_2/33296_test.dart
rename to tests/web_2/regress/issue/33296_test.dart
diff --git a/tests/web_2/33572_test.dart b/tests/web_2/regress/issue/33572_test.dart
similarity index 100%
rename from tests/web_2/33572_test.dart
rename to tests/web_2/regress/issue/33572_test.dart
diff --git a/tests/web_2/33_test.dart b/tests/web_2/regress/issue/33_test.dart
similarity index 100%
rename from tests/web_2/33_test.dart
rename to tests/web_2/regress/issue/33_test.dart
diff --git a/tests/web_2/34156_test.dart b/tests/web_2/regress/issue/34156_test.dart
similarity index 100%
rename from tests/web_2/34156_test.dart
rename to tests/web_2/regress/issue/34156_test.dart
diff --git a/tests/web_2/34701_test.dart b/tests/web_2/regress/issue/34701_test.dart
similarity index 100%
rename from tests/web_2/34701_test.dart
rename to tests/web_2/regress/issue/34701_test.dart
diff --git a/tests/web_2/35341_test.dart b/tests/web_2/regress/issue/35341_test.dart
similarity index 100%
rename from tests/web_2/35341_test.dart
rename to tests/web_2/regress/issue/35341_test.dart
diff --git a/tests/web_2/35356_test.dart b/tests/web_2/regress/issue/35356_test.dart
similarity index 100%
rename from tests/web_2/35356_test.dart
rename to tests/web_2/regress/issue/35356_test.dart
diff --git a/tests/web_2/35853_test.dart b/tests/web_2/regress/issue/35853_test.dart
similarity index 100%
rename from tests/web_2/35853_test.dart
rename to tests/web_2/regress/issue/35853_test.dart
diff --git a/tests/web_2/35965a_test.dart b/tests/web_2/regress/issue/35965a_test.dart
similarity index 100%
rename from tests/web_2/35965a_test.dart
rename to tests/web_2/regress/issue/35965a_test.dart
diff --git a/tests/web_2/regress_36222_test.dart b/tests/web_2/regress/issue/36222_test.dart
similarity index 100%
rename from tests/web_2/regress_36222_test.dart
rename to tests/web_2/regress/issue/36222_test.dart
diff --git a/tests/web_2/37494_test.dart b/tests/web_2/regress/issue/37494_test.dart
similarity index 100%
rename from tests/web_2/37494_test.dart
rename to tests/web_2/regress/issue/37494_test.dart
diff --git a/tests/web_2/37576_test.dart b/tests/web_2/regress/issue/37576_test.dart
similarity index 100%
rename from tests/web_2/37576_test.dart
rename to tests/web_2/regress/issue/37576_test.dart
diff --git a/tests/web_2/38005_test.dart b/tests/web_2/regress/issue/38005_test.dart
similarity index 100%
rename from tests/web_2/38005_test.dart
rename to tests/web_2/regress/issue/38005_test.dart
diff --git a/tests/web_2/38949_test.dart b/tests/web_2/regress/issue/38949_test.dart
similarity index 100%
rename from tests/web_2/38949_test.dart
rename to tests/web_2/regress/issue/38949_test.dart
diff --git a/tests/web_2/3_test.dart b/tests/web_2/regress/issue/3_test.dart
similarity index 100%
rename from tests/web_2/3_test.dart
rename to tests/web_2/regress/issue/3_test.dart
diff --git a/tests/web_2/40152a_test.dart b/tests/web_2/regress/issue/40152a_test.dart
similarity index 100%
rename from tests/web_2/40152a_test.dart
rename to tests/web_2/regress/issue/40152a_test.dart
diff --git a/tests/web_2/regress_40349_test.dart b/tests/web_2/regress/issue/40349_test.dart
similarity index 100%
rename from tests/web_2/regress_40349_test.dart
rename to tests/web_2/regress/issue/40349_test.dart
diff --git a/tests/web_2/40902_test.dart b/tests/web_2/regress/issue/40902_test.dart
similarity index 100%
rename from tests/web_2/40902_test.dart
rename to tests/web_2/regress/issue/40902_test.dart
diff --git a/tests/web_2/41449a_test.dart b/tests/web_2/regress/issue/41449a_test.dart
similarity index 100%
rename from tests/web_2/41449a_test.dart
rename to tests/web_2/regress/issue/41449a_test.dart
diff --git a/tests/web_2/41449b_test.dart b/tests/web_2/regress/issue/41449b_test.dart
similarity index 100%
rename from tests/web_2/41449b_test.dart
rename to tests/web_2/regress/issue/41449b_test.dart
diff --git a/tests/web_2/41449c_test.dart b/tests/web_2/regress/issue/41449c_test.dart
similarity index 100%
rename from tests/web_2/41449c_test.dart
rename to tests/web_2/regress/issue/41449c_test.dart
diff --git a/tests/web_2/41449d_test.dart b/tests/web_2/regress/issue/41449d_test.dart
similarity index 100%
rename from tests/web_2/41449d_test.dart
rename to tests/web_2/regress/issue/41449d_test.dart
diff --git a/tests/web_2/regress/41781_test.dart b/tests/web_2/regress/issue/41781_test.dart
similarity index 100%
rename from tests/web_2/regress/41781_test.dart
rename to tests/web_2/regress/issue/41781_test.dart
diff --git a/tests/web_2/42088_test.dart b/tests/web_2/regress/issue/42088_test.dart
similarity index 100%
rename from tests/web_2/42088_test.dart
rename to tests/web_2/regress/issue/42088_test.dart
diff --git a/tests/web_2/42189_test.dart b/tests/web_2/regress/issue/42189_test.dart
similarity index 100%
rename from tests/web_2/42189_test.dart
rename to tests/web_2/regress/issue/42189_test.dart
diff --git a/tests/web_2/regress_42281_test.dart b/tests/web_2/regress/issue/42281_test.dart
similarity index 100%
rename from tests/web_2/regress_42281_test.dart
rename to tests/web_2/regress/issue/42281_test.dart
diff --git a/tests/web_2/42501_test.dart b/tests/web_2/regress/issue/42501_test.dart
similarity index 100%
rename from tests/web_2/42501_test.dart
rename to tests/web_2/regress/issue/42501_test.dart
diff --git a/tests/web_2/42531_test.dart b/tests/web_2/regress/issue/42531_test.dart
similarity index 100%
rename from tests/web_2/42531_test.dart
rename to tests/web_2/regress/issue/42531_test.dart
diff --git a/tests/web_2/regress/43520_safari_test.dart b/tests/web_2/regress/issue/43520_safari_test.dart
similarity index 100%
rename from tests/web_2/regress/43520_safari_test.dart
rename to tests/web_2/regress/issue/43520_safari_test.dart
diff --git a/tests/web_2/43_test.dart b/tests/web_2/regress/issue/43_test.dart
similarity index 100%
rename from tests/web_2/43_test.dart
rename to tests/web_2/regress/issue/43_test.dart
diff --git a/tests/web_2/regress/4434_lib.dart b/tests/web_2/regress/issue/4434_lib.dart
similarity index 100%
rename from tests/web_2/regress/4434_lib.dart
rename to tests/web_2/regress/issue/4434_lib.dart
diff --git a/tests/web_2/regress/4434_test.dart b/tests/web_2/regress/issue/4434_test.dart
similarity index 100%
rename from tests/web_2/regress/4434_test.dart
rename to tests/web_2/regress/issue/4434_test.dart
diff --git a/tests/web_2/regress/44818_test.dart b/tests/web_2/regress/issue/44818_test.dart
similarity index 100%
rename from tests/web_2/regress/44818_test.dart
rename to tests/web_2/regress/issue/44818_test.dart
diff --git a/tests/web_2/regress/4492_test.dart b/tests/web_2/regress/issue/4492_test.dart
similarity index 100%
rename from tests/web_2/regress/4492_test.dart
rename to tests/web_2/regress/issue/4492_test.dart
diff --git a/tests/web_2/45046_test.dart b/tests/web_2/regress/issue/45046_test.dart
similarity index 100%
rename from tests/web_2/45046_test.dart
rename to tests/web_2/regress/issue/45046_test.dart
diff --git a/tests/web_2/regress/4515_1_test.dart b/tests/web_2/regress/issue/4515_1_test.dart
similarity index 100%
rename from tests/web_2/regress/4515_1_test.dart
rename to tests/web_2/regress/issue/4515_1_test.dart
diff --git a/tests/web_2/regress/4515_2_test.dart b/tests/web_2/regress/issue/4515_2_test.dart
similarity index 100%
rename from tests/web_2/regress/4515_2_test.dart
rename to tests/web_2/regress/issue/4515_2_test.dart
diff --git a/tests/web_2/regress/4515_3_test.dart b/tests/web_2/regress/issue/4515_3_test.dart
similarity index 100%
rename from tests/web_2/regress/4515_3_test.dart
rename to tests/web_2/regress/issue/4515_3_test.dart
diff --git a/tests/web_2/regress/45943_test.dart b/tests/web_2/regress/issue/45943_test.dart
similarity index 100%
rename from tests/web_2/regress/45943_test.dart
rename to tests/web_2/regress/issue/45943_test.dart
diff --git a/tests/web_2/regress/4639_test.dart b/tests/web_2/regress/issue/4639_test.dart
similarity index 100%
rename from tests/web_2/regress/4639_test.dart
rename to tests/web_2/regress/issue/4639_test.dart
diff --git a/tests/web_2/regress/46417_test.dart b/tests/web_2/regress/issue/46417_test.dart
similarity index 100%
rename from tests/web_2/regress/46417_test.dart
rename to tests/web_2/regress/issue/46417_test.dart
diff --git a/tests/web_2/regress/46589_test.dart b/tests/web_2/regress/issue/46589_test.dart
similarity index 100%
rename from tests/web_2/regress/46589_test.dart
rename to tests/web_2/regress/issue/46589_test.dart
diff --git a/tests/web_2/47691_test.dart b/tests/web_2/regress/issue/47691_test.dart
similarity index 100%
rename from tests/web_2/47691_test.dart
rename to tests/web_2/regress/issue/47691_test.dart
diff --git a/tests/web_2/regress/48317_test.dart b/tests/web_2/regress/issue/48317_test.dart
similarity index 100%
rename from tests/web_2/regress/48317_test.dart
rename to tests/web_2/regress/issue/48317_test.dart
diff --git a/tests/web_2/48383_test.dart b/tests/web_2/regress/issue/48383_test.dart
similarity index 100%
rename from tests/web_2/48383_test.dart
rename to tests/web_2/regress/issue/48383_test.dart
diff --git a/tests/web_2/48442_test.dart b/tests/web_2/regress/issue/48442_test.dart
similarity index 100%
rename from tests/web_2/48442_test.dart
rename to tests/web_2/regress/issue/48442_test.dart
diff --git a/tests/web_2/7_test.dart b/tests/web_2/regress/issue/7_test.dart
similarity index 100%
rename from tests/web_2/7_test.dart
rename to tests/web_2/regress/issue/7_test.dart
diff --git a/tests/web_2/881_test.dart b/tests/web_2/regress/issue/881_test.dart
similarity index 100%
rename from tests/web_2/881_test.dart
rename to tests/web_2/regress/issue/881_test.dart
diff --git a/tests/web_2/regress_null_aware_test.dart b/tests/web_2/regress/null_aware_test.dart
similarity index 63%
rename from tests/web_2/regress_null_aware_test.dart
rename to tests/web_2/regress/null_aware_test.dart
index 68cbcdc..2b3e177 100644
--- a/tests/web_2/regress_null_aware_test.dart
+++ b/tests/web_2/regress/null_aware_test.dart
@@ -9,15 +9,9 @@
class Class {
Map<String, Set<String>> map;
- List<String> method(String node, Set<String> set) =>
- set.add(node)
- ? [
- node,
- ...?map[node]
- ?.expand((node) => method(node, set))
- ?.toList()
- ]
- : [];
+ List<String> method(String node, Set<String> set) => set.add(node)
+ ? [node, ...?map[node]?.expand((node) => method(node, set))?.toList()]
+ : [];
}
main(args) {
diff --git a/tests/web_2/regress/regression_type_variables_is_test.dart b/tests/web_2/regress/type_variables_is_test.dart
similarity index 100%
rename from tests/web_2/regress/regression_type_variables_is_test.dart
rename to tests/web_2/regress/type_variables_is_test.dart
diff --git a/tests/web_2/regress/scope_info_field_loop_test.dart b/tests/web_2/scope_info_field_loop_test.dart
similarity index 100%
rename from tests/web_2/regress/scope_info_field_loop_test.dart
rename to tests/web_2/scope_info_field_loop_test.dart
diff --git a/tests/web_2/regress/unused_generator_type_parameter_test.dart b/tests/web_2/unused_generator_type_parameter_test.dart
similarity index 100%
rename from tests/web_2/regress/unused_generator_type_parameter_test.dart
rename to tests/web_2/unused_generator_type_parameter_test.dart
diff --git a/tools/VERSION b/tools/VERSION
index d7d6b9c..7047fbf 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 195
+PRERELEASE 196
PRERELEASE_PATCH 0
\ No newline at end of file