 Chromium Code Reviews
 Chromium Code Reviews Issue 23898009:
  Switch polymer's build.dart to use the new linter. This CL does the following  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
    
  
    Issue 23898009:
  Switch polymer's build.dart to use the new linter. This CL does the following  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart| Index: pkg/polymer/lib/src/transform/common.dart | 
| diff --git a/pkg/polymer/lib/src/transform/common.dart b/pkg/polymer/lib/src/transform/common.dart | 
| index e18a053d4e60065a581418b7ce78312d5310f773..9bdd58023b4e4625ce507cc8c4f9db773879199e 100644 | 
| --- a/pkg/polymer/lib/src/transform/common.dart | 
| +++ b/pkg/polymer/lib/src/transform/common.dart | 
| @@ -34,23 +34,48 @@ Document _parseHtml(String contents, String sourcePath, TransformLogger logger, | 
| return document; | 
| } | 
| -Future<Document> readPrimaryAsHtml(Transform transform) { | 
| - var asset = transform.primaryInput; | 
| - var id = asset.id; | 
| - return asset.readAsString().then((content) { | 
| - return _parseHtml(content, id.path, transform.logger, | 
| - checkDocType: isPrimaryHtml(id)); | 
| - }); | 
| +/** Additional options used by polymer transformers */ | 
| +class TransformOptions { | 
| + String currentPackage; | 
| + List<String> entrypoints; | 
| + | 
| + TransformOptions([this.currentPackage, this.entrypoints]); | 
| + | 
| + /** Whether an asset with [id] is an entry point HTML file. */ | 
| + bool isHtmlEntrypoint(AssetId id) { | 
| 
Jennifer Messerly
2013/09/10 04:16:51
nit: entry point is two words? so entryPoint
(fun
 
Siggi Cherem (dart-lang)
2013/09/11 01:45:26
Done.
 | 
| + if (id.extension != '.html') return false; | 
| + | 
| + // Note: [id.path] is a relative path from the root of a package. | 
| + if (!id.path.startsWith('web/') && | 
| + !id.path.startsWith('test/')) return false; | 
| + | 
| + if (currentPackage == null || entrypoints == null) return true; | 
| + return id.package == currentPackage && entrypoints.contains(id.path); | 
| + } | 
| } | 
| -Future<Document> readAsHtml(AssetId id, Transform transform) { | 
| - var primaryId = transform.primaryInput.id; | 
| - var url = (id.package == primaryId.package) ? id.path | 
| - : assetUrlFor(id, primaryId, transform.logger, allowAssetUrl: true); | 
| - return transform.readInputAsString(id).then((content) { | 
| - return _parseHtml(content, url, transform.logger, | 
| - checkDocType: isPrimaryHtml(id)); | 
| - }); | 
| +/** Mixin for polymer transformers. */ | 
| +abstract class PolymerTransformer { | 
| + TransformOptions get options; | 
| + | 
| + Future<Document> readPrimaryAsHtml(Transform transform) { | 
| + var asset = transform.primaryInput; | 
| + var id = asset.id; | 
| + return asset.readAsString().then((content) { | 
| + return _parseHtml(content, id.path, transform.logger, | 
| + checkDocType: options.isHtmlEntrypoint(id)); | 
| + }); | 
| + } | 
| + | 
| + Future<Document> readAsHtml(AssetId id, Transform transform) { | 
| + var primaryId = transform.primaryInput.id; | 
| + var url = (id.package == primaryId.package) ? id.path | 
| + : assetUrlFor(id, primaryId, transform.logger, allowAssetUrl: true); | 
| + return transform.readInputAsString(id).then((content) { | 
| + return _parseHtml(content, url, transform.logger, | 
| + checkDocType: options.isHtmlEntrypoint(id)); | 
| + }); | 
| + } | 
| } | 
| /** Create an [AssetId] for a [url] seen in the [source] asset. */ | 
| @@ -92,11 +117,6 @@ AssetId resolve(AssetId source, String url, TransformLogger logger, Span span) { | 
| return new AssetId(package, targetPath); | 
| } | 
| -/** Whether an asset with [id] is considered a primary entry point HTML file. */ | 
| -bool isPrimaryHtml(AssetId id) => id.extension == '.html' && | 
| - // Note: [id.path] is a relative path from the root of a package. | 
| - (id.path.startsWith('web/') || id.path.startsWith('test/')); | 
| - | 
| /** | 
| * Generate the import url for a file described by [id], referenced by a file | 
| * with [sourceId]. |