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

Side by Side Diff: lib/src/utils.dart

Issue 1020043002: Replace dart_core.js with actual compiled SDK (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 9 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
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Holds a couple utility functions used at various places in the system. 5 /// Holds a couple utility functions used at various places in the system.
6 library dev_compiler.src.utils; 6 library dev_compiler.src.utils;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:path/path.dart' as path; 10 import 'package:path/path.dart' as path;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 if (resourceUri.scheme != 'file') return null; 310 if (resourceUri.scheme != 'file') return null;
311 var filepath = resourceUri.path; 311 var filepath = resourceUri.path;
312 var relativePath = path.relative(filepath, from: path.dirname(entryUri.path)); 312 var relativePath = path.relative(filepath, from: path.dirname(entryUri.path));
313 313
314 // File:/// urls can be for resources in the same project or resources from 314 // File:/// urls can be for resources in the same project or resources from
315 // the dev_compiler package. For now we only support relative paths going 315 // the dev_compiler package. For now we only support relative paths going
316 // further inside the folder where the entrypoint is located, otherwise we 316 // further inside the folder where the entrypoint is located, otherwise we
317 // assume this is a runtime resource from the dev_compiler. 317 // assume this is a runtime resource from the dev_compiler.
318 if (!relativePath.startsWith('..')) return relativePath; 318 if (!relativePath.startsWith('..')) return relativePath;
319
319 var segments = resourceUri.pathSegments; 320 var segments = resourceUri.pathSegments;
320 var len = segments.length; 321 for (int i = 0, len = segments.length; i < len; i++) {
321 if (segments.length < 4 || 322 var s = segments[i];
322 segments[len - 2] != 'runtime' || 323 if (_packageNameWithVersion.stringMatch(s) == s &&
Siggi Cherem (dart-lang) 2015/03/19 23:11:14 FYI you'll have a not so fun merge conflict here :
323 segments[len - 3] != 'lib' || 324 i + 3 < len &&
324 // If loaded from sources this will be exactly dev_compiler, otherwise it 325 segments[i + 1] == 'lib' &&
325 // can be the name in the pub cache (typically dev_compiler-version). 326 segments[i + 2] == 'runtime') {
326 !segments[len - 4].startsWith('dev_compiler')) { 327 return path.joinAll(['dev_compiler']..addAll(segments.skip(i + 2)));
327 return null; 328 }
328 } 329 }
329 return path.joinAll(['dev_compiler']..addAll(segments.skip(len - 2))); 330 return null;
330 } 331 }
332
333 // If loaded from sources this will be exactly dev_compiler, otherwise it
334 // can be the name in the pub cache (typically dev_compiler-version).
335 // TODO(jmesserly): avoid depending on pub cache implementation details.
336 final _packageNameWithVersion = new RegExp('dev_compiler[0-9A-Za-z-.]*');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698