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

Side by Side Diff: third_party/pkg/angular/lib/tools/expression_extractor.dart

Issue 148453003: Updating Angular version (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
OLDNEW
1 library angular.tools.html_expression_extractor; 1 library angular.tools.html_expression_extractor;
2 2
3 import 'dart:io'; 3 import 'dart:io';
4 import 'package:angular/tools/html_extractor.dart'; 4 import 'package:angular/tools/html_extractor.dart';
5 import 'package:angular/tools/source_metadata_extractor.dart'; 5 import 'package:angular/tools/source_metadata_extractor.dart';
6 import 'package:angular/tools/source_crawler_impl.dart'; 6 import 'package:angular/tools/source_crawler_impl.dart';
7 import 'package:angular/tools/io.dart'; 7 import 'package:angular/tools/io.dart';
8 import 'package:angular/tools/io_impl.dart'; 8 import 'package:angular/tools/io_impl.dart';
9 import 'package:angular/tools/common.dart'; 9 import 'package:angular/tools/common.dart';
10 10
11 import 'package:di/di.dart'; 11 import 'package:di/di.dart';
12 import 'package:di/dynamic_injector.dart'; 12 import 'package:di/dynamic_injector.dart';
13 import 'package:angular/core/parser/parser_library.dart'; 13
14 import 'package:angular/tools/parser_generator/dart_code_gen.dart'; 14 import 'package:angular/core/module.dart';
15 import 'package:angular/core/parser/parser.dart';
15 import 'package:angular/tools/parser_generator/generator.dart'; 16 import 'package:angular/tools/parser_generator/generator.dart';
16 17
17 main(args) { 18 main(args) {
18 if (args.length < 5) { 19 if (args.length < 5) {
19 print('Usage: expression_extractor file_to_scan html_root header_file ' 20 print('Usage: expression_extractor file_to_scan html_root header_file '
20 'footer_file output [package_roots+]'); 21 'footer_file output [package_roots+]');
21 exit(0); 22 exit(0);
22 } 23 }
23 IoService ioService = new IoServiceImpl(); 24 IoService ioService = new IoServiceImpl();
24 25
25 var packageRoots = 26 var packageRoots =
26 (args.length < 6) ? [Platform.packageRoot] : args.sublist(5); 27 (args.length < 6) ? [Platform.packageRoot] : args.sublist(5);
27 var sourceCrawler = new SourceCrawlerImpl(packageRoots); 28 var sourceCrawler = new SourceCrawlerImpl(packageRoots);
28 var sourceMetadataExtractor = new SourceMetadataExtractor(sourceCrawler); 29 var sourceMetadataExtractor = new SourceMetadataExtractor(sourceCrawler);
29 List<DirectiveInfo> directives = 30 List<DirectiveInfo> directives =
30 sourceMetadataExtractor.gatherDirectiveInfo(args[0]); 31 sourceMetadataExtractor.gatherDirectiveInfo(args[0]);
31 var htmlExtractor = new HtmlExpressionExtractor(directives, ioService); 32 var htmlExtractor = new HtmlExpressionExtractor(directives, ioService);
32 htmlExtractor.crawl(args[1]); 33 htmlExtractor.crawl(args[1]);
33 34
34 var expressions = htmlExtractor.expressions; 35 var expressions = htmlExtractor.expressions;
35 expressions.add('null'); 36 expressions.add('null');
36 37
37 var headerFile = args[2]; 38 var headerFile = args[2];
38 var footerFile = args[3]; 39 var footerFile = args[3];
39 var outputFile = args[4]; 40 var outputFile = args[4];
40 SourcePrinter _prt; 41 SourcePrinter printer;
41 if (outputFile == '--') { 42 if (outputFile == '--') {
42 _prt = new SourcePrinter(); 43 printer = new SourcePrinter();
43 } else { 44 } else {
44 _prt = new FileSourcePrinter(outputFile); 45 printer = new FileSourcePrinter(outputFile);
45 } 46 }
46 47
47 // Output the header file first. 48 // Output the header file first.
48 if (headerFile != '') { 49 if (headerFile != '') {
49 _prt.printSrc(_readFile(headerFile)); 50 printer.printSrc(_readFile(headerFile));
50 } 51 }
51 52
52 _prt.printSrc('// Found ${expressions.length} expressions'); 53 printer.printSrc('// Found ${expressions.length} expressions');
53 Module module = new Module() 54 Module module = new Module()
54 ..type(ParserBackend, implementedBy: DartCodeGen) 55 ..type(Parser, implementedBy: DynamicParser)
55 ..value(SourcePrinter, _prt); 56 ..type(ParserBackend, implementedBy: DynamicParserBackend)
57 ..type(FilterMap, implementedBy: NullFilterMap)
58 ..value(SourcePrinter, printer);
56 Injector injector = 59 Injector injector =
57 new DynamicInjector(modules: [module], allowImplicitInjection: true); 60 new DynamicInjector(modules: [module], allowImplicitInjection: true);
58 61
59 // Run the generator. 62 // Run the generator.
60 injector.get(ParserGenerator).generateParser(htmlExtractor.expressions); 63 injector.get(ParserGenerator).generateParser(htmlExtractor.expressions);
61 64
62 // Output footer last. 65 // Output footer last.
63 if (footerFile != '') { 66 if (footerFile != '') {
64 _prt.printSrc(_readFile(footerFile)); 67 printer.printSrc(_readFile(footerFile));
65 } 68 }
66 } 69 }
67 70
68 String _readFile(String filePath) => new File(filePath).readAsStringSync(); 71 String _readFile(String filePath) => new File(filePath).readAsStringSync();
69 72
70 class FileSourcePrinter implements SourcePrinter { 73 class FileSourcePrinter implements SourcePrinter {
71 final File _file; 74 final File _file;
72 75
73 FileSourcePrinter(String filePath) 76 FileSourcePrinter(String filePath)
74 : _file = new File(filePath) { 77 : _file = new File(filePath) {
75 // clear file 78 // clear file
76 _file.writeAsStringSync(''); 79 _file.writeAsStringSync('');
77 } 80 }
78 81
79 printSrc(src) => _file.writeAsStringSync('$src\n', mode: FileMode.APPEND); 82 printSrc(src) => _file.writeAsStringSync('$src\n', mode: FileMode.APPEND);
80 } 83 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/routing/module.dart ('k') | third_party/pkg/angular/lib/tools/html_extractor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698