OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library fasta.translate_uri; | 5 library fasta.translate_uri; |
6 | 6 |
7 import 'dart:async' show | 7 import 'dart:async' show Future; |
8 Future; | |
9 | 8 |
10 import 'dart:io' show | 9 import 'dart:io' show File; |
11 File; | |
12 | 10 |
13 import 'package:package_config/packages_file.dart' as packages_file show | 11 import 'package:package_config/packages_file.dart' as packages_file show parse; |
14 parse; | |
15 | 12 |
16 class TranslateUri { | 13 class TranslateUri { |
17 final Map<String, Uri> packages; | 14 final Map<String, Uri> packages; |
18 final Map<String, Uri> dartLibraries; | 15 final Map<String, Uri> dartLibraries; |
19 | 16 |
20 TranslateUri(this.packages, this.dartLibraries); | 17 TranslateUri(this.packages, this.dartLibraries); |
21 | 18 |
22 Uri translate(Uri uri) { | 19 Uri translate(Uri uri) { |
23 if (uri.scheme == "dart") return translateDartUri(uri); | 20 if (uri.scheme == "dart") return translateDartUri(uri); |
24 if (uri.scheme == "package") return translatePackageUri(uri); | 21 if (uri.scheme == "package") return translatePackageUri(uri); |
(...skipping 23 matching lines...) Expand all Loading... |
48 "async": sdk.resolve("lib/async/async.dart"), | 45 "async": sdk.resolve("lib/async/async.dart"), |
49 "_blink": sdk.resolve("lib/_blink/dartium/_blink_dartium.dart"), | 46 "_blink": sdk.resolve("lib/_blink/dartium/_blink_dartium.dart"), |
50 "_chrome": sdk.resolve("lib/_chrome/dart2js/chrome_dart2js.dart"), | 47 "_chrome": sdk.resolve("lib/_chrome/dart2js/chrome_dart2js.dart"), |
51 "collection": sdk.resolve("lib/collection/collection.dart"), | 48 "collection": sdk.resolve("lib/collection/collection.dart"), |
52 "convert": sdk.resolve("lib/convert/convert.dart"), | 49 "convert": sdk.resolve("lib/convert/convert.dart"), |
53 "core": sdk.resolve("lib/core/core.dart"), | 50 "core": sdk.resolve("lib/core/core.dart"), |
54 "developer": sdk.resolve("lib/developer/developer.dart"), | 51 "developer": sdk.resolve("lib/developer/developer.dart"), |
55 "html": sdk.resolve("lib/html/dartium/html_dartium.dart"), | 52 "html": sdk.resolve("lib/html/dartium/html_dartium.dart"), |
56 "html_common": sdk.resolve("lib/html/html_common/html_common.dart"), | 53 "html_common": sdk.resolve("lib/html/html_common/html_common.dart"), |
57 "indexed_db": | 54 "indexed_db": |
58 sdk.resolve("lib/indexed_db/dartium/indexed_db_dartium.dart"), | 55 sdk.resolve("lib/indexed_db/dartium/indexed_db_dartium.dart"), |
59 "io": sdk.resolve("lib/io/io.dart"), | 56 "io": sdk.resolve("lib/io/io.dart"), |
60 "isolate": sdk.resolve("lib/isolate/isolate.dart"), | 57 "isolate": sdk.resolve("lib/isolate/isolate.dart"), |
61 "js": sdk.resolve("lib/js/dartium/js_dartium.dart"), | 58 "js": sdk.resolve("lib/js/dartium/js_dartium.dart"), |
62 "js_util": sdk.resolve("lib/js_util/dartium/js_util_dartium.dart"), | 59 "js_util": sdk.resolve("lib/js_util/dartium/js_util_dartium.dart"), |
63 "math": sdk.resolve("lib/math/math.dart"), | 60 "math": sdk.resolve("lib/math/math.dart"), |
64 "mirrors": sdk.resolve("lib/mirrors/mirrors.dart"), | 61 "mirrors": sdk.resolve("lib/mirrors/mirrors.dart"), |
65 "nativewrappers": sdk.resolve("lib/html/dartium/nativewrappers.dart"), | 62 "nativewrappers": sdk.resolve("lib/html/dartium/nativewrappers.dart"), |
66 "typed_data": sdk.resolve("lib/typed_data/typed_data.dart"), | 63 "typed_data": sdk.resolve("lib/typed_data/typed_data.dart"), |
67 "svg": sdk.resolve("lib/svg/dartium/svg_dartium.dart"), | 64 "svg": sdk.resolve("lib/svg/dartium/svg_dartium.dart"), |
68 "web_audio": sdk.resolve("lib/web_audio/dartium/web_audio_dartium.dart")
, | 65 "web_audio": |
| 66 sdk.resolve("lib/web_audio/dartium/web_audio_dartium.dart"), |
69 "web_gl": sdk.resolve("lib/web_gl/dartium/web_gl_dartium.dart"), | 67 "web_gl": sdk.resolve("lib/web_gl/dartium/web_gl_dartium.dart"), |
70 "web_sql": sdk.resolve("lib/web_sql/dartium/web_sql_dartium.dart"), | 68 "web_sql": sdk.resolve("lib/web_sql/dartium/web_sql_dartium.dart"), |
71 "_internal": sdk.resolve("lib/internal/internal.dart"), | 69 "_internal": sdk.resolve("lib/internal/internal.dart"), |
72 "profiler": sdk.resolve("lib/profiler/profiler.dart"), | 70 "profiler": sdk.resolve("lib/profiler/profiler.dart"), |
73 "vmservice_io": sdk.resolve("lib/vmservice_io/vmservice_io.dart"), | 71 "vmservice_io": sdk.resolve("lib/vmservice_io/vmservice_io.dart"), |
74 "_vmservice": sdk.resolve("lib/vmservice/vmservice.dart"), | 72 "_vmservice": sdk.resolve("lib/vmservice/vmservice.dart"), |
75 "_builtin": sdk.resolve("lib/_builtin/_builtin.dart"), | 73 "_builtin": sdk.resolve("lib/_builtin/_builtin.dart"), |
76 }; | 74 }; |
77 } | 75 } |
78 uri ??= Uri.base.resolve(".packages"); | 76 uri ??= Uri.base.resolve(".packages"); |
79 File file = new File.fromUri(uri); | 77 File file = new File.fromUri(uri); |
80 List<int> bytes = await file.readAsBytes(); | 78 List<int> bytes = await file.readAsBytes(); |
81 Map<String, Uri> packages = packages_file.parse(bytes, uri); | 79 Map<String, Uri> packages = packages_file.parse(bytes, uri); |
82 return new TranslateUri(packages, dartLibraries); | 80 return new TranslateUri(packages, dartLibraries); |
83 } | 81 } |
84 } | 82 } |
OLD | NEW |