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

Side by Side Diff: test/codegen_expected/path/path.js

Issue 2234343003: fix #620, infer the input files from sources (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: fix 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
OLDNEW
(Empty)
1 dart_library.library('path', null, /* Imports */[
2 'dart_sdk'
3 ], function load__path(exports, dart_sdk) {
4 'use strict';
5 const core = dart_sdk.core;
6 const _interceptors = dart_sdk._interceptors;
7 const dart = dart_sdk.dart;
8 const dartx = dart_sdk.dartx;
9 const path$ = Object.create(null);
10 const src__characters = Object.create(null);
11 const src__context = Object.create(null);
12 const src__internal_style = Object.create(null);
13 const src__parsed_path = Object.create(null);
14 const src__path_exception = Object.create(null);
15 const src__style__posix = Object.create(null);
16 const src__style__url = Object.create(null);
17 const src__style__windows = Object.create(null);
18 const src__style = Object.create(null);
19 const src__utils = Object.create(null);
20 let IterableOfString = () => (IterableOfString = dart.constFn(core.Iterable$(c ore.String)))();
21 let ListOfString = () => (ListOfString = dart.constFn(core.List$(core.String)) )();
22 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr ray$(core.String)))();
23 let String__ToString = () => (String__ToString = dart.constFn(dart.definiteFun ctionType(core.String, [core.String], [core.String, core.String, core.String, co re.String, core.String, core.String])))();
24 let StringToString = () => (StringToString = dart.constFn(dart.definiteFunctio nType(core.String, [core.String])))();
25 let StringTobool = () => (StringTobool = dart.constFn(dart.definiteFunctionTyp e(core.bool, [core.String])))();
26 let String__ToString$ = () => (String__ToString$ = dart.constFn(dart.definiteF unctionType(core.String, [core.String], [core.String, core.String, core.String, core.String, core.String, core.String, core.String])))();
27 let IterableOfStringToString = () => (IterableOfStringToString = dart.constFn( dart.definiteFunctionType(core.String, [IterableOfString()])))();
28 let StringToListOfString = () => (StringToListOfString = dart.constFn(dart.def initeFunctionType(ListOfString(), [core.String])))();
29 let String__ToString$0 = () => (String__ToString$0 = dart.constFn(dart.definit eFunctionType(core.String, [core.String], {from: core.String})))();
30 let StringAndStringTobool = () => (StringAndStringTobool = dart.constFn(dart.d efiniteFunctionType(core.bool, [core.String, core.String])))();
31 let dynamicToString = () => (dynamicToString = dart.constFn(dart.definiteFunct ionType(core.String, [dart.dynamic])))();
32 let StringToUri = () => (StringToUri = dart.constFn(dart.definiteFunctionType( core.Uri, [core.String])))();
33 let VoidToContext = () => (VoidToContext = dart.constFn(dart.definiteFunctionT ype(src__context.Context, [])))();
34 let StringAndListOfStringTodynamic = () => (StringAndListOfStringTodynamic = d art.constFn(dart.definiteFunctionType(dart.dynamic, [core.String, ListOfString() ])))();
35 let intToString = () => (intToString = dart.constFn(dart.definiteFunctionType( core.String, [core.int])))();
36 let VoidToString = () => (VoidToString = dart.constFn(dart.definiteFunctionTyp e(core.String, [])))();
37 let intTobool = () => (intTobool = dart.constFn(dart.definiteFunctionType(core .bool, [core.int])))();
38 dart.defineLazy(path$, {
39 get posix() {
40 return src__context.Context.new({style: src__style.Style.posix});
41 }
42 });
43 dart.defineLazy(path$, {
44 get windows() {
45 return src__context.Context.new({style: src__style.Style.windows});
46 }
47 });
48 dart.defineLazy(path$, {
49 get url() {
50 return src__context.Context.new({style: src__style.Style.url});
51 }
52 });
53 dart.defineLazy(path$, {
54 get context() {
55 return src__context.createInternal();
56 }
57 });
58 dart.copyProperties(path$, {
59 get style() {
60 return path$.context.style;
61 }
62 });
63 dart.copyProperties(path$, {
64 get current() {
65 let uri = core.Uri.base;
66 if (dart.equals(uri, path$._currentUriBase)) return path$._current;
67 path$._currentUriBase = uri;
68 if (dart.equals(src__style.Style.platform, src__style.Style.url)) {
69 path$._current = dart.toString(uri.resolve('.'));
70 return path$._current;
71 } else {
72 let path = uri.toFilePath();
73 let lastIndex = dart.notNull(path[dartx.length]) - 1;
74 dart.assert(path[dartx.get](lastIndex) == '/' || path[dartx.get](lastInd ex) == '\\');
75 path$._current = path[dartx.substring](0, lastIndex);
76 return path$._current;
77 }
78 }
79 });
80 path$._currentUriBase = null;
81 path$._current = null;
82 dart.copyProperties(path$, {
83 get separator() {
84 return path$.context.separator;
85 }
86 });
87 path$.absolute = function(part1, part2, part3, part4, part5, part6, part7) {
88 if (part2 === void 0) part2 = null;
89 if (part3 === void 0) part3 = null;
90 if (part4 === void 0) part4 = null;
91 if (part5 === void 0) part5 = null;
92 if (part6 === void 0) part6 = null;
93 if (part7 === void 0) part7 = null;
94 return path$.context.absolute(part1, part2, part3, part4, part5, part6, part 7);
95 };
96 dart.fn(path$.absolute, String__ToString());
97 path$.basename = function(path) {
98 return path$.context.basename(path);
99 };
100 dart.fn(path$.basename, StringToString());
101 path$.basenameWithoutExtension = function(path) {
102 return path$.context.basenameWithoutExtension(path);
103 };
104 dart.fn(path$.basenameWithoutExtension, StringToString());
105 path$.dirname = function(path) {
106 return path$.context.dirname(path);
107 };
108 dart.fn(path$.dirname, StringToString());
109 path$.extension = function(path) {
110 return path$.context.extension(path);
111 };
112 dart.fn(path$.extension, StringToString());
113 path$.rootPrefix = function(path) {
114 return path$.context.rootPrefix(path);
115 };
116 dart.fn(path$.rootPrefix, StringToString());
117 path$.isAbsolute = function(path) {
118 return path$.context.isAbsolute(path);
119 };
120 dart.fn(path$.isAbsolute, StringTobool());
121 path$.isRelative = function(path) {
122 return path$.context.isRelative(path);
123 };
124 dart.fn(path$.isRelative, StringTobool());
125 path$.isRootRelative = function(path) {
126 return path$.context.isRootRelative(path);
127 };
128 dart.fn(path$.isRootRelative, StringTobool());
129 path$.join = function(part1, part2, part3, part4, part5, part6, part7, part8) {
130 if (part2 === void 0) part2 = null;
131 if (part3 === void 0) part3 = null;
132 if (part4 === void 0) part4 = null;
133 if (part5 === void 0) part5 = null;
134 if (part6 === void 0) part6 = null;
135 if (part7 === void 0) part7 = null;
136 if (part8 === void 0) part8 = null;
137 return path$.context.join(part1, part2, part3, part4, part5, part6, part7, p art8);
138 };
139 dart.fn(path$.join, String__ToString$());
140 path$.joinAll = function(parts) {
141 return path$.context.joinAll(parts);
142 };
143 dart.fn(path$.joinAll, IterableOfStringToString());
144 path$.split = function(path) {
145 return path$.context.split(path);
146 };
147 dart.fn(path$.split, StringToListOfString());
148 path$.normalize = function(path) {
149 return path$.context.normalize(path);
150 };
151 dart.fn(path$.normalize, StringToString());
152 path$.relative = function(path, opts) {
153 let from = opts && 'from' in opts ? opts.from : null;
154 return path$.context.relative(path, {from: from});
155 };
156 dart.fn(path$.relative, String__ToString$0());
157 path$.isWithin = function(parent, child) {
158 return path$.context.isWithin(parent, child);
159 };
160 dart.fn(path$.isWithin, StringAndStringTobool());
161 path$.withoutExtension = function(path) {
162 return path$.context.withoutExtension(path);
163 };
164 dart.fn(path$.withoutExtension, StringToString());
165 path$.fromUri = function(uri) {
166 return path$.context.fromUri(uri);
167 };
168 dart.fn(path$.fromUri, dynamicToString());
169 path$.toUri = function(path) {
170 return path$.context.toUri(path);
171 };
172 dart.fn(path$.toUri, StringToUri());
173 path$.prettyUri = function(uri) {
174 return path$.context.prettyUri(uri);
175 };
176 dart.fn(path$.prettyUri, dynamicToString());
177 const _current = Symbol('_current');
178 const _parse = Symbol('_parse');
179 const _needsNormalization = Symbol('_needsNormalization');
180 const _isWithinFast = Symbol('_isWithinFast');
181 const _pathDirection = Symbol('_pathDirection');
182 src__context.Context = class Context extends core.Object {
183 static new(opts) {
184 let style = opts && 'style' in opts ? opts.style : null;
185 let current = opts && 'current' in opts ? opts.current : null;
186 if (current == null) {
187 if (style == null) {
188 current = path$.current;
189 } else {
190 current = ".";
191 }
192 }
193 if (style == null) {
194 style = src__style.Style.platform;
195 } else if (!src__internal_style.InternalStyle.is(style)) {
196 dart.throw(new core.ArgumentError("Only styles defined by the path packa ge are " + "allowed."));
197 }
198 return new src__context.Context._(src__internal_style.InternalStyle.as(sty le), current);
199 }
200 _internal() {
201 this.style = src__internal_style.InternalStyle.as(src__style.Style.platfor m);
202 this[_current] = null;
203 }
204 _(style, current) {
205 this.style = style;
206 this[_current] = current;
207 }
208 get current() {
209 return this[_current] != null ? this[_current] : path$.current;
210 }
211 get separator() {
212 return this.style.separator;
213 }
214 absolute(part1, part2, part3, part4, part5, part6, part7) {
215 if (part2 === void 0) part2 = null;
216 if (part3 === void 0) part3 = null;
217 if (part4 === void 0) part4 = null;
218 if (part5 === void 0) part5 = null;
219 if (part6 === void 0) part6 = null;
220 if (part7 === void 0) part7 = null;
221 src__context._validateArgList("absolute", JSArrayOfString().of([part1, par t2, part3, part4, part5, part6, part7]));
222 if (part2 == null && dart.test(this.isAbsolute(part1)) && !dart.test(this. isRootRelative(part1))) {
223 return part1;
224 }
225 return this.join(this.current, part1, part2, part3, part4, part5, part6, p art7);
226 }
227 basename(path) {
228 return this[_parse](path).basename;
229 }
230 basenameWithoutExtension(path) {
231 return this[_parse](path).basenameWithoutExtension;
232 }
233 dirname(path) {
234 let parsed = this[_parse](path);
235 parsed.removeTrailingSeparators();
236 if (dart.test(parsed.parts[dartx.isEmpty])) return parsed.root == null ? ' .' : parsed.root;
237 if (parsed.parts[dartx.length] == 1) {
238 return parsed.root == null ? '.' : parsed.root;
239 }
240 parsed.parts[dartx.removeLast]();
241 parsed.separators[dartx.removeLast]();
242 parsed.removeTrailingSeparators();
243 return dart.toString(parsed);
244 }
245 extension(path) {
246 return this[_parse](path).extension;
247 }
248 rootPrefix(path) {
249 return path[dartx.substring](0, this.style.rootLength(path));
250 }
251 isAbsolute(path) {
252 return dart.notNull(this.style.rootLength(path)) > 0;
253 }
254 isRelative(path) {
255 return !dart.test(this.isAbsolute(path));
256 }
257 isRootRelative(path) {
258 return this.style.isRootRelative(path);
259 }
260 join(part1, part2, part3, part4, part5, part6, part7, part8) {
261 if (part2 === void 0) part2 = null;
262 if (part3 === void 0) part3 = null;
263 if (part4 === void 0) part4 = null;
264 if (part5 === void 0) part5 = null;
265 if (part6 === void 0) part6 = null;
266 if (part7 === void 0) part7 = null;
267 if (part8 === void 0) part8 = null;
268 let parts = JSArrayOfString().of([part1, part2, part3, part4, part5, part6 , part7, part8]);
269 src__context._validateArgList("join", parts);
270 return this.joinAll(parts[dartx.where](dart.fn(part => part != null, Strin gTobool())));
271 }
272 joinAll(parts) {
273 let buffer = new core.StringBuffer();
274 let needsSeparator = false;
275 let isAbsoluteAndNotRootRelative = false;
276 for (let part of parts[dartx.where](dart.fn(part => part != '', StringTobo ol()))) {
277 if (dart.test(this.isRootRelative(part)) && isAbsoluteAndNotRootRelative ) {
278 let parsed = this[_parse](part);
279 parsed.root = this.rootPrefix(buffer.toString());
280 if (dart.test(this.style.needsSeparator(parsed.root))) {
281 parsed.separators[dartx.set](0, this.style.separator);
282 }
283 buffer.clear();
284 buffer.write(dart.toString(parsed));
285 } else if (dart.test(this.isAbsolute(part))) {
286 isAbsoluteAndNotRootRelative = !dart.test(this.isRootRelative(part));
287 buffer.clear();
288 buffer.write(part);
289 } else {
290 if (dart.notNull(part[dartx.length]) > 0 && dart.test(this.style.conta insSeparator(part[dartx.get](0)))) {
291 } else if (dart.test(needsSeparator)) {
292 buffer.write(this.separator);
293 }
294 buffer.write(part);
295 }
296 needsSeparator = this.style.needsSeparator(part);
297 }
298 return buffer.toString();
299 }
300 split(path) {
301 let parsed = this[_parse](path);
302 parsed.parts = parsed.parts[dartx.where](dart.fn(part => !dart.test(part[d artx.isEmpty]), StringTobool()))[dartx.toList]();
303 if (parsed.root != null) parsed.parts[dartx.insert](0, parsed.root);
304 return parsed.parts;
305 }
306 normalize(path) {
307 if (!dart.test(this[_needsNormalization](path))) return path;
308 let parsed = this[_parse](path);
309 parsed.normalize();
310 return dart.toString(parsed);
311 }
312 [_needsNormalization](path) {
313 let start = 0;
314 let codeUnits = path[dartx.codeUnits];
315 let previousPrevious = null;
316 let previous = null;
317 let root = this.style.rootLength(path);
318 if (root != 0) {
319 start = root;
320 previous = src__characters.SLASH;
321 if (dart.equals(this.style, src__style.Style.windows)) {
322 for (let i = 0; i < dart.notNull(root); i++) {
323 if (codeUnits[dartx.get](i) == src__characters.SLASH) return true;
324 }
325 }
326 }
327 for (let i = start; dart.notNull(i) < dart.notNull(codeUnits[dartx.length] ); i = dart.notNull(i) + 1) {
328 let codeUnit = codeUnits[dartx.get](i);
329 if (dart.test(this.style.isSeparator(codeUnit))) {
330 if (dart.equals(this.style, src__style.Style.windows) && codeUnit == s rc__characters.SLASH) return true;
331 if (previous != null && dart.test(this.style.isSeparator(core.int._che ck(previous)))) return true;
332 if (dart.equals(previous, src__characters.PERIOD) && (previousPrevious == null || dart.equals(previousPrevious, src__characters.PERIOD) || dart.test(t his.style.isSeparator(core.int._check(previousPrevious))))) {
333 return true;
334 }
335 }
336 previousPrevious = previous;
337 previous = codeUnit;
338 }
339 if (previous == null) return true;
340 if (dart.test(this.style.isSeparator(core.int._check(previous)))) return t rue;
341 if (dart.equals(previous, src__characters.PERIOD) && (previousPrevious == null || dart.equals(previousPrevious, src__characters.SLASH) || dart.equals(prev iousPrevious, src__characters.PERIOD))) {
342 return true;
343 }
344 return false;
345 }
346 relative(path, opts) {
347 let from = opts && 'from' in opts ? opts.from : null;
348 if (from == null && dart.test(this.isRelative(path))) return this.normaliz e(path);
349 from = from == null ? this.current : this.absolute(from);
350 if (dart.test(this.isRelative(from)) && dart.test(this.isAbsolute(path))) {
351 return this.normalize(path);
352 }
353 if (dart.test(this.isRelative(path)) || dart.test(this.isRootRelative(path ))) {
354 path = this.absolute(path);
355 }
356 if (dart.test(this.isRelative(path)) && dart.test(this.isAbsolute(from))) {
357 dart.throw(new src__path_exception.PathException(dart.str`Unable to find a path to "${path}" from "${from}".`));
358 }
359 let fromParsed = this[_parse](from);
360 fromParsed.normalize();
361 let pathParsed = this[_parse](path);
362 pathParsed.normalize();
363 if (dart.notNull(fromParsed.parts[dartx.length]) > 0 && fromParsed.parts[d artx.get](0) == '.') {
364 return pathParsed.toString();
365 }
366 if (fromParsed.root != pathParsed.root && (fromParsed.root == null || path Parsed.root == null || fromParsed.root[dartx.toLowerCase]()[dartx.replaceAll]('/ ', '\\') != pathParsed.root[dartx.toLowerCase]()[dartx.replaceAll]('/', '\\'))) {
367 return pathParsed.toString();
368 }
369 while (dart.notNull(fromParsed.parts[dartx.length]) > 0 && dart.notNull(pa thParsed.parts[dartx.length]) > 0 && fromParsed.parts[dartx.get](0) == pathParse d.parts[dartx.get](0)) {
370 fromParsed.parts[dartx.removeAt](0);
371 fromParsed.separators[dartx.removeAt](1);
372 pathParsed.parts[dartx.removeAt](0);
373 pathParsed.separators[dartx.removeAt](1);
374 }
375 if (dart.notNull(fromParsed.parts[dartx.length]) > 0 && fromParsed.parts[d artx.get](0) == '..') {
376 dart.throw(new src__path_exception.PathException(dart.str`Unable to find a path to "${path}" from "${from}".`));
377 }
378 pathParsed.parts[dartx.insertAll](0, ListOfString().filled(fromParsed.part s[dartx.length], '..'));
379 pathParsed.separators[dartx.set](0, '');
380 pathParsed.separators[dartx.insertAll](1, ListOfString().filled(fromParsed .parts[dartx.length], this.style.separator));
381 if (pathParsed.parts[dartx.length] == 0) return '.';
382 if (dart.notNull(pathParsed.parts[dartx.length]) > 1 && pathParsed.parts[d artx.last] == '.') {
383 pathParsed.parts[dartx.removeLast]();
384 let _ = pathParsed.separators;
385 _[dartx.removeLast]();
386 _[dartx.removeLast]();
387 _[dartx.add]('');
388 }
389 pathParsed.root = '';
390 pathParsed.removeTrailingSeparators();
391 return pathParsed.toString();
392 }
393 isWithin(parent, child) {
394 let parentIsAbsolute = this.isAbsolute(parent);
395 let childIsAbsolute = this.isAbsolute(child);
396 if (dart.test(parentIsAbsolute) && !dart.test(childIsAbsolute)) {
397 child = this.absolute(child);
398 if (dart.test(this.style.isRootRelative(parent))) parent = this.absolute (parent);
399 } else if (dart.test(childIsAbsolute) && !dart.test(parentIsAbsolute)) {
400 parent = this.absolute(parent);
401 if (dart.test(this.style.isRootRelative(child))) child = this.absolute(c hild);
402 } else if (dart.test(childIsAbsolute) && dart.test(parentIsAbsolute)) {
403 let childIsRootRelative = this.style.isRootRelative(child);
404 let parentIsRootRelative = this.style.isRootRelative(parent);
405 if (dart.test(childIsRootRelative) && !dart.test(parentIsRootRelative)) {
406 child = this.absolute(child);
407 } else if (dart.test(parentIsRootRelative) && !dart.test(childIsRootRela tive)) {
408 parent = this.absolute(parent);
409 }
410 }
411 let fastResult = this[_isWithinFast](parent, child);
412 if (fastResult != null) return fastResult;
413 let relative = null;
414 try {
415 relative = this.relative(child, {from: parent});
416 } catch (_) {
417 if (src__path_exception.PathException.is(_)) {
418 return false;
419 } else
420 throw _;
421 }
422
423 let parts = this.split(core.String._check(relative));
424 return dart.test(this.isRelative(core.String._check(relative))) && parts[d artx.first] != '..' && parts[dartx.first] != '.';
425 }
426 [_isWithinFast](parent, child) {
427 if (parent == '.') parent = '';
428 let parentRootLength = this.style.rootLength(parent);
429 let childRootLength = this.style.rootLength(child);
430 if (parentRootLength != childRootLength) return false;
431 let parentCodeUnits = parent[dartx.codeUnits];
432 let childCodeUnits = child[dartx.codeUnits];
433 for (let i = 0; i < dart.notNull(parentRootLength); i++) {
434 let parentCodeUnit = parentCodeUnits[dartx.get](i);
435 let childCodeUnit = childCodeUnits[dartx.get](i);
436 if (parentCodeUnit == childCodeUnit) continue;
437 if (!dart.test(this.style.isSeparator(parentCodeUnit)) || !dart.test(thi s.style.isSeparator(childCodeUnit))) {
438 return false;
439 }
440 }
441 let lastCodeUnit = src__characters.SLASH;
442 let parentIndex = parentRootLength;
443 let childIndex = childRootLength;
444 while (dart.notNull(parentIndex) < dart.notNull(parent[dartx.length]) && d art.notNull(childIndex) < dart.notNull(child[dartx.length])) {
445 let parentCodeUnit = parentCodeUnits[dartx.get](parentIndex);
446 let childCodeUnit = childCodeUnits[dartx.get](childIndex);
447 if (parentCodeUnit == childCodeUnit) {
448 lastCodeUnit = parentCodeUnit;
449 parentIndex = dart.notNull(parentIndex) + 1;
450 childIndex = dart.notNull(childIndex) + 1;
451 continue;
452 }
453 let parentIsSeparator = this.style.isSeparator(parentCodeUnit);
454 let childIsSeparator = this.style.isSeparator(childCodeUnit);
455 if (dart.test(parentIsSeparator) && dart.test(childIsSeparator)) {
456 lastCodeUnit = parentCodeUnit;
457 parentIndex = dart.notNull(parentIndex) + 1;
458 childIndex = dart.notNull(childIndex) + 1;
459 continue;
460 }
461 if (dart.test(parentIsSeparator) && dart.test(this.style.isSeparator(las tCodeUnit))) {
462 parentIndex = dart.notNull(parentIndex) + 1;
463 continue;
464 } else if (dart.test(childIsSeparator) && dart.test(this.style.isSeparat or(lastCodeUnit))) {
465 childIndex = dart.notNull(childIndex) + 1;
466 continue;
467 }
468 if (parentCodeUnit == src__characters.PERIOD) {
469 if (dart.test(this.style.isSeparator(lastCodeUnit))) {
470 parentIndex = dart.notNull(parentIndex) + 1;
471 if (parentIndex == parent[dartx.length]) break;
472 parentCodeUnit = parentCodeUnits[dartx.get](parentIndex);
473 if (dart.test(this.style.isSeparator(parentCodeUnit))) {
474 parentIndex = dart.notNull(parentIndex) + 1;
475 continue;
476 }
477 if (parentCodeUnit == src__characters.PERIOD) {
478 parentIndex = dart.notNull(parentIndex) + 1;
479 if (parentIndex == parent[dartx.length] || dart.test(this.style.is Separator(parentCodeUnits[dartx.get](parentIndex)))) {
480 return null;
481 }
482 }
483 }
484 }
485 if (childCodeUnit == src__characters.PERIOD) {
486 if (dart.test(this.style.isSeparator(lastCodeUnit))) {
487 childIndex = dart.notNull(childIndex) + 1;
488 if (childIndex == child[dartx.length]) break;
489 childCodeUnit = childCodeUnits[dartx.get](childIndex);
490 if (dart.test(this.style.isSeparator(childCodeUnit))) {
491 childIndex = dart.notNull(childIndex) + 1;
492 continue;
493 }
494 if (childCodeUnit == src__characters.PERIOD) {
495 childIndex = dart.notNull(childIndex) + 1;
496 if (childIndex == child[dartx.length] || dart.test(this.style.isSe parator(childCodeUnits[dartx.get](childIndex)))) {
497 return null;
498 }
499 }
500 }
501 }
502 let childDirection = this[_pathDirection](childCodeUnits, childIndex);
503 if (!dart.equals(childDirection, src__context._PathDirection.belowRoot)) return null;
504 let parentDirection = this[_pathDirection](parentCodeUnits, parentIndex) ;
505 if (!dart.equals(parentDirection, src__context._PathDirection.belowRoot) ) return null;
506 return false;
507 }
508 if (childIndex == child[dartx.length]) {
509 let direction = this[_pathDirection](parentCodeUnits, parentIndex);
510 return dart.equals(direction, src__context._PathDirection.aboveRoot) ? n ull : false;
511 }
512 let direction = this[_pathDirection](childCodeUnits, childIndex);
513 if (dart.equals(direction, src__context._PathDirection.atRoot)) return fal se;
514 if (dart.equals(direction, src__context._PathDirection.aboveRoot)) return null;
515 return dart.test(this.style.isSeparator(childCodeUnits[dartx.get](childInd ex))) || dart.test(this.style.isSeparator(lastCodeUnit));
516 }
517 [_pathDirection](codeUnits, index) {
518 let depth = 0;
519 let reachedRoot = false;
520 let i = index;
521 while (dart.notNull(i) < dart.notNull(codeUnits[dartx.length])) {
522 while (dart.notNull(i) < dart.notNull(codeUnits[dartx.length]) && dart.t est(this.style.isSeparator(codeUnits[dartx.get](i)))) {
523 i = dart.notNull(i) + 1;
524 }
525 if (i == codeUnits[dartx.length]) break;
526 let start = i;
527 while (dart.notNull(i) < dart.notNull(codeUnits[dartx.length]) && !dart. test(this.style.isSeparator(codeUnits[dartx.get](i)))) {
528 i = dart.notNull(i) + 1;
529 }
530 if (dart.notNull(i) - dart.notNull(start) == 1 && codeUnits[dartx.get](s tart) == src__characters.PERIOD) {
531 } else if (dart.notNull(i) - dart.notNull(start) == 2 && codeUnits[dartx .get](start) == src__characters.PERIOD && codeUnits[dartx.get](dart.notNull(star t) + 1) == src__characters.PERIOD) {
532 depth--;
533 if (depth < 0) break;
534 if (depth == 0) reachedRoot = true;
535 } else {
536 depth++;
537 }
538 if (i == codeUnits[dartx.length]) break;
539 i = dart.notNull(i) + 1;
540 }
541 if (depth < 0) return src__context._PathDirection.aboveRoot;
542 if (depth == 0) return src__context._PathDirection.atRoot;
543 if (reachedRoot) return src__context._PathDirection.reachesRoot;
544 return src__context._PathDirection.belowRoot;
545 }
546 withoutExtension(path) {
547 let parsed = this[_parse](path);
548 for (let i = dart.notNull(parsed.parts[dartx.length]) - 1; i >= 0; i--) {
549 if (!dart.test(parsed.parts[dartx.get](i)[dartx.isEmpty])) {
550 parsed.parts[dartx.set](i, parsed.basenameWithoutExtension);
551 break;
552 }
553 }
554 return dart.toString(parsed);
555 }
556 fromUri(uri) {
557 if (typeof uri == 'string') uri = core.Uri.parse(core.String._check(uri));
558 return this.style.pathFromUri(core.Uri._check(uri));
559 }
560 toUri(path) {
561 if (dart.test(this.isRelative(path))) {
562 return this.style.relativePathToUri(path);
563 } else {
564 return this.style.absolutePathToUri(this.join(this.current, path));
565 }
566 }
567 prettyUri(uri) {
568 if (typeof uri == 'string') uri = core.Uri.parse(core.String._check(uri));
569 if (dart.equals(dart.dload(uri, 'scheme'), 'file') && dart.equals(this.sty le, src__style.Style.url)) return dart.toString(uri);
570 if (!dart.equals(dart.dload(uri, 'scheme'), 'file') && !dart.equals(dart.d load(uri, 'scheme'), '') && !dart.equals(this.style, src__style.Style.url)) {
571 return dart.toString(uri);
572 }
573 let path = this.normalize(this.fromUri(uri));
574 let rel = this.relative(path);
575 return dart.notNull(this.split(rel)[dartx.length]) > dart.notNull(this.spl it(path)[dartx.length]) ? path : rel;
576 }
577 [_parse](path) {
578 return src__parsed_path.ParsedPath.parse(path, this.style);
579 }
580 };
581 dart.defineNamedConstructor(src__context.Context, '_internal');
582 dart.defineNamedConstructor(src__context.Context, '_');
583 dart.setSignature(src__context.Context, {
584 constructors: () => ({
585 new: dart.definiteFunctionType(src__context.Context, [], {style: src__styl e.Style, current: core.String}),
586 _internal: dart.definiteFunctionType(src__context.Context, []),
587 _: dart.definiteFunctionType(src__context.Context, [src__internal_style.In ternalStyle, core.String])
588 }),
589 methods: () => ({
590 absolute: dart.definiteFunctionType(core.String, [core.String], [core.Stri ng, core.String, core.String, core.String, core.String, core.String]),
591 basename: dart.definiteFunctionType(core.String, [core.String]),
592 basenameWithoutExtension: dart.definiteFunctionType(core.String, [core.Str ing]),
593 dirname: dart.definiteFunctionType(core.String, [core.String]),
594 extension: dart.definiteFunctionType(core.String, [core.String]),
595 rootPrefix: dart.definiteFunctionType(core.String, [core.String]),
596 isAbsolute: dart.definiteFunctionType(core.bool, [core.String]),
597 isRelative: dart.definiteFunctionType(core.bool, [core.String]),
598 isRootRelative: dart.definiteFunctionType(core.bool, [core.String]),
599 join: dart.definiteFunctionType(core.String, [core.String], [core.String, core.String, core.String, core.String, core.String, core.String, core.String]),
600 joinAll: dart.definiteFunctionType(core.String, [core.Iterable$(core.Strin g)]),
601 split: dart.definiteFunctionType(core.List$(core.String), [core.String]),
602 normalize: dart.definiteFunctionType(core.String, [core.String]),
603 [_needsNormalization]: dart.definiteFunctionType(core.bool, [core.String]) ,
604 relative: dart.definiteFunctionType(core.String, [core.String], {from: cor e.String}),
605 isWithin: dart.definiteFunctionType(core.bool, [core.String, core.String]) ,
606 [_isWithinFast]: dart.definiteFunctionType(core.bool, [core.String, core.S tring]),
607 [_pathDirection]: dart.definiteFunctionType(src__context._PathDirection, [ core.List$(core.int), core.int]),
608 withoutExtension: dart.definiteFunctionType(core.String, [core.String]),
609 fromUri: dart.definiteFunctionType(core.String, [dart.dynamic]),
610 toUri: dart.definiteFunctionType(core.Uri, [core.String]),
611 prettyUri: dart.definiteFunctionType(core.String, [dart.dynamic]),
612 [_parse]: dart.definiteFunctionType(src__parsed_path.ParsedPath, [core.Str ing])
613 })
614 });
615 path$.Context = src__context.Context;
616 src__path_exception.PathException = class PathException extends core.Object {
617 new(message) {
618 this.message = message;
619 }
620 toString() {
621 return dart.str`PathException: ${this.message}`;
622 }
623 };
624 src__path_exception.PathException[dart.implements] = () => [core.Exception];
625 dart.setSignature(src__path_exception.PathException, {
626 constructors: () => ({new: dart.definiteFunctionType(src__path_exception.Pat hException, [core.String])})
627 });
628 path$.PathException = src__path_exception.PathException;
629 src__style.Style = class Style extends core.Object {
630 static _getPlatformStyle() {
631 if (core.Uri.base.scheme != 'file') return src__style.Style.url;
632 if (!dart.test(core.Uri.base.path[dartx.endsWith]('/'))) return src__style .Style.url;
633 if (core.Uri.new({path: 'a/b'}).toFilePath() == 'a\\b') return src__style. Style.windows;
634 return src__style.Style.posix;
635 }
636 get context() {
637 return src__context.Context.new({style: this});
638 }
639 toString() {
640 return this.name;
641 }
642 };
643 dart.setSignature(src__style.Style, {
644 statics: () => ({_getPlatformStyle: dart.definiteFunctionType(src__style.Sty le, [])}),
645 names: ['_getPlatformStyle']
646 });
647 dart.defineLazy(src__style.Style, {
648 get posix() {
649 return new src__style__posix.PosixStyle();
650 },
651 get windows() {
652 return new src__style__windows.WindowsStyle();
653 },
654 get url() {
655 return new src__style__url.UrlStyle();
656 },
657 get platform() {
658 return src__style.Style._getPlatformStyle();
659 }
660 });
661 path$.Style = src__style.Style;
662 src__characters.PLUS = 43;
663 src__characters.MINUS = 45;
664 src__characters.PERIOD = 46;
665 src__characters.SLASH = 47;
666 src__characters.ZERO = 48;
667 src__characters.NINE = 57;
668 src__characters.COLON = 58;
669 src__characters.UPPER_A = 65;
670 src__characters.UPPER_Z = 90;
671 src__characters.LOWER_A = 97;
672 src__characters.LOWER_Z = 122;
673 src__characters.BACKSLASH = 92;
674 src__context.createInternal = function() {
675 return new src__context.Context._internal();
676 };
677 dart.fn(src__context.createInternal, VoidToContext());
678 src__context._validateArgList = function(method, args) {
679 for (let i = 1; i < dart.notNull(args[dartx.length]); i++) {
680 if (args[dartx.get](i) == null || args[dartx.get](i - 1) != null) continue ;
681 let numArgs = null;
682 for (numArgs = args[dartx.length]; dart.test(dart.dsend(numArgs, '>=', 1)) ; numArgs = dart.dsend(numArgs, '-', 1)) {
683 if (args[dartx.get](core.int._check(dart.dsend(numArgs, '-', 1))) != nul l) break;
684 }
685 let message = new core.StringBuffer();
686 message.write(dart.str`${method}(`);
687 message.write(args[dartx.take](core.int._check(numArgs))[dartx.map](core.S tring)(dart.fn(arg => arg == null ? "null" : dart.str`"${arg}"`, StringToString( )))[dartx.join](", "));
688 message.write(dart.str`): part ${i - 1} was null, but part ${i} was not.`) ;
689 dart.throw(new core.ArgumentError(message.toString()));
690 }
691 };
692 dart.fn(src__context._validateArgList, StringAndListOfStringTodynamic());
693 src__context._PathDirection = class _PathDirection extends core.Object {
694 new(name) {
695 this.name = name;
696 }
697 toString() {
698 return this.name;
699 }
700 };
701 dart.setSignature(src__context._PathDirection, {
702 constructors: () => ({new: dart.definiteFunctionType(src__context._PathDirec tion, [core.String])})
703 });
704 dart.defineLazy(src__context._PathDirection, {
705 get aboveRoot() {
706 return dart.const(new src__context._PathDirection("above root"));
707 },
708 get atRoot() {
709 return dart.const(new src__context._PathDirection("at root"));
710 },
711 get reachesRoot() {
712 return dart.const(new src__context._PathDirection("reaches root"));
713 },
714 get belowRoot() {
715 return dart.const(new src__context._PathDirection("below root"));
716 }
717 });
718 src__internal_style.InternalStyle = class InternalStyle extends src__style.Sty le {
719 getRoot(path) {
720 let length = this.rootLength(path);
721 if (dart.notNull(length) > 0) return path[dartx.substring](0, length);
722 return dart.test(this.isRootRelative(path)) ? path[dartx.get](0) : null;
723 }
724 relativePathToUri(path) {
725 let segments = this.context.split(path);
726 if (dart.test(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(path[da rtx.length]) - 1)))) segments[dartx.add]('');
727 return core.Uri.new({pathSegments: segments});
728 }
729 };
730 dart.setSignature(src__internal_style.InternalStyle, {
731 methods: () => ({
732 getRoot: dart.definiteFunctionType(core.String, [core.String]),
733 relativePathToUri: dart.definiteFunctionType(core.Uri, [core.String])
734 })
735 });
736 const _splitExtension = Symbol('_splitExtension');
737 src__parsed_path.ParsedPath = class ParsedPath extends core.Object {
738 get extension() {
739 return this[_splitExtension]()[dartx.get](1);
740 }
741 get isAbsolute() {
742 return this.root != null;
743 }
744 static parse(path, style) {
745 let root = style.getRoot(path);
746 let isRootRelative = style.isRootRelative(path);
747 if (root != null) path = path[dartx.substring](root[dartx.length]);
748 let parts = JSArrayOfString().of([]);
749 let separators = JSArrayOfString().of([]);
750 let start = 0;
751 if (dart.test(path[dartx.isNotEmpty]) && dart.test(style.isSeparator(path[ dartx.codeUnitAt](0)))) {
752 separators[dartx.add](path[dartx.get](0));
753 start = 1;
754 } else {
755 separators[dartx.add]('');
756 }
757 for (let i = start; i < dart.notNull(path[dartx.length]); i++) {
758 if (dart.test(style.isSeparator(path[dartx.codeUnitAt](i)))) {
759 parts[dartx.add](path[dartx.substring](start, i));
760 separators[dartx.add](path[dartx.get](i));
761 start = i + 1;
762 }
763 }
764 if (start < dart.notNull(path[dartx.length])) {
765 parts[dartx.add](path[dartx.substring](start));
766 separators[dartx.add]('');
767 }
768 return new src__parsed_path.ParsedPath._(style, root, isRootRelative, part s, separators);
769 }
770 _(style, root, isRootRelative, parts, separators) {
771 this.style = style;
772 this.root = root;
773 this.isRootRelative = isRootRelative;
774 this.parts = parts;
775 this.separators = separators;
776 }
777 get basename() {
778 let copy = this.clone();
779 copy.removeTrailingSeparators();
780 if (dart.test(copy.parts[dartx.isEmpty])) return this.root == null ? '' : this.root;
781 return copy.parts[dartx.last];
782 }
783 get basenameWithoutExtension() {
784 return this[_splitExtension]()[dartx.get](0);
785 }
786 get hasTrailingSeparator() {
787 return !dart.test(this.parts[dartx.isEmpty]) && (this.parts[dartx.last] == '' || this.separators[dartx.last] != '');
788 }
789 removeTrailingSeparators() {
790 while (!dart.test(this.parts[dartx.isEmpty]) && this.parts[dartx.last] == '') {
791 this.parts[dartx.removeLast]();
792 this.separators[dartx.removeLast]();
793 }
794 if (dart.notNull(this.separators[dartx.length]) > 0) this.separators[dartx .set](dart.notNull(this.separators[dartx.length]) - 1, '');
795 }
796 normalize() {
797 let leadingDoubles = 0;
798 let newParts = JSArrayOfString().of([]);
799 for (let part of this.parts) {
800 if (part == '.' || part == '') {
801 } else if (part == '..') {
802 if (dart.notNull(newParts[dartx.length]) > 0) {
803 newParts[dartx.removeLast]();
804 } else {
805 leadingDoubles++;
806 }
807 } else {
808 newParts[dartx.add](part);
809 }
810 }
811 if (!dart.test(this.isAbsolute)) {
812 newParts[dartx.insertAll](0, ListOfString().filled(leadingDoubles, '..') );
813 }
814 if (newParts[dartx.length] == 0 && !dart.test(this.isAbsolute)) {
815 newParts[dartx.add]('.');
816 }
817 let newSeparators = ListOfString().generate(newParts[dartx.length], dart.f n(_ => this.style.separator, intToString()), {growable: true});
818 newSeparators[dartx.insert](0, dart.test(this.isAbsolute) && dart.notNull( newParts[dartx.length]) > 0 && dart.test(this.style.needsSeparator(this.root)) ? this.style.separator : '');
819 this.parts = newParts;
820 this.separators = newSeparators;
821 if (this.root != null && dart.equals(this.style, src__style.Style.windows) ) {
822 this.root = this.root[dartx.replaceAll]('/', '\\');
823 }
824 this.removeTrailingSeparators();
825 }
826 toString() {
827 let builder = new core.StringBuffer();
828 if (this.root != null) builder.write(this.root);
829 for (let i = 0; i < dart.notNull(this.parts[dartx.length]); i++) {
830 builder.write(this.separators[dartx.get](i));
831 builder.write(this.parts[dartx.get](i));
832 }
833 builder.write(this.separators[dartx.last]);
834 return builder.toString();
835 }
836 [_splitExtension]() {
837 let file = this.parts[dartx.lastWhere](dart.fn(p => p != '', StringTobool( )), {orElse: dart.fn(() => null, VoidToString())});
838 if (file == null) return JSArrayOfString().of(['', '']);
839 if (file == '..') return JSArrayOfString().of(['..', '']);
840 let lastDot = file[dartx.lastIndexOf]('.');
841 if (dart.notNull(lastDot) <= 0) return JSArrayOfString().of([file, '']);
842 return JSArrayOfString().of([file[dartx.substring](0, lastDot), file[dartx .substring](lastDot)]);
843 }
844 clone() {
845 return new src__parsed_path.ParsedPath._(this.style, this.root, this.isRoo tRelative, ListOfString().from(this.parts), ListOfString().from(this.separators) );
846 }
847 };
848 dart.defineNamedConstructor(src__parsed_path.ParsedPath, '_');
849 dart.setSignature(src__parsed_path.ParsedPath, {
850 constructors: () => ({
851 parse: dart.definiteFunctionType(src__parsed_path.ParsedPath, [core.String , src__internal_style.InternalStyle]),
852 _: dart.definiteFunctionType(src__parsed_path.ParsedPath, [src__internal_s tyle.InternalStyle, core.String, core.bool, core.List$(core.String), core.List$( core.String)])
853 }),
854 methods: () => ({
855 removeTrailingSeparators: dart.definiteFunctionType(dart.void, []),
856 normalize: dart.definiteFunctionType(dart.void, []),
857 [_splitExtension]: dart.definiteFunctionType(core.List$(core.String), []),
858 clone: dart.definiteFunctionType(src__parsed_path.ParsedPath, [])
859 })
860 });
861 let const$;
862 src__style__posix.PosixStyle = class PosixStyle extends src__internal_style.In ternalStyle {
863 new() {
864 this.separatorPattern = core.RegExp.new('/');
865 this.needsSeparatorPattern = core.RegExp.new('[^/]$');
866 this.rootPattern = core.RegExp.new('^/');
867 this.name = 'posix';
868 this.separator = '/';
869 this.separators = const$ || (const$ = dart.constList(['/'], core.String));
870 this.relativeRootPattern = null;
871 }
872 containsSeparator(path) {
873 return path[dartx.contains]('/');
874 }
875 isSeparator(codeUnit) {
876 return codeUnit == src__characters.SLASH;
877 }
878 needsSeparator(path) {
879 return dart.test(path[dartx.isNotEmpty]) && !dart.test(this.isSeparator(pa th[dartx.codeUnitAt](dart.notNull(path[dartx.length]) - 1)));
880 }
881 rootLength(path) {
882 if (dart.test(path[dartx.isNotEmpty]) && dart.test(this.isSeparator(path[d artx.codeUnitAt](0)))) return 1;
883 return 0;
884 }
885 isRootRelative(path) {
886 return false;
887 }
888 getRelativeRoot(path) {
889 return null;
890 }
891 pathFromUri(uri) {
892 if (uri.scheme == '' || uri.scheme == 'file') {
893 return core.Uri.decodeComponent(uri.path);
894 }
895 dart.throw(new core.ArgumentError(dart.str`Uri ${uri} must have scheme 'fi le:'.`));
896 }
897 absolutePathToUri(path) {
898 let parsed = src__parsed_path.ParsedPath.parse(path, this);
899 if (dart.test(parsed.parts[dartx.isEmpty])) {
900 parsed.parts[dartx.addAll](JSArrayOfString().of(["", ""]));
901 } else if (dart.test(parsed.hasTrailingSeparator)) {
902 parsed.parts[dartx.add]("");
903 }
904 return core.Uri.new({scheme: 'file', pathSegments: parsed.parts});
905 }
906 };
907 dart.setSignature(src__style__posix.PosixStyle, {
908 constructors: () => ({new: dart.definiteFunctionType(src__style__posix.Posix Style, [])}),
909 methods: () => ({
910 containsSeparator: dart.definiteFunctionType(core.bool, [core.String]),
911 isSeparator: dart.definiteFunctionType(core.bool, [core.int]),
912 needsSeparator: dart.definiteFunctionType(core.bool, [core.String]),
913 rootLength: dart.definiteFunctionType(core.int, [core.String]),
914 isRootRelative: dart.definiteFunctionType(core.bool, [core.String]),
915 getRelativeRoot: dart.definiteFunctionType(core.String, [core.String]),
916 pathFromUri: dart.definiteFunctionType(core.String, [core.Uri]),
917 absolutePathToUri: dart.definiteFunctionType(core.Uri, [core.String])
918 })
919 });
920 let const$0;
921 src__style__url.UrlStyle = class UrlStyle extends src__internal_style.Internal Style {
922 new() {
923 this.separatorPattern = core.RegExp.new('/');
924 this.needsSeparatorPattern = core.RegExp.new("(^[a-zA-Z][-+.a-zA-Z\\d]*:// |[^/])$");
925 this.rootPattern = core.RegExp.new("[a-zA-Z][-+.a-zA-Z\\d]*://[^/]*");
926 this.relativeRootPattern = core.RegExp.new("^/");
927 this.name = 'url';
928 this.separator = '/';
929 this.separators = const$0 || (const$0 = dart.constList(['/'], core.String) );
930 }
931 containsSeparator(path) {
932 return path[dartx.contains]('/');
933 }
934 isSeparator(codeUnit) {
935 return codeUnit == src__characters.SLASH;
936 }
937 needsSeparator(path) {
938 if (dart.test(path[dartx.isEmpty])) return false;
939 if (!dart.test(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(path[d artx.length]) - 1)))) return true;
940 return dart.test(path[dartx.endsWith]("://")) && this.rootLength(path) == path[dartx.length];
941 }
942 rootLength(path) {
943 if (dart.test(path[dartx.isEmpty])) return 0;
944 if (dart.test(this.isSeparator(path[dartx.codeUnitAt](0)))) return 1;
945 let index = path[dartx.indexOf]("/");
946 if (dart.notNull(index) > 0 && dart.test(path[dartx.startsWith]('://', dar t.notNull(index) - 1))) {
947 index = path[dartx.indexOf]('/', dart.notNull(index) + 2);
948 if (dart.notNull(index) > 0) return index;
949 return path[dartx.length];
950 }
951 return 0;
952 }
953 isRootRelative(path) {
954 return dart.test(path[dartx.isNotEmpty]) && dart.test(this.isSeparator(pat h[dartx.codeUnitAt](0)));
955 }
956 getRelativeRoot(path) {
957 return dart.test(this.isRootRelative(path)) ? '/' : null;
958 }
959 pathFromUri(uri) {
960 return dart.toString(uri);
961 }
962 relativePathToUri(path) {
963 return core.Uri.parse(path);
964 }
965 absolutePathToUri(path) {
966 return core.Uri.parse(path);
967 }
968 };
969 dart.setSignature(src__style__url.UrlStyle, {
970 constructors: () => ({new: dart.definiteFunctionType(src__style__url.UrlStyl e, [])}),
971 methods: () => ({
972 containsSeparator: dart.definiteFunctionType(core.bool, [core.String]),
973 isSeparator: dart.definiteFunctionType(core.bool, [core.int]),
974 needsSeparator: dart.definiteFunctionType(core.bool, [core.String]),
975 rootLength: dart.definiteFunctionType(core.int, [core.String]),
976 isRootRelative: dart.definiteFunctionType(core.bool, [core.String]),
977 getRelativeRoot: dart.definiteFunctionType(core.String, [core.String]),
978 pathFromUri: dart.definiteFunctionType(core.String, [core.Uri]),
979 absolutePathToUri: dart.definiteFunctionType(core.Uri, [core.String])
980 })
981 });
982 let const$1;
983 src__style__windows.WindowsStyle = class WindowsStyle extends src__internal_st yle.InternalStyle {
984 new() {
985 this.separatorPattern = core.RegExp.new('[/\\\\]');
986 this.needsSeparatorPattern = core.RegExp.new('[^/\\\\]$');
987 this.rootPattern = core.RegExp.new('^(\\\\\\\\[^\\\\]+\\\\[^\\\\/]+|[a-zA- Z]:[/\\\\])');
988 this.relativeRootPattern = core.RegExp.new("^[/\\\\](?![/\\\\])");
989 this.name = 'windows';
990 this.separator = '\\';
991 this.separators = const$1 || (const$1 = dart.constList(['/', '\\'], core.S tring));
992 }
993 containsSeparator(path) {
994 return path[dartx.contains]('/');
995 }
996 isSeparator(codeUnit) {
997 return codeUnit == src__characters.SLASH || codeUnit == src__characters.BA CKSLASH;
998 }
999 needsSeparator(path) {
1000 if (dart.test(path[dartx.isEmpty])) return false;
1001 return !dart.test(this.isSeparator(path[dartx.codeUnitAt](dart.notNull(pat h[dartx.length]) - 1)));
1002 }
1003 rootLength(path) {
1004 if (dart.test(path[dartx.isEmpty])) return 0;
1005 if (path[dartx.codeUnitAt](0) == src__characters.SLASH) return 1;
1006 if (path[dartx.codeUnitAt](0) == src__characters.BACKSLASH) {
1007 if (dart.notNull(path[dartx.length]) < 2 || path[dartx.codeUnitAt](1) != src__characters.BACKSLASH) return 1;
1008 let index = path[dartx.indexOf]('\\', 2);
1009 if (dart.notNull(index) > 0) {
1010 index = path[dartx.indexOf]('\\', dart.notNull(index) + 1);
1011 if (dart.notNull(index) > 0) return index;
1012 }
1013 return path[dartx.length];
1014 }
1015 if (dart.notNull(path[dartx.length]) < 3) return 0;
1016 if (!dart.test(src__utils.isAlphabetic(path[dartx.codeUnitAt](0)))) return 0;
1017 if (path[dartx.codeUnitAt](1) != src__characters.COLON) return 0;
1018 if (!dart.test(this.isSeparator(path[dartx.codeUnitAt](2)))) return 0;
1019 return 3;
1020 }
1021 isRootRelative(path) {
1022 return this.rootLength(path) == 1;
1023 }
1024 getRelativeRoot(path) {
1025 let length = this.rootLength(path);
1026 if (length == 1) return path[dartx.get](0);
1027 return null;
1028 }
1029 pathFromUri(uri) {
1030 if (uri.scheme != '' && uri.scheme != 'file') {
1031 dart.throw(new core.ArgumentError(dart.str`Uri ${uri} must have scheme ' file:'.`));
1032 }
1033 let path = uri.path;
1034 if (uri.host == '') {
1035 if (dart.test(path[dartx.startsWith]('/'))) path = path[dartx.replaceFir st]("/", "");
1036 } else {
1037 path = dart.str`\\\\${uri.host}${path}`;
1038 }
1039 return core.Uri.decodeComponent(path[dartx.replaceAll]("/", "\\"));
1040 }
1041 absolutePathToUri(path) {
1042 let parsed = src__parsed_path.ParsedPath.parse(path, this);
1043 if (dart.test(parsed.root[dartx.startsWith]('\\\\'))) {
1044 let rootParts = parsed.root[dartx.split]('\\')[dartx.where](dart.fn(part => part != '', StringTobool()));
1045 parsed.parts[dartx.insert](0, rootParts[dartx.last]);
1046 if (dart.test(parsed.hasTrailingSeparator)) {
1047 parsed.parts[dartx.add]("");
1048 }
1049 return core.Uri.new({scheme: 'file', host: rootParts[dartx.first], pathS egments: parsed.parts});
1050 } else {
1051 if (parsed.parts[dartx.length] == 0 || dart.test(parsed.hasTrailingSepar ator)) {
1052 parsed.parts[dartx.add]("");
1053 }
1054 parsed.parts[dartx.insert](0, parsed.root[dartx.replaceAll]("/", "")[dar tx.replaceAll]("\\", ""));
1055 return core.Uri.new({scheme: 'file', pathSegments: parsed.parts});
1056 }
1057 }
1058 };
1059 dart.setSignature(src__style__windows.WindowsStyle, {
1060 constructors: () => ({new: dart.definiteFunctionType(src__style__windows.Win dowsStyle, [])}),
1061 methods: () => ({
1062 containsSeparator: dart.definiteFunctionType(core.bool, [core.String]),
1063 isSeparator: dart.definiteFunctionType(core.bool, [core.int]),
1064 needsSeparator: dart.definiteFunctionType(core.bool, [core.String]),
1065 rootLength: dart.definiteFunctionType(core.int, [core.String]),
1066 isRootRelative: dart.definiteFunctionType(core.bool, [core.String]),
1067 getRelativeRoot: dart.definiteFunctionType(core.String, [core.String]),
1068 pathFromUri: dart.definiteFunctionType(core.String, [core.Uri]),
1069 absolutePathToUri: dart.definiteFunctionType(core.Uri, [core.String])
1070 })
1071 });
1072 src__utils.isAlphabetic = function(char) {
1073 return dart.notNull(char) >= src__characters.UPPER_A && dart.notNull(char) < = src__characters.UPPER_Z || dart.notNull(char) >= src__characters.LOWER_A && da rt.notNull(char) <= src__characters.LOWER_Z;
1074 };
1075 dart.fn(src__utils.isAlphabetic, intTobool());
1076 src__utils.isNumeric = function(char) {
1077 return dart.notNull(char) >= src__characters.ZERO && dart.notNull(char) <= s rc__characters.NINE;
1078 };
1079 dart.fn(src__utils.isNumeric, intTobool());
1080 // Exports:
1081 exports.path = path$;
1082 exports.src__characters = src__characters;
1083 exports.src__context = src__context;
1084 exports.src__internal_style = src__internal_style;
1085 exports.src__parsed_path = src__parsed_path;
1086 exports.src__path_exception = src__path_exception;
1087 exports.src__style__posix = src__style__posix;
1088 exports.src__style__url = src__style__url;
1089 exports.src__style__windows = src__style__windows;
1090 exports.src__style = src__style;
1091 exports.src__utils = src__utils;
1092 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698