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

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

Issue 335943003: merge to trunk all changes from 36817 until 37378 under the packages: polymer, (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 6 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/polymer_element.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
===================================================================
--- pkg/polymer/lib/src/build/common.dart (revision 37373)
+++ pkg/polymer/lib/src/build/common.dart (working copy)
@@ -18,20 +18,28 @@
import 'package:observe/transformer.dart' show ObservableTransformer;
import 'package:source_maps/span.dart' show Span;
+const _ignoredErrors = const [
+ 'unexpected-dash-after-double-dash-in-comment',
+ 'unexpected-char-in-comment',
+];
+
/// Parses an HTML file [contents] and returns a DOM-like tree. Adds emitted
/// error/warning to [logger].
Document _parseHtml(String contents, String sourcePath, TransformLogger logger,
- {bool checkDocType: true}) {
+ {bool checkDocType: true, bool showWarnings: true}) {
// TODO(jmesserly): make HTTP encoding configurable
- var parser = new HtmlParser(contents, encoding: 'utf8', generateSpans: true,
- sourceUrl: sourcePath);
+ var parser = new HtmlParser(contents, encoding: 'utf8',
+ generateSpans: true, sourceUrl: sourcePath);
var document = parser.parse();
// Note: errors aren't fatal in HTML (unless strict mode is on).
// So just print them as warnings.
- for (var e in parser.errors) {
- if (checkDocType || e.errorCode != 'expected-doctype-but-got-start-tag') {
- logger.warning(e.message, span: e.span);
+ if (showWarnings) {
+ for (var e in parser.errors) {
+ if (_ignoredErrors.contains(e.errorCode)) continue;
+ if (checkDocType || e.errorCode != 'expected-doctype-but-got-start-tag') {
+ logger.warning(e.message, span: e.span);
+ }
}
}
return document;
@@ -99,13 +107,15 @@
});
}
- Future<Document> readAsHtml(AssetId id, Transform transform) {
+ Future<Document> readAsHtml(AssetId id, Transform transform,
+ {bool showWarnings: true}) {
var primaryId = transform.primaryInput.id;
bool samePackage = id.package == primaryId.package;
var url = spanUrlFor(id, transform);
return transform.readInputAsString(id).then((content) {
return _parseHtml(content, url, transform.logger,
- checkDocType: samePackage && options.isHtmlEntryPoint(id));
+ checkDocType: samePackage && options.isHtmlEntryPoint(id),
+ showWarnings: showWarnings);
});
}
@@ -172,22 +182,6 @@
return path.posix.joinAll(path.split(assetPath));
}
-
-/// Parse [code] using analyzer.
-CompilationUnit parseCompilationUnit(String code) {
- var errorListener = new _ErrorCollector();
- var reader = new CharSequenceReader(code);
- var scanner = new Scanner(null, reader, errorListener);
- var token = scanner.tokenize();
- var parser = new Parser(null, errorListener);
- return parser.parseCompilationUnit(token);
-}
-
-class _ErrorCollector extends AnalysisErrorListener {
- final errors = <AnalysisError>[];
- onError(error) => errors.add(error);
-}
-
/// These names have meaning in SVG or MathML, so they aren't allowed as custom
/// tags. See [isCustomTagName].
const invalidTagNames = const {
« no previous file with comments | « pkg/polymer/lib/polymer_element.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