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

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

Issue 23456028: report error message when import urls are broken. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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.build.common; 6 library polymer.src.build.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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 Future<Document> readAsHtml(AssetId id, Transform transform) { 72 Future<Document> readAsHtml(AssetId id, Transform transform) {
73 var primaryId = transform.primaryInput.id; 73 var primaryId = transform.primaryInput.id;
74 var url = (id.package == primaryId.package) ? id.path 74 var url = (id.package == primaryId.package) ? id.path
75 : assetUrlFor(id, primaryId, transform.logger, allowAssetUrl: true); 75 : assetUrlFor(id, primaryId, transform.logger, allowAssetUrl: true);
76 return transform.readInputAsString(id).then((content) { 76 return transform.readInputAsString(id).then((content) {
77 return _parseHtml(content, url, transform.logger, 77 return _parseHtml(content, url, transform.logger,
78 checkDocType: options.isHtmlEntryPoint(id)); 78 checkDocType: options.isHtmlEntryPoint(id));
79 }); 79 });
80 } 80 }
81
82 Future<bool> assetExists(AssetId id, Transform transform) =>
83 transform.getInput(id).then((_) => true).catchError((_) => false);
81 } 84 }
82 85
83 /** Create an [AssetId] for a [url] seen in the [source] asset. */ 86 /** Create an [AssetId] for a [url] seen in the [source] asset. */
84 // TODO(sigmund): delete once this is part of barback (dartbug.com/12610) 87 // TODO(sigmund): delete once this is part of barback (dartbug.com/12610)
85 AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) { 88 AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) {
86 if (url == null || url == '') return null; 89 if (url == null || url == '') return null;
87 var uri = Uri.parse(url); 90 var uri = Uri.parse(url);
88 var urlBuilder = path.url; 91 var urlBuilder = path.url;
89 if (uri.host != '' || uri.scheme != '' || urlBuilder.isAbsolute(url)) { 92 if (uri.host != '' || uri.scheme != '' || urlBuilder.isAbsolute(url)) {
90 logger.error('absolute paths not allowed: "$url"', span); 93 logger.error('absolute paths not allowed: "$url"', span);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return builder.relative(builder.join('/', id.path), 153 return builder.relative(builder.join('/', id.path),
151 from: builder.join('/', builder.dirname(sourceId.path))); 154 from: builder.join('/', builder.dirname(sourceId.path)));
152 } 155 }
153 156
154 157
155 /** Convert system paths to asset paths (asset paths are posix style). */ 158 /** Convert system paths to asset paths (asset paths are posix style). */
156 String _systemToAssetPath(String assetPath) { 159 String _systemToAssetPath(String assetPath) {
157 if (path.Style.platform != path.Style.windows) return assetPath; 160 if (path.Style.platform != path.Style.windows) return assetPath;
158 return path.posix.joinAll(path.split(assetPath)); 161 return path.posix.joinAll(path.split(assetPath));
159 } 162 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/linter.dart » ('j') | pkg/polymer/lib/src/build/linter.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698