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

Side by Side Diff: runtime/bin/builtin.dart

Issue 16019002: Merge the dart:uri library into dart:core and update the Uri class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final cleanup Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « pkg/webdriver/lib/webdriver.dart ('k') | runtime/bin/dartutils.cc » ('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) 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';
7 6
8 // Corelib 'print' implementation. 7 // Corelib 'print' implementation.
9 void _print(arg) { 8 void _print(arg) {
10 _Logger._printString(arg.toString()); 9 _Logger._printString(arg.toString());
11 } 10 }
12 11
13 class _Logger { 12 class _Logger {
14 static void _printString(String s) native "Logger_PrintString"; 13 static void _printString(String s) native "Logger_PrintString";
15 } 14 }
16 15
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 _logResolution("## cwd: $cwd"); 50 _logResolution("## cwd: $cwd");
52 if ((scriptName.length > 2) && (scriptName[1] == ":")) { 51 if ((scriptName.length > 2) && (scriptName[1] == ":")) {
53 // This is an absolute path. 52 // This is an absolute path.
54 scriptName = "/${scriptName.replaceAll('\\', '/')}"; 53 scriptName = "/${scriptName.replaceAll('\\', '/')}";
55 } else { 54 } else {
56 scriptName = scriptName.replaceAll('\\', '/'); 55 scriptName = scriptName.replaceAll('\\', '/');
57 } 56 }
58 _logResolution("## scriptName: $scriptName"); 57 _logResolution("## scriptName: $scriptName");
59 } 58 }
60 var base = 59 var base =
61 new Uri.fromComponents( 60 new Uri(scheme: "file",
62 scheme: "file", 61 path: cwd.endsWith("/") ? cwd : "$cwd/");
63 path: cwd.endsWith("/") ? cwd : "$cwd/");
64 _entrypoint = base.resolve(scriptName); 62 _entrypoint = base.resolve(scriptName);
65 _logResolution("# Resolved script to: $_entrypoint"); 63 _logResolution("# Resolved script to: $_entrypoint");
66 64
67 return _entrypoint.toString(); 65 return _entrypoint.toString();
68 } 66 }
69 67
70 String _resolveUri(String base, String userString) { 68 String _resolveUri(String base, String userString) {
71 var baseUri = Uri.parse(base); 69 var baseUri = Uri.parse(base);
72 _logResolution("# Resolving: $userString from $base"); 70 _logResolution("# Resolving: $userString from $base");
73 71
74 var uri = Uri.parse(userString); 72 var uri = Uri.parse(userString);
75 var resolved; 73 var resolved;
76 if ('dart-ext' == uri.scheme) { 74 if ('dart-ext' == uri.scheme) {
77 // Relative URIs with scheme dart-ext should be resolved as if with no 75 // Relative URIs with scheme dart-ext should be resolved as if with no
78 // scheme. 76 // scheme.
79 resolved = baseUri.resolve(uri.path); 77 resolved = baseUri.resolve(uri.path);
80 var path = resolved.path; 78 var path = resolved.path;
81 if (resolved.scheme == 'package') { 79 if (resolved.scheme == 'package') {
82 // If we are resolving relative to a package URI we go directly to the 80 // 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 81 // file path and keep the dart-ext scheme. Otherwise, we will lose the
84 // package URI path part. 82 // package URI path part.
85 path = _filePathFromPackageUri(resolved); 83 path = _filePathFromPackageUri(resolved);
86 } 84 }
87 resolved = new Uri.fromComponents(scheme: "dart-ext", path: path); 85 resolved = new Uri(scheme: "dart-ext", path: path);
88 } else { 86 } else {
89 resolved = baseUri.resolve(userString); 87 resolved = baseUri.resolve(userString);
90 } 88 }
91 _logResolution("# Resolved to: $resolved"); 89 _logResolution("# Resolved to: $resolved");
92 return resolved.toString(); 90 return resolved.toString();
93 } 91 }
94 92
95 93
96 String _filePathFromUri(String userUri, bool isWindows) { 94 String _filePathFromUri(String userUri, bool isWindows) {
97 var uri = Uri.parse(userUri); 95 var uri = Uri.parse(userUri);
(...skipping 22 matching lines...) Expand all
120 // 118 //
121 // Drop the leading / before the drive letter. 119 // Drop the leading / before the drive letter.
122 path = path.substring(1); 120 path = path.substring(1);
123 _logResolution("# path: $path"); 121 _logResolution("# path: $path");
124 } 122 }
125 123
126 return path; 124 return path;
127 } 125 }
128 126
129 String _filePathFromFileUri(Uri uri) { 127 String _filePathFromFileUri(Uri uri) {
130 if (uri.domain != '') { 128 if (!uri.host.isEmpty) {
131 throw "URIs using the 'file:' scheme may not contain a domain."; 129 throw "URIs using the 'file:' scheme may not contain a host.";
132 } 130 }
133 131
134 _logResolution("# Path: ${uri.path}"); 132 _logResolution("# Path: ${uri.path}");
135 return uri.path; 133 return uri.path;
136 } 134 }
137 135
138 String _filePathFromOtherUri(Uri uri) { 136 String _filePathFromOtherUri(Uri uri) {
139 if (uri.domain != '') { 137 if (!uri.host.isEmpty) {
140 throw "URIs whose paths are used as file paths may not contain a domain."; 138 throw "URIs whose paths are used as file paths may not contain a host.";
141 } 139 }
142 140
143 _logResolution("# Path: ${uri.path}"); 141 _logResolution("# Path: ${uri.path}");
144 return uri.path; 142 return uri.path;
145 } 143 }
146 144
147 String _filePathFromPackageUri(Uri uri) { 145 String _filePathFromPackageUri(Uri uri) {
148 if (uri.domain != '') { 146 if (!uri.host.isEmpty) {
149 var path = (uri.path != '') ? '${uri.domain}${uri.path}' : uri.domain; 147 var path = (uri.path != '') ? '${uri.host}${uri.path}' : uri.host;
150 var right = 'package:$path'; 148 var right = 'package:$path';
151 var wrong = 'package://$path'; 149 var wrong = 'package://$path';
152 150
153 throw "URIs using the 'package:' scheme should look like " 151 throw "URIs using the 'package:' scheme should look like "
154 "'$right', not '$wrong'."; 152 "'$right', not '$wrong'.";
155 } 153 }
156 154
157 var path; 155 var path;
158 if (_packageRoot != null) { 156 if (_packageRoot != null) {
159 path = "${_packageRoot}${uri.path}"; 157 path = "${_packageRoot}${uri.path}";
160 } else { 158 } else {
161 path = _entrypoint.resolve('packages/${uri.path}').path; 159 path = _entrypoint.resolve('packages/${uri.path}').path;
162 } 160 }
163 161
164 _logResolution("# Package: $path"); 162 _logResolution("# Package: $path");
165 return path; 163 return path;
166 } 164 }
OLDNEW
« no previous file with comments | « pkg/webdriver/lib/webdriver.dart ('k') | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698