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

Side by Side Diff: modules/angular2/src/transform/transformer.dart

Issue 927373004: Initial commit of Dart transformer to generate constructor stubs, see https://github.com/angular/an… (Closed) Base URL: https://github.com/kegluneq/angular.git@master
Patch Set: Fixing review comments Created 5 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 library angular2.src.transform;
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.
4 library angular2.transformer;
5 2
6 import 'dart:async'; 3 import 'dart:async';
7 import 'package:barback/barback.dart'; 4 import 'package:barback/barback.dart';
8 import 'package:code_transformers/resolver.dart'; 5 import 'package:code_transformers/resolver.dart';
9 6
10 import 'annotation_processor.dart'; 7 import 'annotation_processor.dart';
11 import 'codegen.dart' as codegen; 8 import 'codegen.dart' as codegen;
12 import 'html_transform.dart'; 9 import 'html_transform.dart';
13 import 'options.dart'; 10 import 'options.dart';
14 import 'resolvers.dart'; 11 import 'resolvers.dart';
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 50
54 Future _buildBootstrapFile(Transform transform) { 51 Future _buildBootstrapFile(Transform transform) {
55 var newEntryPointId = 52 var newEntryPointId =
56 new AssetId(transform.primaryInput.id.package, options.newEntryPoint); 53 new AssetId(transform.primaryInput.id.package, options.newEntryPoint);
57 return transform.hasInput(newEntryPointId).then((exists) { 54 return transform.hasInput(newEntryPointId).then((exists) {
58 if (exists) { 55 if (exists) {
59 transform.logger 56 transform.logger
60 .error('New entry point file $newEntryPointId already exists.'); 57 .error('New entry point file $newEntryPointId already exists.');
61 } else { 58 } else {
62 return _resolvers.get(transform).then((resolver) { 59 return _resolvers.get(transform).then((resolver) {
63 new _BootstrapFileBuilder(resolver, transform, 60 try {
64 transform.primaryInput.id, newEntryPointId).run(); 61 new _BootstrapFileBuilder(resolver, transform,
65 resolver.release(); 62 transform.primaryInput.id, newEntryPointId).run();
63 } finally {
64 resolver.release();
65 }
66 }); 66 });
67 } 67 }
68 }); 68 });
69 } 69 }
70 } 70 }
71 71
72 class _BootstrapFileBuilder { 72 class _BootstrapFileBuilder {
73 final Resolver _resolver; 73 final Resolver _resolver;
74 final Transform _transform; 74 final Transform _transform;
75 final AssetId _entryPoint; 75 final AssetId _entryPoint;
(...skipping 10 matching lines...) Expand all
86 'angular2', 'lib/src/core/annotations/annotations.dart')) 86 'angular2', 'lib/src/core/annotations/annotations.dart'))
87 .getType('Directive')); 87 .getType('Directive'));
88 88
89 /// Adds the new entry point file to the transform. Should only be ran once. 89 /// Adds the new entry point file to the transform. Should only be ran once.
90 void run() { 90 void run() {
91 var entryLib = _resolver.getLibrary(_entryPoint); 91 var entryLib = _resolver.getLibrary(_entryPoint);
92 92
93 new ImportTraversal(_directiveInfo).traverse(entryLib); 93 new ImportTraversal(_directiveInfo).traverse(entryLib);
94 94
95 var context = new codegen.Context(logger: _transform.logger); 95 var context = new codegen.Context(logger: _transform.logger);
96 _directiveInfo.initQueue 96 _directiveInfo.matchQueue
97 .forEach((entry) => context.directiveRegistry.register(entry)); 97 .forEach((entry) => context.directiveRegistry.register(entry));
98 98
99 _transform.addOutput(new Asset.fromString(_newEntryPoint, codegen 99 _transform.addOutput(new Asset.fromString(_newEntryPoint, codegen
100 .codegenEntryPoint(context, 100 .codegenEntryPoint(context,
101 entryPoint: entryLib, newEntryPoint: _newEntryPoint))); 101 entryPoint: entryLib, newEntryPoint: _newEntryPoint)));
102 } 102 }
103 } 103 }
OLDNEW
« no previous file with comments | « modules/angular2/src/transform/resolvers.dart ('k') | modules/angular2/src/transform/traversal.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698