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

Unified Diff: pkg/polymer/lib/src/build/common.dart

Issue 162093002: fix imports link rel=stylesheet (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/build/code_extractor.dart ('k') | pkg/polymer/lib/src/build/import_inliner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/common.dart
diff --git a/pkg/polymer/lib/src/build/common.dart b/pkg/polymer/lib/src/build/common.dart
index 7e62cc7adb575dde51b6aa40ddb53e58cb898176..94abdd7b88deda2c95b58871847e7e06a6bf005a 100644
--- a/pkg/polymer/lib/src/build/common.dart
+++ b/pkg/polymer/lib/src/build/common.dart
@@ -104,14 +104,31 @@ abstract class PolymerTransformer {
Future<Document> readAsHtml(AssetId id, Transform transform) {
var primaryId = transform.primaryInput.id;
bool samePackage = id.package == primaryId.package;
- var url = samePackage ? id.path
- : assetUrlFor(id, primaryId, transform.logger, allowAssetUrl: true);
+ var url = spanUrlFor(id, transform);
return transform.readInputAsString(id).then((content) {
return _parseHtml(content, url, transform.logger,
checkDocType: samePackage && options.isHtmlEntryPoint(id));
});
}
+ /**
+ * Gets the appropriate URL to use in a [Span] to produce messages
+ * (e.g. warnings) for users. This will attempt to format the URL in the most
+ * useful way:
+ *
+ * - If the asset is within the primary package, then use the [id.path],
+ * the user will know it is a file from their own code.
+ * - If the asset is from another package, then use [assetUrlFor], this will
+ * likely be a "package:" url to the file in the other package, which is
+ * enough for users to identify where the error is.
+ */
+ String spanUrlFor(AssetId id, Transform transform) {
+ var primaryId = transform.primaryInput.id;
+ bool samePackage = id.package == primaryId.package;
+ return samePackage ? id.path
+ : assetUrlFor(id, primaryId, transform.logger, allowAssetUrl: true);
+ }
+
Future<bool> assetExists(AssetId id, Transform transform) =>
transform.getInput(id).then((_) => true).catchError((_) => false);
@@ -129,7 +146,8 @@ List<List<Transformer>> get phasesForPolymer =>
* urls are not resolved unless [source] is Dart file (has a .dart extension).
*/
// TODO(sigmund): delete once this is part of barback (dartbug.com/12610)
-AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) {
+AssetId resolve(AssetId source, String url, TransformLogger logger, Span span,
+ {bool allowAbsolute: false}) {
if (url == null || url == '') return null;
var uri = Uri.parse(url);
var urlBuilder = path.url;
@@ -142,7 +160,9 @@ AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) {
}
}
- logger.error('absolute paths not allowed: "$url"', span: span);
+ if (!allowAbsolute) {
+ logger.error('absolute paths not allowed: "$url"', span: span);
+ }
return null;
}
« no previous file with comments | « pkg/polymer/lib/src/build/code_extractor.dart ('k') | pkg/polymer/lib/src/build/import_inliner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698