forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransformer.dart
More file actions
45 lines (38 loc) · 1.46 KB
/
transformer.dart
File metadata and controls
45 lines (38 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
library angular2.transform;
import 'package:barback/barback.dart';
import 'package:dart_style/dart_style.dart';
import 'directive_linker/transformer.dart';
import 'directive_processor/transformer.dart';
import 'bind_generator/transformer.dart';
import 'reflection_remover/transformer.dart';
import 'template_compiler/transformer.dart';
import 'common/formatter.dart' as formatter;
import 'common/names.dart';
import 'common/options.dart';
export 'common/options.dart';
/// Replaces Angular 2 mirror use with generated code.
class AngularTransformerGroup extends TransformerGroup {
AngularTransformerGroup._(phases) : super(phases) {
formatter.init(new DartFormatter());
}
factory AngularTransformerGroup(TransformerOptions options) {
var phases = [[new DirectiveProcessor(options)], [new DirectiveLinker()]];
if (options.modeName == TRANSFORM_MODE) {
phases.addAll([
[new BindGenerator(options)],
[new TemplateCompiler(options)],
[new ReflectionRemover(options)]
]);
}
return new AngularTransformerGroup._(phases);
}
factory AngularTransformerGroup.asPlugin(BarbackSettings settings) {
return new AngularTransformerGroup(_parseOptions(settings));
}
}
TransformerOptions _parseOptions(BarbackSettings settings) {
var config = settings.configuration;
return new TransformerOptions(config[ENTRY_POINT_PARAM],
reflectionEntryPoint: config[REFLECTION_ENTRY_POINT_PARAM],
modeName: settings.mode.name);
}