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

Side by Side Diff: lib/src/util/dart.dart

Issue 2184543002: Use the package_resolver package. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « lib/src/runner/vm/platform.dart ('k') | lib/src/util/io.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 import 'package:analyzer/analyzer.dart'; 8 import 'package:analyzer/analyzer.dart';
9 import 'package:source_span/source_span.dart'; 9 import 'package:source_span/source_span.dart';
10 10
11 import 'string_literal_iterator.dart'; 11 import 'string_literal_iterator.dart';
12 12
13 /// Runs [code] in an isolate. 13 /// Runs [code] in an isolate.
14 /// 14 ///
15 /// [code] should be the contents of a Dart entrypoint. It may contain imports; 15 /// [code] should be the contents of a Dart entrypoint. It may contain imports;
16 /// they will be resolved in the same context as the host isolate. [message] is 16 /// they will be resolved in the same context as the host isolate. [message] is
17 /// passed to the [main] method of the code being run; the caller is responsible 17 /// passed to the [main] method of the code being run; the caller is responsible
18 /// for using this to establish communication with the isolate. 18 /// for using this to establish communication with the isolate.
19 /// 19 Future<Isolate> runInIsolate(String code, message, {bool checked}) async {
20 /// [packageRoot] controls the package root of the isolate. It may be either a
21 /// [String] or a [Uri].
22 Future<Isolate> runInIsolate(String code, message, {packageRoot,
23 bool checked}) async {
24 if (packageRoot is String) packageRoot = Uri.parse(packageRoot);
25
26 return await Isolate.spawnUri( 20 return await Isolate.spawnUri(
27 Uri.parse('data:application/dart;charset=utf-8,' + Uri.encodeFull(code)), 21 Uri.parse('data:application/dart;charset=utf-8,' + Uri.encodeFull(code)),
28 [], 22 [],
29 message, 23 message,
30 packageRoot: packageRoot, 24 packageRoot: await Isolate.packageRoot,
25 packageConfig: await Isolate.packageConfig,
31 checked: checked); 26 checked: checked);
32 } 27 }
33 28
34 // TODO(nweiz): Move this into the analyzer once it starts using SourceSpan 29 // TODO(nweiz): Move this into the analyzer once it starts using SourceSpan
35 // (issue 22977). 30 // (issue 22977).
36 /// Takes a span whose source is the value of a string that has been parsed from 31 /// Takes a span whose source is the value of a string that has been parsed from
37 /// a Dart file and returns the corresponding span from within that Dart file. 32 /// a Dart file and returns the corresponding span from within that Dart file.
38 /// 33 ///
39 /// For example, suppose a Dart file contains `@Eval("1 + a")`. The 34 /// For example, suppose a Dart file contains `@Eval("1 + a")`. The
40 /// [StringLiteral] `"1 + a"` is extracted; this is [context]. Its contents are 35 /// [StringLiteral] `"1 + a"` is extracted; this is [context]. Its contents are
(...skipping 26 matching lines...) Expand all
67 } 62 }
68 63
69 var start = contextRunes.offset; 64 var start = contextRunes.offset;
70 for (var spanRune in span.text.runes) { 65 for (var spanRune in span.text.runes) {
71 if (spanRune != contextRunes.current) return null; 66 if (spanRune != contextRunes.current) return null;
72 contextRunes.moveNext(); 67 contextRunes.moveNext();
73 } 68 }
74 69
75 return file.span(start, contextRunes.offset); 70 return file.span(start, contextRunes.offset);
76 } 71 }
OLDNEW
« no previous file with comments | « lib/src/runner/vm/platform.dart ('k') | lib/src/util/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698