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

Side by Side Diff: pkg/polymer/lib/src/transform/common.dart

Issue 22852013: Fix polymer transformers in windows. AssetId's always use posix style paths (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /** Common methods used by transfomers. */ 5 /** Common methods used by transfomers. */
6 library polymer.src.transform.common; 6 library polymer.src.transform.common;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 } 42 }
43 return document; 43 return document;
44 } 44 }
45 45
46 /** Create an [AssetId] for a [url] seen in the [source] asset. */ 46 /** Create an [AssetId] for a [url] seen in the [source] asset. */
47 // TODO(sigmund): delete once this is part of barback (dartbug.com/12610) 47 // TODO(sigmund): delete once this is part of barback (dartbug.com/12610)
48 AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) { 48 AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) {
49 if (url == null || url == '') return null; 49 if (url == null || url == '') return null;
50 var uri = Uri.parse(url); 50 var uri = Uri.parse(url);
51 if (uri.host != '' || uri.scheme != '' || path.isAbsolute(url)) { 51 var urlBuilder = path.url;
52 if (uri.host != '' || uri.scheme != '' || urlBuilder.isAbsolute(url)) {
52 logger.error('absolute paths not allowed: "$url"', span); 53 logger.error('absolute paths not allowed: "$url"', span);
53 return null; 54 return null;
54 } 55 }
55 56
56 var package; 57 var package;
57 var targetPath; 58 var targetPath;
58 var segments = path.split(url); 59 var segments = urlBuilder.split(url);
59 if (segments[0] == 'packages') { 60 if (segments[0] == 'packages') {
60 if (segments.length < 3) { 61 if (segments.length < 3) {
61 logger.error("incomplete packages/ path. It should have at least 3 " 62 logger.error("incomplete packages/ path. It should have at least 3 "
62 "segments packages/name/path-from-name's-lib-dir", span); 63 "segments packages/name/path-from-name's-lib-dir", span);
63 return null; 64 return null;
64 } 65 }
65 package = segments[1]; 66 package = segments[1];
66 targetPath = path.join('lib', path.joinAll(segments.sublist(2))); 67 targetPath = urlBuilder.join('lib',
68 urlBuilder.joinAll(segments.sublist(2)));
67 } else if (segments[0] == 'assets') { 69 } else if (segments[0] == 'assets') {
68 if (segments.length < 3) { 70 if (segments.length < 3) {
69 logger.error("incomplete assets/ path. It should have at least 3 " 71 logger.error("incomplete assets/ path. It should have at least 3 "
70 "segments assets/name/path-from-name's-asset-dir", span); 72 "segments assets/name/path-from-name's-asset-dir", span);
71 } 73 }
72 package = segments[1]; 74 package = segments[1];
73 targetPath = path.join('asset', path.joinAll(segments.sublist(2))); 75 targetPath = urlBuilder.join('asset',
76 urlBuilder.joinAll(segments.sublist(2)));
74 } else { 77 } else {
75 package = source.package; 78 package = source.package;
76 targetPath = path.normalize(path.join(path.dirname(source.path), url)); 79 targetPath = urlBuilder.normalize(
80 urlBuilder.join(urlBuilder.dirname(source.path), url));
77 } 81 }
78 return new AssetId(package, targetPath); 82 return new AssetId(package, targetPath);
79 } 83 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/transform/code_extractor.dart ('k') | pkg/polymer/lib/src/transform/script_compactor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698