Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Unified Diff: lib/src/util/dart.dart

Issue 2269403002: Add a packageResolver parameter to runInIsolate(). (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Bump pubspec and changelog. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/util/dart.dart
diff --git a/lib/src/util/dart.dart b/lib/src/util/dart.dart
index 05cd260a96b92433ba073b65aed9c4a6785de6e5..e18b50d0334adfb85134166a80ac70e1aef8a05d 100644
--- a/lib/src/util/dart.dart
+++ b/lib/src/util/dart.dart
@@ -6,6 +6,7 @@ import 'dart:async';
import 'dart:isolate';
import 'package:analyzer/analyzer.dart';
+import 'package:package_resolver/package_resolver.dart';
import 'package:source_span/source_span.dart';
import 'string_literal_iterator.dart';
@@ -16,13 +17,18 @@ import 'string_literal_iterator.dart';
/// they will be resolved in the same context as the host isolate. [message] is
/// passed to the [main] method of the code being run; the caller is responsible
/// for using this to establish communication with the isolate.
-Future<Isolate> runInIsolate(String code, message, {bool checked}) async {
+///
+/// If [resolver] is passed, its package resolution strategy is used to resolve
+/// code in the spawned isolate. It defaults to [PackageResolver.current].
+Future<Isolate> runInIsolate(String code, message, {PackageResolver resolver,
+ bool checked}) async {
+ resolver ??= PackageResolver.current;
return await Isolate.spawnUri(
Uri.parse('data:application/dart;charset=utf-8,' + Uri.encodeFull(code)),
[],
message,
- packageRoot: await Isolate.packageRoot,
- packageConfig: await Isolate.packageConfig,
+ packageRoot: await resolver.packageRoot,
+ packageConfig: await resolver.packageConfigUri,
checked: checked);
}
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698