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

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

Issue 112843004: Add linter by default for polymer's pub-build, also cleans up the linter code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 /** Transfomer that extracts inlined script code into separate assets. */ 5 /** Transfomer that extracts inlined script code into separate assets. */
6 library polymer.src.build.code_extractor; 6 library polymer.src.build.code_extractor;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:analyzer/src/generated/java_core.dart' show CharSequence; 10 import 'package:analyzer/src/generated/java_core.dart' show CharSequence;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 code = "library $libname;\n$code"; 61 code = "library $libname;\n$code";
62 } 62 }
63 transform.addOutput(new Asset.fromString(newId, code)); 63 transform.addOutput(new Asset.fromString(newId, code));
64 textContent.remove(); 64 textContent.remove();
65 count++; 65 count++;
66 } 66 }
67 transform.addOutput( 67 transform.addOutput(
68 htmlChanged ? new Asset.fromString(id, document.outerHtml) : input); 68 htmlChanged ? new Asset.fromString(id, document.outerHtml) : input);
69 }); 69 });
70 } 70 }
71
72 String toString() => 'polymer-code-extractor';
71 } 73 }
72 74
73 /** Parse [code] and determine whether it has a library directive. */ 75 /** Parse [code] and determine whether it has a library directive. */
74 bool _hasLibraryDirective(String code) { 76 bool _hasLibraryDirective(String code) {
75 var errorListener = new _ErrorCollector(); 77 var errorListener = new _ErrorCollector();
76 var reader = new CharSequenceReader(new CharSequence(code)); 78 var reader = new CharSequenceReader(new CharSequence(code));
77 var scanner = new Scanner(null, reader, errorListener); 79 var scanner = new Scanner(null, reader, errorListener);
78 var token = scanner.tokenize(); 80 var token = scanner.tokenize();
79 var unit = new Parser(null, errorListener).parseCompilationUnit(token); 81 var unit = new Parser(null, errorListener).parseCompilationUnit(token);
80 return unit.directives.any((d) => d is LibraryDirective); 82 return unit.directives.any((d) => d is LibraryDirective);
81 } 83 }
82 84
83 class _ErrorCollector extends AnalysisErrorListener { 85 class _ErrorCollector extends AnalysisErrorListener {
84 final errors = <AnalysisError>[]; 86 final errors = <AnalysisError>[];
85 onError(error) => errors.add(error); 87 onError(error) => errors.add(error);
86 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698