Version 2.18.0-32.0.dev
Merge commit 'da89828077c176761193641509ab54015bc046cf' into 'dev'
diff --git a/DEPS b/DEPS
index f6dfe398..0416bb7 100644
--- a/DEPS
+++ b/DEPS
@@ -82,53 +82,51 @@
"benchmark_harness_rev": "c546dbd9f639f75cd2f75de8df2eb9f8ea15e8e7",
"boolean_selector_rev": "437e7f06c7e416bed91e16ae1df453555897e945",
"boringssl_gen_rev": "ced85ef0a00bbca77ce5a91261a5f2ae61b1e62f",
- "boringssl_rev" : "87f316d7748268eb56f2dc147bd593254ae93198",
+ "boringssl_rev": "87f316d7748268eb56f2dc147bd593254ae93198",
"browser-compat-data_tag": "ac8cae697014da1ff7124fba33b0b4245cc6cd1b", # v1.0.22
"browser_launcher_rev": "c6cc1025d6901926cf022e144ba109677e3548f1",
"characters_rev": "6ec389c4dfa8fce14820dc5cbf6e693202e7e052",
"charcode_rev": "84ea427711e24abf3b832923959caa7dd9a8514b",
- "chrome_rev" : "19997",
- "cli_util_rev" : "b0adbba89442b2ea6fef39c7a82fe79cb31e1168",
- "clock_rev" : "5631a0612f4ac7e1b32f7c9a00fc7c00a41615e1",
+ "chrome_rev": "19997",
+ "cli_util_rev": "b0adbba89442b2ea6fef39c7a82fe79cb31e1168",
+ "clock_rev": "5631a0612f4ac7e1b32f7c9a00fc7c00a41615e1",
"collection_rev": "e1407da23b9f17400b3a905aafe2b8fa10db3d86",
"convert_rev": "e063fdca4bebffecbb5e6aa5525995120982d9ce",
- "crypto_rev": "3bae7168183264bb47e7ef576d3881a2f572f89c",
+ "crypto_rev": "4297d240b0e1e780ec0a9eab23eaf1ad491f3e68",
"csslib_rev": "518761b166974537f334dbf264e7f56cb157a96a",
# Note: Updates to dart_style have to be coordinated with the infrastructure
# team so that the internal formatter `tools/sdks/dart-sdk/bin/dart format`
- # matches the version here.
+ # matches the version here. Please follow this process to make updates:
#
- # Please follow this process to make updates:
+ # * Create a commit that updates the version here to the desired version and
+ # adds any appropriate CHANGELOG text.
+ # * Send that to eng-prod to review. They will update the checked-in SDK
+ # and land the review.
#
- # * Create a commit that updates the version here to the desired version and
- # adds any appropriate CHANGELOG text.
- # * Send that to eng-prod to review. They will update the checked-in SDK
- # and land the review.
- #
- # For more details, see https://github.com/dart-lang/sdk/issues/30164
+ # For more details, see https://github.com/dart-lang/sdk/issues/30164.
"dart_style_rev": "d7b73536a8079331c888b7da539b80e6825270ea",
- "dartdoc_rev" : "334072b0cad436c05f6bcecf8a1a59f2f0809b84",
- "devtools_rev" : "8c525828ba33029ed664bf8ea2829b6e5370535f",
+ "dartdoc_rev": "334072b0cad436c05f6bcecf8a1a59f2f0809b84",
+ "devtools_rev": "8c525828ba33029ed664bf8ea2829b6e5370535f",
"ffi_rev": "4dd32429880a57b64edaf54c9d5af8a9fa9a4ffb",
- "fixnum_rev": "848341f061359ef7ddc0cad472c2ecbb036b28ac",
"file_rev": "1ebc38852ffed24b564910317982298b56c2cedd",
+ "fixnum_rev": "848341f061359ef7ddc0cad472c2ecbb036b28ac",
"glob_rev": "da1f4595ee2f87982cbcc663d4cac244822d9227",
"html_rev": "f108bce59d136c584969fd24a5006914796cf213",
"http_io_rev": "2fa188caf7937e313026557713f7feffedd4978b",
"http_multi_server_rev": "34bf7f04b61cce561f47f7f275c2cc811534a05a",
"http_parser_rev": "202391286ddc13c4c3c284ac5b511f04697250ed",
- "http_rev": "a645b938f766d6c9f48724ee55d40e1b394bfae4",
- "icu_rev" : "81d656878ec611cb0b42d52c82e9dae93920d9ba",
- "intl_tag": "9669926609e7efc17dfd74fbb44ec719a7e573cc", # 0.17.0-nullsafety
+ "http_rev": "2c9b418f5086f999c150d18172d2eec1f963de7b",
+ "icu_rev": "81d656878ec611cb0b42d52c82e9dae93920d9ba",
+ "intl_rev": "9669926609e7efc17dfd74fbb44ec719a7e573cc",
"jinja2_rev": "2222b31554f03e62600cd7e383376a7c187967a1",
"json_rpc_2_rev": "7e00f893440a72de0637970325e4ea44bd1e8c8e",
- "linter_tag": "14c916a16e78315e212cf79e7ccf4c19159a1bda", # 1.22.0
- "lints_tag": "8294e5648ab49474541527e2911e72e4c5aefe55", #2.0.0
+ "linter_rev": "14c916a16e78315e212cf79e7ccf4c19159a1bda",
+ "lints_rev": "8294e5648ab49474541527e2911e72e4c5aefe55",
"logging_rev": "dfbe88b890c3b4f7bc06da5a7b3b43e9e263b688",
- "markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
"markdown_rev": "7479783f0493f6717e1d7ae31cb37d39a91026b2",
+ "markupsafe_rev": "8f45f5cfa0009d2a70589bcda0349b8cb2b72783",
"matcher_rev": "07595a7739d47a8315caba5a8e58fb9ae3d81261",
"mime_rev": "c2c5ffd594674f32dc277521369da1557a1622d3",
"mockito_rev": "1e977a727e82a2e1bdb49b79ef1dce0f23aa1faa",
@@ -145,10 +143,10 @@
"pub_semver_rev": "ea6c54019948dc03042c595ce9413e17aaf7aa38",
"root_certificates_rev": "692f6d6488af68e0121317a9c2c9eb393eb0ee50",
"rust_revision": "b7856f695d65a8ebc846754f97d15814bcb1c244",
- "shelf_static_rev": "202ec1a53c9a830c17cf3b718d089cf7eba568ad",
"shelf_packages_handler_rev": "78302e67c035047e6348e692b0c1182131f0fe35",
- "shelf_proxy_tag": "ccd311f64d8689e7a145d703ba267975d6df9e28", # 1.0.0
+ "shelf_proxy_rev": "ccd311f64d8689e7a145d703ba267975d6df9e28",
"shelf_rev": "78ac724a7944700340a3cef28c84bccbe62e9367",
+ "shelf_static_rev": "202ec1a53c9a830c17cf3b718d089cf7eba568ad",
"shelf_web_socket_rev": "24fb8a04befa75a94ac63a27047b231d1a22aab4",
"source_map_stack_trace_rev": "8eabd96b1811e30a11d3c54c9b4afae4fb72e98f",
"source_maps_rev": "c07a01b8d5547ce3a47ee7a7a2b938a2bc09afe3",
@@ -158,24 +156,26 @@
"stream_channel_rev": "3fa3e40c75c210d617b8b943b9b8f580e9866a89",
"string_scanner_rev": "0e53bf9059e8e22a3b346aac7ec755a0f8314eb6",
"sync_http_rev": "b59c134f2e34d12acac110d4f17f83e5a7db4330",
+ "term_glyph_rev": "4885b7f8af6931e23d3aa6d1767ee3f9a626923d",
"test_descriptor_rev": "ead23c1e7df079ac0f6457a35f7a71432892e527",
"test_process_rev": "7c73ec8a8a6e0e63d0ec27d70c21ca4323fb5e8f",
- "term_glyph_rev": "4885b7f8af6931e23d3aa6d1767ee3f9a626923d",
"test_reflective_loader_rev": "fcfce37666672edac849d2af6dffc0f8df236a94",
"test_rev": "b6aba5544628730b7d6a38eae1aef9117a1bb235",
"typed_data_rev": "29ce5a92b03326d0b8035916ac04f528874994bd",
"usage_rev": "e85d575d6decb921c57a43b9844bba3607479f56",
"vector_math_rev": "0cbed0914d49a6a44555e6d5444c438a4a4c3fc1",
"watcher_rev": "f76997ab0c857dc5537ac0975a9ada92b54ef949",
- "webdriver_rev": "ff5ccb1522edf4bed578ead4d65e0cbc1f2c4f02",
"web_components_rev": "8f57dac273412a7172c8ade6f361b407e2e4ed02",
"web_socket_channel_rev": "99dbdc5769e19b9eeaf69449a59079153c6a8b1f",
"WebCore_rev": "bcb10901266c884e7b3740abc597ab95373ab55c",
"webdev_rev": "832b096c0c24798d3df46faa7b7661fe930573c2",
+ "webdriver_rev": "ff5ccb1522edf4bed578ead4d65e0cbc1f2c4f02",
"webkit_inspection_protocol_rev": "dd6fb5d8b536e19cedb384d0bbf1f5631923f1e8",
"yaml_edit_rev": "4fadb43801b07f90b3f0c6065dbce4efc6d8d55e",
"yaml_rev": "ad0779d1baa25c6b10a192d080efc45de02b6a32",
"zlib_rev": "faff052b6b6edcd6dd548513fe44ac0941427bf0",
+
+ # Windows deps
"crashpad_rev": "bf327d8ceb6a669607b0dbab5a83a275d03f99ed",
"minichromium_rev": "8d641e30a8b12088649606b912c2bc4947419ccc",
"googletest_rev": "f854f1d27488996dc8a6db3c9453f80b02585e12",
@@ -297,9 +297,6 @@
Var('chromium_git') + '/external/github.com/mdn/browser-compat-data' +
"@" + Var("browser-compat-data_tag"),
- Var("dart_root") + "/third_party/pkg/browser_launcher":
- Var("dart_git") + "browser_launcher.git" + "@" + Var("browser_launcher_rev"),
-
Var("dart_root") + "/third_party/tcmalloc/gperftools":
Var('chromium_git') + '/external/github.com/gperftools/gperftools.git' +
"@" + Var("gperftools_revision"),
@@ -316,6 +313,8 @@
Var("dart_root") + "/third_party/pkg/boolean_selector":
Var("dart_git") + "boolean_selector.git" +
"@" + Var("boolean_selector_rev"),
+ Var("dart_root") + "/third_party/pkg/browser_launcher":
+ Var("dart_git") + "browser_launcher.git" + "@" + Var("browser_launcher_rev"),
Var("dart_root") + "/third_party/pkg/characters":
Var("dart_git") + "characters.git" + "@" + Var("characters_rev"),
Var("dart_root") + "/third_party/pkg/charcode":
@@ -341,7 +340,7 @@
Var("dart_root") + "/third_party/pkg/fixnum":
Var("dart_git") + "fixnum.git" + "@" + Var("fixnum_rev"),
Var("dart_root") + "/third_party/pkg/file":
- Var("dart_git") + "external/github.com/google/file.dart/"
+ Var("dart_git") + "external/github.com/google/file.dart"
+ "@" + Var("file_rev"),
Var("dart_root") + "/third_party/pkg/glob":
Var("dart_git") + "glob.git" + "@" + Var("glob_rev"),
@@ -357,13 +356,13 @@
Var("dart_root") + "/third_party/pkg/http_parser":
Var("dart_git") + "http_parser.git" + "@" + Var("http_parser_rev"),
Var("dart_root") + "/third_party/pkg/intl":
- Var("dart_git") + "intl.git" + "@" + Var("intl_tag"),
+ Var("dart_git") + "intl.git" + "@" + Var("intl_rev"),
Var("dart_root") + "/third_party/pkg/json_rpc_2":
Var("dart_git") + "json_rpc_2.git" + "@" + Var("json_rpc_2_rev"),
Var("dart_root") + "/third_party/pkg/linter":
- Var("dart_git") + "linter.git" + "@" + Var("linter_tag"),
+ Var("dart_git") + "linter.git" + "@" + Var("linter_rev"),
Var("dart_root") + "/third_party/pkg/lints":
- Var("dart_git") + "lints.git" + "@" + Var("lints_tag"),
+ Var("dart_git") + "lints.git" + "@" + Var("lints_rev"),
Var("dart_root") + "/third_party/pkg/logging":
Var("dart_git") + "logging.git" + "@" + Var("logging_rev"),
Var("dart_root") + "/third_party/pkg/markdown":
@@ -401,7 +400,7 @@
Var("dart_git") + "shelf_packages_handler.git"
+ "@" + Var("shelf_packages_handler_rev"),
Var("dart_root") + "/third_party/pkg/shelf_proxy":
- Var("dart_git") + "shelf_proxy.git" + "@" + Var("shelf_proxy_tag"),
+ Var("dart_git") + "shelf_proxy.git" + "@" + Var("shelf_proxy_rev"),
Var("dart_root") + "/third_party/pkg/shelf_static":
Var("dart_git") + "shelf_static.git" + "@" + Var("shelf_static_rev"),
Var("dart_root") + "/third_party/pkg/shelf_web_socket":
diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart
index caaf66b..5c7458c 100644
--- a/pkg/analysis_server/lib/src/domain_analysis.dart
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/protocol/protocol_constants.dart';
-import 'package:analysis_server/src/analysis_server.dart';
import 'package:analysis_server/src/domain_abstract.dart';
import 'package:analysis_server/src/handler/legacy/analysis_get_errors.dart';
import 'package:analysis_server/src/handler/legacy/analysis_get_hover.dart';
@@ -15,10 +14,10 @@
import 'package:analysis_server/src/handler/legacy/analysis_set_general_subscriptions.dart';
import 'package:analysis_server/src/handler/legacy/analysis_set_priority_files.dart';
import 'package:analysis_server/src/handler/legacy/analysis_set_subscriptions.dart';
+import 'package:analysis_server/src/handler/legacy/analysis_update_content.dart';
+import 'package:analysis_server/src/handler/legacy/analysis_update_options.dart';
import 'package:analysis_server/src/handler/legacy/unsupported_request.dart';
-import 'package:analysis_server/src/plugin/request_converter.dart';
import 'package:analysis_server/src/protocol_server.dart';
-import 'package:analyzer/src/generated/engine.dart' as engine;
import 'package:analyzer/src/utilities/cancellation.dart';
/// Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
@@ -78,62 +77,17 @@
.handle();
return Response.DELAYED_RESPONSE;
} else if (requestName == ANALYSIS_REQUEST_UPDATE_CONTENT) {
- // TODO(brianwilkerson) Converting this to a handler currently causes a
- // test to timeout.
- return updateContent(request);
+ AnalysisUpdateContentHandler(server, request, cancellationToken)
+ .handle();
+ return Response.DELAYED_RESPONSE;
} else if (requestName == ANALYSIS_REQUEST_UPDATE_OPTIONS) {
- // TODO(brianwilkerson) Converting this to a handler currently causes a
- // test to timeout.
- return updateOptions(request);
+ AnalysisUpdateOptionsHandler(server, request, cancellationToken)
+ .handle();
+ return Response.DELAYED_RESPONSE;
}
} on RequestFailure catch (exception) {
return exception.response;
}
return null;
}
-
- /// Implement the 'analysis.updateContent' request.
- Response updateContent(Request request) {
- var params = AnalysisUpdateContentParams.fromRequest(request);
-
- for (var file in params.files.keys) {
- if (!server.isAbsoluteAndNormalized(file)) {
- return Response.invalidFilePathFormat(request, file);
- }
- }
-
- server.updateContent(request.id, params.files);
- //
- // Forward the request to the plugins.
- //
- var converter = RequestConverter();
- server.pluginManager.setAnalysisUpdateContentParams(
- converter.convertAnalysisUpdateContentParams(params));
- //
- // Send the response.
- //
- return AnalysisUpdateContentResult().toResponse(request.id);
- }
-
- /// Implement the 'analysis.updateOptions' request.
- Response updateOptions(Request request) {
- // options
- var params = AnalysisUpdateOptionsParams.fromRequest(request);
- var newOptions = params.options;
- var updaters = <OptionUpdater>[];
- var generateHints = newOptions.generateHints;
- if (generateHints != null) {
- updaters.add((engine.AnalysisOptionsImpl options) {
- options.hint = generateHints;
- });
- }
- var generateLints = newOptions.generateLints;
- if (generateLints != null) {
- updaters.add((engine.AnalysisOptionsImpl options) {
- options.lint = generateLints;
- });
- }
- server.updateOptions(updaters);
- return AnalysisUpdateOptionsResult().toResponse(request.id);
- }
}
diff --git a/pkg/analysis_server/lib/src/handler/legacy/analysis_update_content.dart b/pkg/analysis_server/lib/src/handler/legacy/analysis_update_content.dart
new file mode 100644
index 0000000..b2852185
--- /dev/null
+++ b/pkg/analysis_server/lib/src/handler/legacy/analysis_update_content.dart
@@ -0,0 +1,41 @@
+// 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:analysis_server/protocol/protocol.dart';
+import 'package:analysis_server/protocol/protocol_generated.dart';
+import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
+import 'package:analysis_server/src/plugin/request_converter.dart';
+
+/// The handler for the `analysis.updateContent` request.
+class AnalysisUpdateContentHandler extends LegacyHandler {
+ /// Initialize a newly created handler to be able to service requests for the
+ /// [server].
+ AnalysisUpdateContentHandler(
+ super.server, super.request, super.cancellationToken);
+
+ @override
+ Future<void> handle() async {
+ var params = AnalysisUpdateContentParams.fromRequest(request);
+
+ for (var file in params.files.keys) {
+ if (!server.isAbsoluteAndNormalized(file)) {
+ sendResponse(Response.invalidFilePathFormat(request, file));
+ }
+ }
+
+ server.updateContent(request.id, params.files);
+ //
+ // Forward the request to the plugins.
+ //
+ var converter = RequestConverter();
+ server.pluginManager.setAnalysisUpdateContentParams(
+ converter.convertAnalysisUpdateContentParams(params));
+ //
+ // Send the response.
+ //
+ sendResult(AnalysisUpdateContentResult());
+ }
+}
diff --git a/pkg/analysis_server/lib/src/handler/legacy/analysis_update_options.dart b/pkg/analysis_server/lib/src/handler/legacy/analysis_update_options.dart
new file mode 100644
index 0000000..707cfbd
--- /dev/null
+++ b/pkg/analysis_server/lib/src/handler/legacy/analysis_update_options.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 'dart:async';
+
+import 'package:analysis_server/protocol/protocol_generated.dart';
+import 'package:analysis_server/src/analysis_server.dart';
+import 'package:analysis_server/src/handler/legacy/legacy_handler.dart';
+import 'package:analyzer/src/generated/engine.dart' as engine;
+
+/// The handler for the `analysis.updateOptions` request.
+class AnalysisUpdateOptionsHandler extends LegacyHandler {
+ /// Initialize a newly created handler to be able to service requests for the
+ /// [server].
+ AnalysisUpdateOptionsHandler(
+ super.server, super.request, super.cancellationToken);
+
+ @override
+ Future<void> handle() async {
+ // options
+ var params = AnalysisUpdateOptionsParams.fromRequest(request);
+ var newOptions = params.options;
+ var updaters = <OptionUpdater>[];
+ var generateHints = newOptions.generateHints;
+ if (generateHints != null) {
+ updaters.add((engine.AnalysisOptionsImpl options) {
+ options.hint = generateHints;
+ });
+ }
+ var generateLints = newOptions.generateLints;
+ if (generateLints != null) {
+ updaters.add((engine.AnalysisOptionsImpl options) {
+ options.lint = generateLints;
+ });
+ }
+ server.updateOptions(updaters);
+ sendResult(AnalysisUpdateOptionsResult());
+ }
+}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_initializing_formal.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_initializing_formal.dart
index 4cc61ae..5cf8e0f 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_initializing_formal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_initializing_formal.dart
@@ -35,21 +35,25 @@
if (block is! Block) {
return;
}
- var right = node.rightHandSide;
- if (right is! SimpleIdentifier) {
+ var parameter = _parameter(constructor, node.rightHandSide);
+ if (parameter == null) {
return;
}
- var parameterElement = right.staticElement;
- var parameter = _parameterForElement(constructor, parameterElement);
- if (parameter is! SimpleFormalParameter) {
+ var identifier = parameter.identifier;
+ if (identifier == null) {
return;
}
- var name = parameter.identifier?.name;
- if (name == null) {
- return;
- }
+
+ var preserveType = parameter.type?.type != node.writeType;
+
await builder.addDartFileEdit(file, (builder) {
- builder.addSimpleReplacement(range.node(parameter), 'this.$name');
+ if (preserveType) {
+ builder.addSimpleInsertion(identifier.offset, 'this.');
+ } else {
+ builder.addSimpleReplacement(
+ range.node(parameter), 'this.${identifier.name}');
+ }
+
var statements = block.statements;
var functionBody = block.parent;
if (statements.length == 1 && functionBody is BlockFunctionBody) {
@@ -60,21 +64,30 @@
}
});
} else if (node is ConstructorFieldInitializer) {
- var right = node.expression;
- if (right is! SimpleIdentifier) {
+ var parameter = _parameter(constructor, node.expression);
+ if (parameter == null) {
return;
}
- var parameterElement = right.staticElement;
- var parameter = _parameterForElement(constructor, parameterElement);
- if (parameter is! SimpleFormalParameter) {
+ var identifier = parameter.identifier;
+ if (identifier == null) {
return;
}
- var name = parameter.identifier?.name;
- if (name == null) {
+
+ var fieldElement = node.fieldName.staticElement;
+ if (fieldElement is! VariableElement) {
return;
}
+
+ var preserveType = parameter.type?.type != fieldElement.type;
+
await builder.addDartFileEdit(file, (builder) {
- builder.addSimpleReplacement(range.node(parameter), 'this.$name');
+ if (preserveType) {
+ builder.addSimpleInsertion(identifier.offset, 'this.');
+ } else {
+ builder.addSimpleReplacement(
+ range.node(parameter), 'this.${identifier.name}');
+ }
+
var initializers = constructor.initializers;
if (initializers.length == 1) {
builder.addDeletion(range.endEnd(constructor.parameters, node));
@@ -85,11 +98,15 @@
}
}
- FormalParameter? _parameterForElement(
- ConstructorDeclaration constructor, Element? parameterElement) {
+ SimpleFormalParameter? _parameter(
+ ConstructorDeclaration constructor, Expression expression) {
+ if (expression is! SimpleIdentifier) {
+ return null;
+ }
+ var parameterElement = expression.staticElement;
for (var parameter in constructor.parameters.parameters) {
if (parameter.declaredElement == parameterElement) {
- return parameter;
+ return parameter is SimpleFormalParameter ? parameter : null;
}
}
return null;
diff --git a/pkg/analysis_server/test/edit/bulk_fixes_test.dart b/pkg/analysis_server/test/edit/bulk_fixes_test.dart
index b728b9b..cc90c1f 100644
--- a/pkg/analysis_server/test/edit/bulk_fixes_test.dart
+++ b/pkg/analysis_server/test/edit/bulk_fixes_test.dart
@@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:io' show Platform;
-
import 'package:analysis_server/protocol/protocol_generated.dart';
import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:analyzer/file_system/file_system.dart';
@@ -201,9 +199,6 @@
// The test case currently drops the 'new' but does not convert the code to
// use a set literal. The code is no longer mangled, but we need to run the
// BulkFixProcessor iteratively to solve the second case.
- if (Platform.isWindows) {
- fail('Should not be passing on Windows, but it does');
- }
newAnalysisOptionsYamlFile2(testPackageRootPath, '''
linter:
rules:
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_initializing_formal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_initializing_formal_test.dart
index 8270691..e082d34 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_initializing_formal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_initializing_formal_test.dart
@@ -23,6 +23,25 @@
@override
String get lintCode => LintNames.prefer_initializing_formals;
+ Future<void> test_assignment_different_type() async {
+ await resolveTestCode('''
+class C {
+ Object a = '';
+
+ C(String a) {
+ this.a = a;
+ }
+}
+''');
+ await assertHasFix('''
+class C {
+ Object a = '';
+
+ C(String this.a);
+}
+''');
+ }
+
Future<void> test_assignment_emptyAfterRemoval() async {
await resolveTestCode('''
class C {
@@ -60,6 +79,21 @@
''');
}
+ Future<void> test_initializer_different_type() async {
+ await resolveTestCode('''
+class C {
+ final Object name;
+ C.forName(String name) : name = name;
+}
+''');
+ await assertHasFix('''
+class C {
+ final Object name;
+ C.forName(String this.name);
+}
+''');
+ }
+
Future<void> test_initializer_emptyAfterRemoval() async {
await resolveTestCode('''
class C {
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index f8e2426..2815dbc 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -130,6 +130,12 @@
return name == 'Enum' && library.isDartCore;
}
+ /// Return `true` if this class represents the class '_Enum' defined in the
+ /// dart:core library.
+ bool get isDartCoreEnumImpl {
+ return name == '_Enum' && library.isDartCore;
+ }
+
@override
bool get isDartCoreObject => false;
diff --git a/pkg/analyzer/lib/src/error/inheritance_override.dart b/pkg/analyzer/lib/src/error/inheritance_override.dart
index 0e38986..5d239db 100644
--- a/pkg/analyzer/lib/src/error/inheritance_override.dart
+++ b/pkg/analyzer/lib/src/error/inheritance_override.dart
@@ -118,7 +118,7 @@
final List<InterfaceType> directSuperInterfaces = [];
- late final implementsDartCoreEnum =
+ late final bool implementsDartCoreEnum =
classElement.allSupertypes.any((e) => e.isDartCoreEnum);
_ClassVerifier({
@@ -648,6 +648,7 @@
void _checkIllegalConcreteEnumMemberDeclaration(SimpleIdentifier name) {
if (implementsDartCoreEnum &&
+ !classElement.isDartCoreEnumImpl &&
const {'index', 'hashCode', '=='}.contains(name.name)) {
reporter.reportErrorForNode(
CompileTimeErrorCode.ILLEGAL_CONCRETE_ENUM_MEMBER_DECLARATION,
diff --git a/pkg/analyzer/lib/src/summary2/macro_application.dart b/pkg/analyzer/lib/src/summary2/macro_application.dart
index 847d5be..7d8f2ba 100644
--- a/pkg/analyzer/lib/src/summary2/macro_application.dart
+++ b/pkg/analyzer/lib/src/summary2/macro_application.dart
@@ -201,7 +201,9 @@
}
static Object? _evaluateArgument(Expression node) {
- if (node is BooleanLiteral) {
+ if (node is AdjacentStrings) {
+ return node.strings.map(_evaluateArgument).join('');
+ } else if (node is BooleanLiteral) {
return node.value;
} else if (node is DoubleLiteral) {
return node.value;
diff --git a/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart b/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart
new file mode 100644
index 0000000..d80cb61
--- /dev/null
+++ b/pkg/analyzer/test/src/diagnostics/mock_sdk_test.dart
@@ -0,0 +1,60 @@
+// 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:analyzer/dart/analysis/results.dart';
+import 'package:analyzer/error/error.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../dart/resolution/context_collection_resolution.dart';
+
+main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(MockSdkTest);
+ });
+}
+
+@reflectiveTest
+class MockSdkTest extends PubPackageResolutionTest {
+ test_dart_async() async {
+ await _assertOnlyHintsInLibraryUri('dart:async');
+ }
+
+ test_dart_convert() async {
+ await _assertOnlyHintsInLibraryUri('dart:convert');
+ }
+
+ test_dart_core() async {
+ await _assertOnlyHintsInLibraryUri('dart:core');
+ }
+
+ test_dart_math() async {
+ await _assertOnlyHintsInLibraryUri('dart:math');
+ }
+
+ void _assertOnlyHintsInLibrary(ResolvedLibraryResult coreResolvedResult) {
+ for (var resolvedUnit in coreResolvedResult.units) {
+ _assertOnlyHintsInUnit(resolvedUnit);
+ }
+ }
+
+ Future<void> _assertOnlyHintsInLibraryUri(String uriStr) async {
+ var coreResolvedResult = await _resolvedLibraryByUri(uriStr);
+ _assertOnlyHintsInLibrary(coreResolvedResult);
+ }
+
+ void _assertOnlyHintsInUnit(ResolvedUnitResult resolvedUnit) {
+ var notHints = resolvedUnit.errors
+ .where((element) => element.errorCode.type != ErrorType.HINT)
+ .toList();
+ assertErrorsInList(notHints, []);
+ }
+
+ Future<ResolvedLibraryResult> _resolvedLibraryByUri(String uriStr) async {
+ var analysisSession = contextFor(testFilePath).currentSession;
+ var coreElementResult =
+ await analysisSession.getLibraryByUri(uriStr) as LibraryElementResult;
+ return await analysisSession.getResolvedLibraryByElement(
+ coreElementResult.element) as ResolvedLibraryResult;
+ }
+}
diff --git a/pkg/analyzer/test/src/diagnostics/test_all.dart b/pkg/analyzer/test/src/diagnostics/test_all.dart
index 4e8864f..1a9a39d 100644
--- a/pkg/analyzer/test/src/diagnostics/test_all.dart
+++ b/pkg/analyzer/test/src/diagnostics/test_all.dart
@@ -476,6 +476,7 @@
import 'mixin_with_non_class_superclass_test.dart'
as mixin_with_non_class_superclass;
import 'mixins_super_class_test.dart' as mixins_super_class;
+import 'mock_sdk_test.dart' as mock_sdk;
import 'multiple_redirecting_constructor_invocations_test.dart'
as multiple_redirecting_constructor_invocations;
import 'multiple_super_initializers_test.dart' as multiple_super_initializers;
@@ -1105,6 +1106,7 @@
mixin_super_class_constraint_non_interface.main();
mixin_with_non_class_superclass.main();
mixins_super_class.main();
+ mock_sdk.main();
multiple_redirecting_constructor_invocations.main();
multiple_super_initializers.main();
must_be_a_native_function_type.main();
diff --git a/pkg/analyzer/test/src/summary/macro_test.dart b/pkg/analyzer/test/src/summary/macro_test.dart
index 36592d2..cfde4cd 100644
--- a/pkg/analyzer/test/src/summary/macro_test.dart
+++ b/pkg/analyzer/test/src/summary/macro_test.dart
@@ -234,6 +234,17 @@
);
}
+ test_arguments_typesPhase_type_string_adjacent() async {
+ await _assertTypesPhaseArgumentsText(
+ fields: {'foo': 'String'},
+ constructorParametersCode: '(this.foo)',
+ argumentsCode: "('aaa' 'bbb' 'ccc')",
+ expected: r'''
+foo: aaabbbccc
+''',
+ );
+ }
+
test_build_types() async {
newFile2('$testPackageLibPath/a.dart', r'''
import 'dart:async';
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index fdda1c8..fc65993 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -26,7 +26,7 @@
show ConstraintData;
import 'deferred_load/program_split_constraints/parser.dart' as psc show Parser;
import 'diagnostics/messages.dart' show Message;
-import 'dump_info.dart' show DumpInfoTask;
+import 'dump_info.dart' show DumpInfoStateData, DumpInfoTask;
import 'elements/entities.dart';
import 'enqueue.dart' show Enqueuer;
import 'environment.dart';
@@ -93,6 +93,7 @@
DataSourceIndices closedWorldIndicesForTesting;
ResolutionEnqueuer resolutionEnqueuerForTesting;
CodegenEnqueuer codegenEnqueuerForTesting;
+ DumpInfoStateData dumpInfoStateForTesting;
ir.Component untrimmedComponentForDumpInfo;
@@ -660,13 +661,18 @@
codegenResults.globalTypeInferenceResults;
JClosedWorld closedWorld = globalTypeInferenceResults.closedWorld;
+ DumpInfoStateData dumpInfoState;
dumpInfoTask.reportSize(programSize);
if (options.features.newDumpInfo.isEnabled) {
assert(untrimmedComponentForDumpInfo != null);
- dumpInfoTask.dumpInfoNew(untrimmedComponentForDumpInfo, closedWorld,
- globalTypeInferenceResults);
+ dumpInfoState = dumpInfoTask.dumpInfoNew(untrimmedComponentForDumpInfo,
+ closedWorld, globalTypeInferenceResults);
} else {
- dumpInfoTask.dumpInfo(closedWorld, globalTypeInferenceResults);
+ dumpInfoState =
+ dumpInfoTask.dumpInfo(closedWorld, globalTypeInferenceResults);
+ }
+ if (retainDataForTesting) {
+ dumpInfoStateForTesting = dumpInfoState;
}
}
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index 10b0b88..2f6b2bd 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -41,10 +41,7 @@
JElementEnvironment get environment => closedWorld.elementEnvironment;
- final AllInfo result = AllInfo();
- final Map<Entity, Info> _entityToInfo = <Entity, Info>{};
- final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{};
- final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {};
+ final state = DumpInfoStateData();
ElementInfoCollector(this.compiler, this.dumpInfoTask, this.closedWorld,
this._globalInferenceResults);
@@ -57,8 +54,8 @@
size: span.end - span.start,
code: [span],
outputUnit: _unitInfoForConstant(constant));
- _constantToInfo[constant] = info;
- result.constants.add(info);
+ state.constantToInfo[constant] = info;
+ state.info.constants.add(info);
});
environment.libraries.forEach(visitLibrary);
}
@@ -80,7 +77,7 @@
}
int size = dumpInfoTask.sizeOf(lib);
LibraryInfo info = LibraryInfo(libname, lib.canonicalUri, null, size);
- _entityToInfo[lib] = info;
+ state.entityToInfo[lib] = info;
environment.forEachLibraryMember(lib, (MemberEntity member) {
if (member.isFunction || member.isGetter || member.isSetter) {
@@ -113,7 +110,7 @@
});
if (info.isEmpty && !shouldKeep(lib)) return null;
- result.libraries.add(info);
+ state.info.libraries.add(info);
return info;
}
@@ -146,10 +143,10 @@
code: code,
outputUnit: _unitInfoForMember(field),
isConst: field.isConst);
- _entityToInfo[field] = info;
+ state.entityToInfo[field] = info;
FieldAnalysisData fieldData = closedWorld.fieldAnalysis.getFieldData(field);
if (fieldData.initialValue != null) {
- info.initializer = _constantToInfo[fieldData.initialValue];
+ info.initializer = state.constantToInfo[fieldData.initialValue];
}
if (compiler.options.experimentCallInstrumentation) {
@@ -161,7 +158,7 @@
int closureSize = _addClosureInfo(info, field);
info.size = size + closureSize;
- result.fields.add(info);
+ state.info.fields.add(info);
return info;
}
@@ -179,7 +176,7 @@
return null;
}
- result.classTypes.add(classTypeInfo);
+ state.info.classTypes.add(classTypeInfo);
return classTypeInfo;
}
@@ -189,7 +186,7 @@
name: clazz.name,
isAbstract: clazz.isAbstract,
outputUnit: _unitInfoForClass(clazz));
- _entityToInfo[clazz] = classInfo;
+ state.entityToInfo[clazz] = classInfo;
int size = dumpInfoTask.sizeOf(clazz);
environment.forEachLocalClassMember(clazz, (member) {
@@ -234,7 +231,7 @@
return null;
}
- result.classes.add(classInfo);
+ state.info.classes.add(classInfo);
return classInfo;
}
@@ -243,7 +240,7 @@
name: element.name,
outputUnit: _unitInfoForClass(element),
size: dumpInfoTask.sizeOf(element));
- _entityToInfo[element] = closureInfo;
+ state.entityToInfo[element] = closureInfo;
FunctionEntity callMethod = closedWorld.elementEnvironment
.lookupClassMember(element, Identifiers.call);
@@ -253,7 +250,7 @@
closureInfo.function = functionInfo;
functionInfo.parent = closureInfo;
- result.closures.add(closureInfo);
+ state.info.closures.add(closureInfo);
return closureInfo;
}
@@ -328,7 +325,7 @@
code: code,
type: functionType.toString(),
outputUnit: _unitInfoForMember(function));
- _entityToInfo[function] = info;
+ state.entityToInfo[function] = info;
int closureSize = _addClosureInfo(info, function);
size += closureSize;
@@ -341,7 +338,7 @@
info.size = size;
- result.functions.add(info);
+ state.info.functions.add(info);
return info;
}
@@ -367,19 +364,19 @@
}
OutputUnitInfo _infoFromOutputUnit(OutputUnit outputUnit) {
- return _outputToInfo.putIfAbsent(outputUnit, () {
+ return state.outputToInfo.putIfAbsent(outputUnit, () {
// Dump-info currently only works with the full emitter. If another
// emitter is used it will fail here.
JsBackendStrategy backendStrategy = compiler.backendStrategy;
assert(outputUnit.name != null || outputUnit.isMainOutput);
- var filename = outputUnit.isMainOutput
- ? compiler.options.outputUri.pathSegments.last
+ final filename = outputUnit.isMainOutput
+ ? (compiler.options.outputUri?.pathSegments?.last ?? 'out')
: deferredPartFileName(compiler.options, outputUnit.name);
OutputUnitInfo info = OutputUnitInfo(filename, outputUnit.name,
backendStrategy.emitterTask.emitter.generatedSize(outputUnit));
info.imports
.addAll(closedWorld.outputUnitData.getImportNames(outputUnit));
- result.outputUnits.add(info);
+ state.info.outputUnits.add(info);
return info;
});
}
@@ -416,19 +413,15 @@
final JClosedWorld closedWorld;
final GlobalTypeInferenceResults _globalInferenceResults;
final DumpInfoTask dumpInfoTask;
+ final state = DumpInfoStateData();
JElementEnvironment get environment => closedWorld.elementEnvironment;
- final AllInfo result = AllInfo();
- final Map<Entity, Info> _entityToInfo = <Entity, Info>{};
- final Map<ConstantValue, Info> _constantToInfo = <ConstantValue, Info>{};
- final Map<OutputUnit, OutputUnitInfo> _outputToInfo = {};
-
KernelInfoCollector(this.component, this.compiler, this.dumpInfoTask,
this.closedWorld, this._globalInferenceResults);
void run() {
- // TODO(markzipan): Add CFE constants to `result.constants`.
+ // TODO(markzipan): Add CFE constants to `state.info.constants`.
component.libraries.forEach(visitLibrary);
}
@@ -442,7 +435,7 @@
}
LibraryInfo info = LibraryInfo(libname, lib.importUri, null, null);
- _entityToInfo[libEntity] = info;
+ state.entityToInfo[libEntity] = info;
lib.members.forEach((ir.Member member) {
final memberEntity =
@@ -481,7 +474,7 @@
}
});
- result.libraries.add(info);
+ state.info.libraries.add(info);
return info;
}
@@ -497,7 +490,7 @@
outputUnit: null,
isConst: field.isConst,
size: null);
- _entityToInfo[fieldEntity] = info;
+ state.entityToInfo[fieldEntity] = info;
if (compiler.options.experimentCallInstrumentation) {
// We use field.hashCode because it is globally unique and it is
@@ -505,13 +498,13 @@
info.coverageId = '${field.hashCode}';
}
- result.fields.add(info);
+ state.info.fields.add(info);
return info;
}
ClassTypeInfo visitClassType(ir.Class clazz) {
ClassTypeInfo classTypeInfo = ClassTypeInfo(name: clazz.name);
- result.classTypes.add(classTypeInfo);
+ state.info.classTypes.add(classTypeInfo);
return classTypeInfo;
}
@@ -519,7 +512,7 @@
// Omit class if it is not needed.
ClassInfo classInfo = ClassInfo(
name: clazz.name, isAbstract: clazz.isAbstract, outputUnit: null);
- _entityToInfo[classEntity] = classInfo;
+ state.entityToInfo[classEntity] = classInfo;
clazz.members.forEach((ir.Member member) {
// clazz.members includes constructors
@@ -530,7 +523,7 @@
// Multiple kernel members can map to single JWorld member
// (e.g., when one of a getter/field pair are tree-shaken),
// so avoid duplicating the downstream info object.
- if (_entityToInfo.containsKey(memberEntity)) {
+ if (state.entityToInfo.containsKey(memberEntity)) {
return;
}
@@ -550,7 +543,7 @@
}
});
- result.classes.add(classInfo);
+ state.info.classes.add(classInfo);
return classInfo;
}
@@ -636,7 +629,7 @@
code: null,
type: functionType.toStringInternal(),
outputUnit: null);
- _entityToInfo[functionEntity] = info;
+ state.entityToInfo[functionEntity] = info;
if (compiler.options.experimentCallInstrumentation) {
// We use function.hashCode because it is globally unique and it is
@@ -644,7 +637,7 @@
info.coverageId = '${function.hashCode}';
}
- result.functions.add(info);
+ state.info.functions.add(info);
return info;
}
}
@@ -671,9 +664,9 @@
size: span.end - span.start,
code: [span],
outputUnit: _unitInfoForConstant(constant));
- kernelInfo._constantToInfo[constant] = info;
+ kernelInfo.state.constantToInfo[constant] = info;
info.treeShakenStatus = TreeShakenStatus.Live;
- kernelInfo.result.constants.add(info);
+ kernelInfo.state.info.constants.add(info);
});
environment.libraries.forEach(visitLibrary);
}
@@ -689,7 +682,7 @@
}
LibraryInfo visitLibrary(LibraryEntity lib) {
- var kLibraryInfos = kernelInfo.result.libraries
+ var kLibraryInfos = kernelInfo.state.info.libraries
.where((i) => '${i.uri}' == '${lib.canonicalUri}');
assert(
kLibraryInfos.length == 1,
@@ -748,7 +741,7 @@
return null;
}
- final kFieldInfos = kernelInfo.result.fields
+ final kFieldInfos = kernelInfo.state.info.fields
.where((f) => f.name == field.name && f.parent.name == parentName)
.toList();
assert(
@@ -771,7 +764,7 @@
FieldAnalysisData fieldData = closedWorld.fieldAnalysis.getFieldData(field);
if (fieldData.initialValue != null) {
kFieldInfo.initializer =
- kernelInfo._constantToInfo[fieldData.initialValue];
+ kernelInfo.state.constantToInfo[fieldData.initialValue];
}
int closureSize = _addClosureInfo(kFieldInfo, field);
@@ -782,7 +775,7 @@
// TODO(markzipan): [parentName] is used for disambiguation, but this might
// not always be valid. Check and validate later.
ClassTypeInfo visitClassType(ClassEntity clazz, String parentName) {
- var kClassTypeInfos = kernelInfo.result.classTypes
+ var kClassTypeInfos = kernelInfo.state.info.classTypes
.where((i) => i.name == clazz.name && i.parent.name == parentName);
assert(
kClassTypeInfos.length == 1,
@@ -807,7 +800,7 @@
// TODO(markzipan): [parentName] is used for disambiguation, but this might
// not always be valid. Check and validate later.
ClassInfo visitClass(ClassEntity clazz, String parentName) {
- final kClassInfos = kernelInfo.result.classes
+ final kClassInfos = kernelInfo.state.info.classes
.where((i) => i.name == clazz.name && i.parent.name == parentName)
.toList();
assert(
@@ -863,7 +856,7 @@
name: element.name,
outputUnit: _unitInfoForClass(element),
size: dumpInfoTask.sizeOf(element));
- kernelInfo._entityToInfo[element] = closureInfo;
+ kernelInfo.state.entityToInfo[element] = closureInfo;
FunctionEntity callMethod = closedWorld.elementEnvironment
.lookupClassMember(element, Identifiers.call);
@@ -875,7 +868,7 @@
functionInfo.parent = closureInfo;
closureInfo.treeShakenStatus = TreeShakenStatus.Live;
- kernelInfo.result.closures.add(closureInfo);
+ kernelInfo.state.info.closures.add(closureInfo);
return closureInfo;
}
@@ -896,7 +889,7 @@
// Multiple kernel members members can sometimes map to a single JElement.
// [isSetter] and [isGetter] are required for disambiguating these cases.
- final kFunctionInfos = kernelInfo.result.functions
+ final kFunctionInfos = kernelInfo.state.info.functions
.where((i) =>
i.name == compareName &&
i.parent.name == parentName &&
@@ -966,20 +959,20 @@
}
OutputUnitInfo _infoFromOutputUnit(OutputUnit outputUnit) {
- return kernelInfo._outputToInfo.putIfAbsent(outputUnit, () {
+ return kernelInfo.state.outputToInfo.putIfAbsent(outputUnit, () {
// Dump-info currently only works with the full emitter. If another
// emitter is used it will fail here.
JsBackendStrategy backendStrategy = compiler.backendStrategy;
assert(outputUnit.name != null || outputUnit.isMainOutput);
- var filename = outputUnit.isMainOutput
- ? compiler.options.outputUri.pathSegments.last
+ final filename = outputUnit.isMainOutput
+ ? (compiler.options.outputUri?.pathSegments?.last ?? 'out')
: deferredPartFileName(compiler.options, outputUnit.name);
OutputUnitInfo info = OutputUnitInfo(filename, outputUnit.name,
backendStrategy.emitterTask.emitter.generatedSize(outputUnit));
info.treeShakenStatus = TreeShakenStatus.Live;
info.imports
.addAll(closedWorld.outputUnitData.getImportNames(outputUnit));
- kernelInfo.result.outputUnits.add(info);
+ kernelInfo.state.info.outputUnits.add(info);
return info;
});
}
@@ -1177,24 +1170,29 @@
return code.map((ast) => _nodeData[ast]).toList();
}
- void dumpInfo(JClosedWorld closedWorld,
+ DumpInfoStateData dumpInfo(JClosedWorld closedWorld,
GlobalTypeInferenceResults globalInferenceResults) {
+ DumpInfoStateData dumpInfoState;
measure(() {
ElementInfoCollector elementInfoCollector = ElementInfoCollector(
compiler, this, closedWorld, globalInferenceResults)
..run();
- var allInfo = buildDumpInfoData(closedWorld, elementInfoCollector);
+ dumpInfoState = buildDumpInfoData(closedWorld, elementInfoCollector);
if (useBinaryFormat) {
- dumpInfoBinary(allInfo);
+ dumpInfoBinary(dumpInfoState.info);
} else {
- dumpInfoJson(allInfo);
+ dumpInfoJson(dumpInfoState.info);
}
});
+ return dumpInfoState;
}
- void dumpInfoNew(ir.Component component, JClosedWorld closedWorld,
+ DumpInfoStateData dumpInfoNew(
+ ir.Component component,
+ JClosedWorld closedWorld,
GlobalTypeInferenceResults globalInferenceResults) {
+ DumpInfoStateData dumpInfoState;
measure(() {
KernelInfoCollector kernelInfoCollector = KernelInfoCollector(
component, compiler, this, closedWorld, globalInferenceResults)
@@ -1204,15 +1202,14 @@
globalInferenceResults)
..run();
- var allInfo = buildDumpInfoDataNew(closedWorld, kernelInfoCollector);
- // TODO(markzipan): Filter DumpInfo here instead of passing a filter
- // filter flag through the serializers.
+ dumpInfoState = buildDumpInfoDataNew(closedWorld, kernelInfoCollector);
if (useBinaryFormat) {
- dumpInfoBinary(allInfo);
+ dumpInfoBinary(dumpInfoState.info);
} else {
- dumpInfoJson(allInfo, filterTreeshaken: true);
+ dumpInfoJson(dumpInfoState.info, filterTreeshaken: true);
}
});
+ return dumpInfoState;
}
void dumpInfoJson(AllInfo data, {bool filterTreeshaken = false}) {
@@ -1223,10 +1220,9 @@
sink.add(AllInfoJsonCodec(
isBackwardCompatible: true, filterTreeshaken: filterTreeshaken)
.encode(data));
- compiler.outputProvider.createOutputSink(
- compiler.options.outputUri.pathSegments.last,
- 'info.json',
- OutputType.dumpInfo)
+ final name = (compiler.options.outputUri?.pathSegments?.last ?? 'out');
+ compiler.outputProvider
+ .createOutputSink(name, 'info.json', OutputType.dumpInfo)
..add(jsonBuffer.toString())
..close();
compiler.reporter
@@ -1237,7 +1233,8 @@
}
void dumpInfoBinary(AllInfo data, {bool filterTreeshaken = false}) {
- var name = compiler.options.outputUri.pathSegments.last + ".info.data";
+ final name = (compiler.options.outputUri?.pathSegments?.last ?? 'out') +
+ ".info.data";
// TODO(markzipan): Plumb [filterTreeshaken] through
// [BinaryOutputSinkAdapter].
Sink<List<int>> sink = BinaryOutputSinkAdapter(compiler.outputProvider
@@ -1250,23 +1247,24 @@
});
}
- AllInfo buildDumpInfoData(
+ DumpInfoStateData buildDumpInfoData(
JClosedWorld closedWorld, ElementInfoCollector infoCollector) {
Stopwatch stopwatch = Stopwatch();
stopwatch.start();
- AllInfo result = infoCollector.result;
+ DumpInfoStateData result = infoCollector.state;
// Recursively build links to function uses
Iterable<Entity> functionEntities =
- infoCollector._entityToInfo.keys.where((k) => k is FunctionEntity);
+ infoCollector.state.entityToInfo.keys.where((k) => k is FunctionEntity);
for (FunctionEntity entity in functionEntities) {
- FunctionInfo info = infoCollector._entityToInfo[entity];
+ FunctionInfo info = infoCollector.state.entityToInfo[entity];
Iterable<Selection> uses = getRetaining(entity, closedWorld);
// Don't bother recording an empty list of dependencies.
for (Selection selection in uses) {
// Don't register dart2js builtin functions that are not recorded.
- Info useInfo = infoCollector._entityToInfo[selection.selectedEntity];
+ Info useInfo =
+ infoCollector.state.entityToInfo[selection.selectedEntity];
if (useInfo == null) continue;
info.uses.add(
DependencyInfo(useInfo, selection.receiverConstraint?.toString()));
@@ -1275,13 +1273,14 @@
// Recursively build links to field uses
Iterable<Entity> fieldEntity =
- infoCollector._entityToInfo.keys.where((k) => k is FieldEntity);
+ infoCollector.state.entityToInfo.keys.where((k) => k is FieldEntity);
for (FieldEntity entity in fieldEntity) {
- FieldInfo info = infoCollector._entityToInfo[entity];
+ FieldInfo info = infoCollector.state.entityToInfo[entity];
Iterable<Selection> uses = getRetaining(entity, closedWorld);
// Don't bother recording an empty list of dependencies.
for (Selection selection in uses) {
- Info useInfo = infoCollector._entityToInfo[selection.selectedEntity];
+ Info useInfo =
+ infoCollector.state.entityToInfo[selection.selectedEntity];
if (useInfo == null) continue;
info.uses.add(
DependencyInfo(useInfo, selection.receiverConstraint?.toString()));
@@ -1290,10 +1289,10 @@
// Track dependencies that come from inlining.
for (Entity entity in inlineMap.keys) {
- CodeInfo outerInfo = infoCollector._entityToInfo[entity];
+ CodeInfo outerInfo = infoCollector.state.entityToInfo[entity];
if (outerInfo == null) continue;
for (Entity inlined in inlineMap[entity]) {
- Info inlinedInfo = infoCollector._entityToInfo[inlined];
+ Info inlinedInfo = infoCollector.state.entityToInfo[inlined];
if (inlinedInfo == null) continue;
outerInfo.uses.add(DependencyInfo(inlinedInfo, 'inlined'));
}
@@ -1303,12 +1302,13 @@
compiler.backendStrategy.emitterTask.emitter.finalizedFragmentsToLoad;
var fragmentMerger =
compiler.backendStrategy.emitterTask.emitter.fragmentMerger;
- result.deferredFiles = fragmentMerger.computeDeferredMap(fragmentsToLoad);
+ result.info.deferredFiles =
+ fragmentMerger.computeDeferredMap(fragmentsToLoad);
stopwatch.stop();
- result.program = ProgramInfo(
+ result.info.program = ProgramInfo(
entrypoint: infoCollector
- ._entityToInfo[closedWorld.elementEnvironment.mainFunction],
+ .state.entityToInfo[closedWorld.elementEnvironment.mainFunction],
size: _programSize,
dart2jsVersion:
compiler.options.hasBuildId ? compiler.options.buildId : null,
@@ -1326,23 +1326,24 @@
return result;
}
- AllInfo buildDumpInfoDataNew(
+ DumpInfoStateData buildDumpInfoDataNew(
JClosedWorld closedWorld, KernelInfoCollector infoCollector) {
Stopwatch stopwatch = Stopwatch();
stopwatch.start();
- AllInfo result = infoCollector.result;
+ DumpInfoStateData result = infoCollector.state;
// Recursively build links to function uses
Iterable<Entity> functionEntities =
- infoCollector._entityToInfo.keys.where((k) => k is FunctionEntity);
+ infoCollector.state.entityToInfo.keys.where((k) => k is FunctionEntity);
for (FunctionEntity entity in functionEntities) {
- FunctionInfo info = infoCollector._entityToInfo[entity];
+ FunctionInfo info = infoCollector.state.entityToInfo[entity];
Iterable<Selection> uses = getRetaining(entity, closedWorld);
// Don't bother recording an empty list of dependencies.
for (Selection selection in uses) {
// Don't register dart2js builtin functions that are not recorded.
- Info useInfo = infoCollector._entityToInfo[selection.selectedEntity];
+ Info useInfo =
+ infoCollector.state.entityToInfo[selection.selectedEntity];
if (useInfo == null) continue;
if (useInfo.treeShakenStatus != TreeShakenStatus.Live) continue;
info.uses.add(
@@ -1352,13 +1353,14 @@
// Recursively build links to field uses
Iterable<Entity> fieldEntity =
- infoCollector._entityToInfo.keys.where((k) => k is FieldEntity);
+ infoCollector.state.entityToInfo.keys.where((k) => k is FieldEntity);
for (FieldEntity entity in fieldEntity) {
- FieldInfo info = infoCollector._entityToInfo[entity];
+ FieldInfo info = infoCollector.state.entityToInfo[entity];
Iterable<Selection> uses = getRetaining(entity, closedWorld);
// Don't bother recording an empty list of dependencies.
for (Selection selection in uses) {
- Info useInfo = infoCollector._entityToInfo[selection.selectedEntity];
+ Info useInfo =
+ infoCollector.state.entityToInfo[selection.selectedEntity];
if (useInfo == null) continue;
if (useInfo.treeShakenStatus != TreeShakenStatus.Live) continue;
info.uses.add(
@@ -1368,10 +1370,10 @@
// Track dependencies that come from inlining.
for (Entity entity in inlineMap.keys) {
- CodeInfo outerInfo = infoCollector._entityToInfo[entity];
+ CodeInfo outerInfo = infoCollector.state.entityToInfo[entity];
if (outerInfo == null) continue;
for (Entity inlined in inlineMap[entity]) {
- Info inlinedInfo = infoCollector._entityToInfo[inlined];
+ Info inlinedInfo = infoCollector.state.entityToInfo[inlined];
if (inlinedInfo == null) continue;
if (inlinedInfo.treeShakenStatus != TreeShakenStatus.Live) continue;
outerInfo.uses.add(DependencyInfo(inlinedInfo, 'inlined'));
@@ -1382,12 +1384,13 @@
compiler.backendStrategy.emitterTask.emitter.finalizedFragmentsToLoad;
var fragmentMerger =
compiler.backendStrategy.emitterTask.emitter.fragmentMerger;
- result.deferredFiles = fragmentMerger.computeDeferredMap(fragmentsToLoad);
+ result.info.deferredFiles =
+ fragmentMerger.computeDeferredMap(fragmentsToLoad);
stopwatch.stop();
- result.program = ProgramInfo(
+ result.info.program = ProgramInfo(
entrypoint: infoCollector
- ._entityToInfo[closedWorld.elementEnvironment.mainFunction],
+ .state.entityToInfo[closedWorld.elementEnvironment.mainFunction],
size: _programSize,
dart2jsVersion:
compiler.options.hasBuildId ? compiler.options.buildId : null,
@@ -1414,3 +1417,13 @@
String get text => '$_text';
int get length => end - start;
}
+
+/// Holds dump-info's mutable state.
+class DumpInfoStateData {
+ final AllInfo info = AllInfo();
+ final Map<Entity, Info> entityToInfo = <Entity, Info>{};
+ final Map<ConstantValue, Info> constantToInfo = <ConstantValue, Info>{};
+ final Map<OutputUnit, OutputUnitInfo> outputToInfo = {};
+
+ DumpInfoStateData();
+}
diff --git a/pkg/compiler/lib/src/hash/sha1.dart b/pkg/compiler/lib/src/hash/sha1.dart
index e8698a0..bcfa126 100644
--- a/pkg/compiler/lib/src/hash/sha1.dart
+++ b/pkg/compiler/lib/src/hash/sha1.dart
@@ -2,17 +2,15 @@
// 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.
-// @dart = 2.10
-
import 'dart:convert';
import 'package:crypto/crypto.dart';
-import '../io/code_output.dart' show CodeOutputListener;
+import '../io/code_output_listener.dart' show CodeOutputListener;
class Hasher implements CodeOutputListener {
final _DigestSink _digestSink;
- ByteConversionSink _byteSink;
+ ByteConversionSink? _byteSink;
Hasher._(this._digestSink)
: _byteSink = sha1.startChunkedConversion(_digestSink);
@@ -27,7 +25,7 @@
@override
void onText(String text) {
if (_byteSink != null) {
- _byteSink.add(utf8.encode(text));
+ _byteSink!.add(utf8.encode(text));
}
}
@@ -35,7 +33,7 @@
/// text.
String getHash() {
if (_byteSink != null) {
- _byteSink.close();
+ _byteSink!.close();
_byteSink = null;
}
return base64.encode(_digestSink.value.bytes);
@@ -44,12 +42,12 @@
/// A sink used to get a digest value out of `Hash.startChunkedConversion`.
class _DigestSink extends Sink<Digest> {
- Digest _value;
+ Digest? _value;
/// The value added to the sink, if any.
Digest /*!*/ get value {
assert(_value != null);
- return _value;
+ return _value!;
}
/// Adds [value] to the sink.
diff --git a/pkg/compiler/lib/src/io/code_output.dart b/pkg/compiler/lib/src/io/code_output.dart
index a1d8036..19d4300 100644
--- a/pkg/compiler/lib/src/io/code_output.dart
+++ b/pkg/compiler/lib/src/io/code_output.dart
@@ -7,17 +7,10 @@
library dart2js.code_output;
import '../../compiler.dart';
+import 'code_output_listener.dart';
+export 'code_output_listener.dart';
import 'source_information.dart';
-/// Listener interface for [CodeOutput] activity.
-abstract class CodeOutputListener {
- /// Called when [text] is added to the output.
- void onText(String text);
-
- /// Called when the output is closed with a final length of [length].
- void onDone(int length);
-}
-
/// Interface for a mapping of target offsets to source locations and for
/// tracking inlining frame data.
///
diff --git a/pkg/compiler/lib/src/io/code_output_listener.dart b/pkg/compiler/lib/src/io/code_output_listener.dart
new file mode 100644
index 0000000..18ba3c4
--- /dev/null
+++ b/pkg/compiler/lib/src/io/code_output_listener.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2012, 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.
+
+library dart2js.code_output_listener;
+
+/// Listener interface for [CodeOutput] activity.
+abstract class CodeOutputListener {
+ /// Called when [text] is added to the output.
+ void onText(String text);
+
+ /// Called when the output is closed with a final length of [length].
+ void onDone(int length);
+}
diff --git a/pkg/compiler/lib/src/io/location_provider.dart b/pkg/compiler/lib/src/io/location_provider.dart
index 72305e7..0f5f501 100644
--- a/pkg/compiler/lib/src/io/location_provider.dart
+++ b/pkg/compiler/lib/src/io/location_provider.dart
@@ -2,11 +2,9 @@
// 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.
-// @dart = 2.10
-
library dart2js.io.location_provider;
-import 'code_output.dart' show CodeOutputListener;
+import 'code_output_listener.dart' show CodeOutputListener;
import 'package:kernel/ast.dart' show Location, Source;
@@ -43,9 +41,12 @@
Location getLocation(int offset) {
RangeError.checkValueInInterval(offset, 0, length, 'offset');
return Source(lineStarts, const <int>[], null, null)
- .getLocation(null, offset);
+ .getLocation(_dummyFile, offset);
}
+ // TODO(48820): Pass file Uri in to Constructor.
+ static final Uri _dummyFile = Uri();
+
@override
void onDone(int length) {
lineStarts.add(length + 1);
diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h
index b884b36..09d4591 100644
--- a/runtime/include/dart_api.h
+++ b/runtime/include/dart_api.h
@@ -849,7 +849,7 @@
* The current version of the Dart_InitializeFlags. Should be incremented every
* time Dart_InitializeFlags changes in a binary incompatible way.
*/
-#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000006)
+#define DART_INITIALIZE_PARAMS_CURRENT_VERSION (0x00000007)
/** Forward declaration */
struct Dart_CodeObserver;
@@ -875,50 +875,6 @@
Dart_OnNewCodeCallback on_new_code;
} Dart_CodeObserver;
-typedef struct _Dart_Task* Dart_Task;
-typedef enum {
- Dart_TaskPriority_Default,
-} Dart_TaskPriority;
-typedef struct {
- /**
- * Placeholder.
- */
- Dart_TaskPriority priority;
- /**
- * Time after which the task should run according to the clock of
- * Dart_TimelineGetMicros.
- */
- int64_t time_point;
-} Dart_TaskData;
-/**
- * Callback provided by the embedder that is used by the VM to eventually run
- * various tasks. If no callback is provided, these tasks will run on a
- * VM-internal thread pool. This callback allows the embedder to make its own
- * choices around the scheduling of these tasks: when they run, how many threads
- * are servicing these tasks, the priorities of said threads, etc.
- * The callback can be invoked as early as during the Dart_Initialize call.
- *
- * \param post_task_data
- * The data provided to Dart_InitializeParams.post_task_data.
- * \param task
- * A task that should eventually be passed to Dart_RunTask.
- * \param task_data
- * Hints about when the task should run.
- */
-typedef void (*Dart_PostTaskCallback)(void* post_task_data,
- Dart_Task task,
- Dart_TaskData task_data);
-
-/**
- * Runs a task given to the Dart_PostTaskCallback. Must not be called
- * synchronously in response to any callback from the VM. In particular, must
- * not be called synchronously by the implemention of a Dart native function
- * or Dart_Post_TaskCallback.
- *
- * Requires there to be no current isolate or isolate group.
- */
-DART_EXPORT void Dart_RunTask(Dart_Task task);
-
/**
* Optional callback provided by the embedder that is used by the VM to
* implement registration of kernel blobs for the subsequent Isolate.spawnUri
@@ -1028,13 +984,6 @@
Dart_CodeObserver* code_observer;
/**
- * A task scheduling callback function. See Dart_PostTaskCallback.
- */
- Dart_PostTaskCallback post_task;
-
- void* post_task_data;
-
- /**
* Kernel blob registration callback function. See Dart_RegisterKernelBlobCallback.
*/
Dart_RegisterKernelBlobCallback register_kernel_blob;
diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc
index 9042281..bf4c995 100644
--- a/runtime/vm/dart.cc
+++ b/runtime/vm/dart.cc
@@ -69,8 +69,6 @@
Dart_FileCloseCallback Dart::file_close_callback_ = NULL;
Dart_EntropySource Dart::entropy_source_callback_ = NULL;
Dart_GCEventCallback Dart::gc_event_callback_ = nullptr;
-Dart_PostTaskCallback Dart::post_task_callback_ = nullptr;
-void* Dart::post_task_data_ = nullptr;
// Structure for managing read-only global handles allocation used for
// creating global read-only handles that are pre created and initialized
@@ -283,8 +281,6 @@
SetFileCallbacks(params->file_open, params->file_read, params->file_write,
params->file_close);
set_entropy_source_callback(params->entropy_source);
- set_post_task_callback(params->post_task);
- set_post_task_data(params->post_task_data);
OS::Init();
NOT_IN_PRODUCT(CodeObservers::Init());
if (params->code_observer != nullptr) {
@@ -802,8 +798,6 @@
Service::SetEmbedderStreamCallbacks(NULL, NULL);
#endif // !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
VirtualMemory::Cleanup();
- post_task_callback_ = nullptr;
- post_task_data_ = nullptr;
return NULL;
}
diff --git a/runtime/vm/dart.h b/runtime/vm/dart.h
index 9b88af1..ede6a2f 100644
--- a/runtime/vm/dart.h
+++ b/runtime/vm/dart.h
@@ -114,14 +114,6 @@
static void set_thread_exit_callback(Dart_ThreadExitCallback cback) {
thread_exit_callback_ = cback;
}
- static Dart_PostTaskCallback post_task_callback() {
- return post_task_callback_;
- }
- static void set_post_task_callback(Dart_PostTaskCallback cback) {
- post_task_callback_ = cback;
- }
- static void* post_task_data() { return post_task_data_; }
- static void set_post_task_data(void* data) { post_task_data_ = data; }
static void SetFileCallbacks(Dart_FileOpenCallback file_open,
Dart_FileReadCallback file_read,
Dart_FileWriteCallback file_write,
@@ -179,8 +171,6 @@
static Dart_FileCloseCallback file_close_callback_;
static Dart_EntropySource entropy_source_callback_;
static Dart_GCEventCallback gc_event_callback_;
- static Dart_PostTaskCallback post_task_callback_;
- static void* post_task_data_;
};
} // namespace dart
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 400aff2..c38de03 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -2047,16 +2047,6 @@
return true;
}
-DART_EXPORT void Dart_RunTask(Dart_Task task) {
- Thread* T = Thread::Current();
- Isolate* I = T == nullptr ? nullptr : T->isolate();
- CHECK_NO_ISOLATE(I);
- API_TIMELINE_BEGIN_END(T);
- ThreadPool::Task* task_impl = reinterpret_cast<ThreadPool::Task*>(task);
- task_impl->Run();
- delete task_impl;
-}
-
DART_EXPORT Dart_Handle Dart_HandleMessage() {
Thread* T = Thread::Current();
Isolate* I = T->isolate();
diff --git a/runtime/vm/thread_pool.cc b/runtime/vm/thread_pool.cc
index ac6adfc..1cf0b8f 100644
--- a/runtime/vm/thread_pool.cc
+++ b/runtime/vm/thread_pool.cc
@@ -82,22 +82,6 @@
}
bool ThreadPool::RunImpl(std::unique_ptr<Task> task) {
- Dart_PostTaskCallback post_task = Dart::post_task_callback();
- if (post_task != nullptr) {
- {
- MonitorLocker ml(&pool_monitor_);
- if (shutting_down_) {
- return false;
- }
- }
- Dart_TaskData data;
- data.priority = Dart_TaskPriority_Default;
- data.time_point = 0;
- post_task(Dart::post_task_data(),
- reinterpret_cast<Dart_Task>(task.release()), data);
- return true;
- }
-
Worker* new_worker = nullptr;
{
MonitorLocker ml(&pool_monitor_);
diff --git a/tools/VERSION b/tools/VERSION
index 0459c27..74dc52d 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 18
PATCH 0
-PRERELEASE 31
+PRERELEASE 32
PRERELEASE_PATCH 0
\ No newline at end of file