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

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

Issue 162093002: fix imports link rel=stylesheet (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/pkg.status ('k') | pkg/polymer/lib/src/build/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.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/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Remove empty tags 45 // Remove empty tags
46 if (tag.nodes.length == 0) { 46 if (tag.nodes.length == 0) {
47 tag.remove(); 47 tag.remove();
48 continue; 48 continue;
49 } 49 }
50 50
51 var filename = path.url.basename(id.path); 51 var filename = path.url.basename(id.path);
52 // TODO(sigmund): ensure this filename is unique (dartbug.com/12618). 52 // TODO(sigmund): ensure this filename is unique (dartbug.com/12618).
53 tag.attributes['src'] = '$filename.$count.dart'; 53 tag.attributes['src'] = '$filename.$count.dart';
54 var textContent = tag.nodes.first; 54 var textContent = tag.nodes.first;
55 var code = textContent.value; 55 var code = textContent.text;
56 var newId = id.addExtension('.$count.dart'); 56 var newId = id.addExtension('.$count.dart');
57 if (!_hasLibraryDirective(code)) { 57 if (!_hasLibraryDirective(code)) {
58 var libname = path.withoutExtension(newId.path) 58 var libname = path.withoutExtension(newId.path)
59 .replaceAll(new RegExp('[-./]'), '_'); 59 .replaceAll(new RegExp('[-./]'), '_');
60 code = "library $libname;\n$code"; 60 code = "library $libname;\n$code";
61 } 61 }
62 transform.addOutput(new Asset.fromString(newId, code)); 62 transform.addOutput(new Asset.fromString(newId, code));
63 textContent.remove(); 63 textContent.remove();
64 count++; 64 count++;
65 } 65 }
(...skipping 10 matching lines...) Expand all
76 var scanner = new Scanner(null, reader, errorListener); 76 var scanner = new Scanner(null, reader, errorListener);
77 var token = scanner.tokenize(); 77 var token = scanner.tokenize();
78 var unit = new Parser(null, errorListener).parseCompilationUnit(token); 78 var unit = new Parser(null, errorListener).parseCompilationUnit(token);
79 return unit.directives.any((d) => d is LibraryDirective); 79 return unit.directives.any((d) => d is LibraryDirective);
80 } 80 }
81 81
82 class _ErrorCollector extends AnalysisErrorListener { 82 class _ErrorCollector extends AnalysisErrorListener {
83 final errors = <AnalysisError>[]; 83 final errors = <AnalysisError>[];
84 onError(error) => errors.add(error); 84 onError(error) => errors.add(error);
85 } 85 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | pkg/polymer/lib/src/build/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698