| 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 |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:io' show | 10 import 'dart:io' show |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 Uri root = packages[name]; | 35 Uri root = packages[name]; |
| 36 if (root == null) return null; | 36 if (root == null) return null; |
| 37 return root.resolve(path); | 37 return root.resolve(path); |
| 38 } | 38 } |
| 39 | 39 |
| 40 static Future<TranslateUri> parse(Uri sdk, [Uri uri]) async { | 40 static Future<TranslateUri> parse(Uri sdk, [Uri uri]) async { |
| 41 // This list is generated with [bin/generate_dart_libraries.dart] below. | 41 // This list is generated with [bin/generate_dart_libraries.dart] below. |
| 42 // | 42 // |
| 43 // TODO(ahe): This is only used with the option --compile-sdk, and | 43 // TODO(ahe): This is only used with the option --compile-sdk, and |
| 44 // currently doesn't work outside the SDK source tree. | 44 // currently doesn't work outside the SDK source tree. |
| 45 Map<String, Uri> dartLibraries = { | 45 Map<String, Uri> dartLibraries = <String, Uri>{}; |
| 46 "async": sdk.resolve("lib/async/async.dart"), | 46 if (sdk != null) { |
| 47 "_blink": sdk.resolve("lib/_blink/dartium/_blink_dartium.dart"), | 47 dartLibraries = <String, Uri>{ |
| 48 "_chrome": sdk.resolve("lib/_chrome/dart2js/chrome_dart2js.dart"), | 48 "async": sdk.resolve("lib/async/async.dart"), |
| 49 "collection": sdk.resolve("lib/collection/collection.dart"), | 49 "_blink": sdk.resolve("lib/_blink/dartium/_blink_dartium.dart"), |
| 50 "convert": sdk.resolve("lib/convert/convert.dart"), | 50 "_chrome": sdk.resolve("lib/_chrome/dart2js/chrome_dart2js.dart"), |
| 51 "core": sdk.resolve("lib/core/core.dart"), | 51 "collection": sdk.resolve("lib/collection/collection.dart"), |
| 52 "developer": sdk.resolve("lib/developer/developer.dart"), | 52 "convert": sdk.resolve("lib/convert/convert.dart"), |
| 53 "html": sdk.resolve("lib/html/dartium/html_dartium.dart"), | 53 "core": sdk.resolve("lib/core/core.dart"), |
| 54 "html_common": sdk.resolve("lib/html/html_common/html_common.dart"), | 54 "developer": sdk.resolve("lib/developer/developer.dart"), |
| 55 "indexed_db": | 55 "html": sdk.resolve("lib/html/dartium/html_dartium.dart"), |
| 56 sdk.resolve("lib/indexed_db/dartium/indexed_db_dartium.dart"), | 56 "html_common": sdk.resolve("lib/html/html_common/html_common.dart"), |
| 57 "io": sdk.resolve("lib/io/io.dart"), | 57 "indexed_db": |
| 58 "isolate": sdk.resolve("lib/isolate/isolate.dart"), | 58 sdk.resolve("lib/indexed_db/dartium/indexed_db_dartium.dart"), |
| 59 "js": sdk.resolve("lib/js/dartium/js_dartium.dart"), | 59 "io": sdk.resolve("lib/io/io.dart"), |
| 60 "js_util": sdk.resolve("lib/js_util/dartium/js_util_dartium.dart"), | 60 "isolate": sdk.resolve("lib/isolate/isolate.dart"), |
| 61 "math": sdk.resolve("lib/math/math.dart"), | 61 "js": sdk.resolve("lib/js/dartium/js_dartium.dart"), |
| 62 "mirrors": sdk.resolve("lib/mirrors/mirrors.dart"), | 62 "js_util": sdk.resolve("lib/js_util/dartium/js_util_dartium.dart"), |
| 63 "nativewrappers": sdk.resolve("lib/html/dartium/nativewrappers.dart"), | 63 "math": sdk.resolve("lib/math/math.dart"), |
| 64 "typed_data": sdk.resolve("lib/typed_data/typed_data.dart"), | 64 "mirrors": sdk.resolve("lib/mirrors/mirrors.dart"), |
| 65 "svg": sdk.resolve("lib/svg/dartium/svg_dartium.dart"), | 65 "nativewrappers": sdk.resolve("lib/html/dartium/nativewrappers.dart"), |
| 66 "web_audio": sdk.resolve("lib/web_audio/dartium/web_audio_dartium.dart"), | 66 "typed_data": sdk.resolve("lib/typed_data/typed_data.dart"), |
| 67 "web_gl": sdk.resolve("lib/web_gl/dartium/web_gl_dartium.dart"), | 67 "svg": sdk.resolve("lib/svg/dartium/svg_dartium.dart"), |
| 68 "web_sql": sdk.resolve("lib/web_sql/dartium/web_sql_dartium.dart"), | 68 "web_audio": sdk.resolve("lib/web_audio/dartium/web_audio_dartium.dart")
, |
| 69 "_internal": sdk.resolve("lib/internal/internal.dart"), | 69 "web_gl": sdk.resolve("lib/web_gl/dartium/web_gl_dartium.dart"), |
| 70 "profiler": sdk.resolve("lib/profiler/profiler.dart"), | 70 "web_sql": sdk.resolve("lib/web_sql/dartium/web_sql_dartium.dart"), |
| 71 "vmservice_io": sdk.resolve("lib/vmservice_io/vmservice_io.dart"), | 71 "_internal": sdk.resolve("lib/internal/internal.dart"), |
| 72 "_vmservice": sdk.resolve("lib/vmservice/vmservice.dart"), | 72 "profiler": sdk.resolve("lib/profiler/profiler.dart"), |
| 73 "_builtin": sdk.resolve("lib/_builtin/_builtin.dart"), | 73 "vmservice_io": sdk.resolve("lib/vmservice_io/vmservice_io.dart"), |
| 74 }; | 74 "_vmservice": sdk.resolve("lib/vmservice/vmservice.dart"), |
| 75 "_builtin": sdk.resolve("lib/_builtin/_builtin.dart"), |
| 76 }; |
| 77 } |
| 75 uri ??= Uri.base.resolve(".packages"); | 78 uri ??= Uri.base.resolve(".packages"); |
| 76 File file = new File.fromUri(uri); | 79 File file = new File.fromUri(uri); |
| 77 List<int> bytes = await file.readAsBytes(); | 80 List<int> bytes = await file.readAsBytes(); |
| 78 Map<String, Uri> packages = packages_file.parse(bytes, uri); | 81 Map<String, Uri> packages = packages_file.parse(bytes, uri); |
| 79 return new TranslateUri(packages, dartLibraries); | 82 return new TranslateUri(packages, dartLibraries); |
| 80 } | 83 } |
| 81 } | 84 } |
| OLD | NEW |