OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 builtin; | 5 library builtin; |
6 import 'dart:uri'; | 6 import 'dart:uri'; |
7 | 7 |
8 // Corelib 'print' implementation. | 8 // Corelib 'print' implementation. |
9 void _print(arg) { | 9 void _print(arg) { |
10 _Logger._printString(arg.toString()); | 10 _Logger._printString(arg.toString()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 new Uri.fromComponents( | 61 new Uri.fromComponents( |
62 scheme: "file", | 62 scheme: "file", |
63 path: cwd.endsWith("/") ? cwd : "$cwd/"); | 63 path: cwd.endsWith("/") ? cwd : "$cwd/"); |
64 _entrypoint = base.resolve(scriptName); | 64 _entrypoint = base.resolve(scriptName); |
65 _logResolution("# Resolved script to: $_entrypoint"); | 65 _logResolution("# Resolved script to: $_entrypoint"); |
66 | 66 |
67 return _entrypoint.toString(); | 67 return _entrypoint.toString(); |
68 } | 68 } |
69 | 69 |
70 String _resolveUri(String base, String userString) { | 70 String _resolveUri(String base, String userString) { |
71 var baseUri = new Uri.fromString(base); | 71 var baseUri = Uri.parse(base); |
72 _logResolution("# Resolving: $userString from $base"); | 72 _logResolution("# Resolving: $userString from $base"); |
73 | 73 |
74 var uri = new Uri.fromString(userString); | 74 var uri = Uri.parse(userString); |
75 var resolved; | 75 var resolved; |
76 if ('dart-ext' == uri.scheme) { | 76 if ('dart-ext' == uri.scheme) { |
77 // Relative URIs with scheme dart-ext should be resolved as if with no | 77 // Relative URIs with scheme dart-ext should be resolved as if with no |
78 // scheme. | 78 // scheme. |
79 resolved = baseUri.resolve(uri.path); | 79 resolved = baseUri.resolve(uri.path); |
80 var path = resolved.path; | 80 var path = resolved.path; |
81 if (resolved.scheme == 'package') { | 81 if (resolved.scheme == 'package') { |
82 // If we are resolving relative to a package URI we go directly to the | 82 // If we are resolving relative to a package URI we go directly to the |
83 // file path and keep the dart-ext scheme. Otherwise, we will lose the | 83 // file path and keep the dart-ext scheme. Otherwise, we will lose the |
84 // package URI path part. | 84 // package URI path part. |
85 path = _filePathFromPackageUri(resolved); | 85 path = _filePathFromPackageUri(resolved); |
86 } | 86 } |
87 resolved = new Uri.fromComponents(scheme: "dart-ext", path: path); | 87 resolved = new Uri.fromComponents(scheme: "dart-ext", path: path); |
88 } else { | 88 } else { |
89 resolved = baseUri.resolve(userString); | 89 resolved = baseUri.resolve(userString); |
90 } | 90 } |
91 _logResolution("# Resolved to: $resolved"); | 91 _logResolution("# Resolved to: $resolved"); |
92 return resolved.toString(); | 92 return resolved.toString(); |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 String _filePathFromUri(String userUri, bool isWindows) { | 96 String _filePathFromUri(String userUri, bool isWindows) { |
97 var uri = new Uri.fromString(userUri); | 97 var uri = Uri.parse(userUri); |
98 _logResolution("# Getting file path from: $uri"); | 98 _logResolution("# Getting file path from: $uri"); |
99 | 99 |
100 var path; | 100 var path; |
101 switch (uri.scheme) { | 101 switch (uri.scheme) { |
102 case 'file': | 102 case 'file': |
103 path = _filePathFromFileUri(uri); | 103 path = _filePathFromFileUri(uri); |
104 break; | 104 break; |
105 case 'dart-ext': | 105 case 'dart-ext': |
106 path = _filePathFromOtherUri(uri); | 106 path = _filePathFromOtherUri(uri); |
107 break; | 107 break; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 var path; | 157 var path; |
158 if (_packageRoot != null) { | 158 if (_packageRoot != null) { |
159 path = "${_packageRoot}${uri.path}"; | 159 path = "${_packageRoot}${uri.path}"; |
160 } else { | 160 } else { |
161 path = _entrypoint.resolve('packages/${uri.path}').path; | 161 path = _entrypoint.resolve('packages/${uri.path}').path; |
162 } | 162 } |
163 | 163 |
164 _logResolution("# Package: $path"); | 164 _logResolution("# Package: $path"); |
165 return path; | 165 return path; |
166 } | 166 } |
OLD | NEW |