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

Side by Side Diff: pkg/polymer/lib/src/transform/code_extractor.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
Patch Set: addressing john comments (part 2) - renamed files 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
« no previous file with comments | « pkg/polymer/lib/src/transform.dart ('k') | pkg/polymer/lib/src/transform/common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** Transfomer that extracts inlined script code into separate assets. */ 5 /** Transfomer that extracts inlined script code into separate assets. */
6 library polymer.src.transformers; 6 library polymer.src.transformers;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:analyzer_experimental/src/generated/ast.dart'; 10 import 'package:analyzer_experimental/src/generated/ast.dart';
11 import 'package:analyzer_experimental/src/generated/error.dart'; 11 import 'package:analyzer_experimental/src/generated/error.dart';
12 import 'package:analyzer_experimental/src/generated/parser.dart'; 12 import 'package:analyzer_experimental/src/generated/parser.dart';
13 import 'package:analyzer_experimental/src/generated/scanner.dart'; 13 import 'package:analyzer_experimental/src/generated/scanner.dart';
14 import 'package:barback/barback.dart'; 14 import 'package:barback/barback.dart';
15 import 'package:path/path.dart' as path; 15 import 'package:path/path.dart' as path;
16 16
17 import 'common.dart'; 17 import 'common.dart';
18 18
19 /** 19 /**
20 * Transformer that extracts Dart code inlined in HTML script tags and outputs a 20 * Transformer that extracts Dart code inlined in HTML script tags and outputs a
21 * separate file for each. 21 * separate file for each.
22 */ 22 */
23 class InlineCodeExtractor extends Transformer { 23 class InlineCodeExtractor extends Transformer with PolymerTransformer {
24 final TransformOptions options;
25
26 InlineCodeExtractor(this.options);
27
24 /** Only run this transformer on .html files. */ 28 /** Only run this transformer on .html files. */
25 final String allowedExtensions = ".html"; 29 final String allowedExtensions = ".html";
26 30
27 Future apply(Transform transform) { 31 Future apply(Transform transform) {
28 var input = transform.primaryInput; 32 var input = transform.primaryInput;
29 var id = transform.primaryInput.id; 33 var id = transform.primaryInput.id;
30 return readPrimaryAsHtml(transform).then((document) { 34 return readPrimaryAsHtml(transform).then((document) {
31 int count = 0; 35 int count = 0;
32 bool htmlChanged = false; 36 bool htmlChanged = false;
33 for (var tag in document.queryAll('script')) { 37 for (var tag in document.queryAll('script')) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 var errorListener = new _ErrorCollector(); 74 var errorListener = new _ErrorCollector();
71 var token = new StringScanner(null, code, errorListener).tokenize(); 75 var token = new StringScanner(null, code, errorListener).tokenize();
72 var unit = new Parser(null, errorListener).parseCompilationUnit(token); 76 var unit = new Parser(null, errorListener).parseCompilationUnit(token);
73 return unit.directives.any((d) => d is LibraryDirective); 77 return unit.directives.any((d) => d is LibraryDirective);
74 } 78 }
75 79
76 class _ErrorCollector extends AnalysisErrorListener { 80 class _ErrorCollector extends AnalysisErrorListener {
77 final errors = <AnalysisError>[]; 81 final errors = <AnalysisError>[];
78 onError(error) => errors.add(error); 82 onError(error) => errors.add(error);
79 } 83 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/transform.dart ('k') | pkg/polymer/lib/src/transform/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698