2015-03-20 15:37:09 -07:00
|
|
|
library angular2.transform;
|
2015-02-17 08:38:54 -08:00
|
|
|
|
|
|
|
import 'package:barback/barback.dart';
|
2015-02-27 14:42:21 -08:00
|
|
|
import 'package:dart_style/dart_style.dart';
|
2015-02-17 08:38:54 -08:00
|
|
|
|
2015-02-27 14:42:21 -08:00
|
|
|
import 'directive_linker/transformer.dart';
|
2015-05-01 13:57:44 -07:00
|
|
|
import 'directive_metadata_extractor/transformer.dart';
|
2015-02-27 14:42:21 -08:00
|
|
|
import 'directive_processor/transformer.dart';
|
|
|
|
import 'bind_generator/transformer.dart';
|
|
|
|
import 'reflection_remover/transformer.dart';
|
2015-03-13 13:55:49 -07:00
|
|
|
import 'template_compiler/transformer.dart';
|
2015-02-27 14:42:21 -08:00
|
|
|
import 'common/formatter.dart' as formatter;
|
|
|
|
import 'common/options.dart';
|
2015-04-09 17:49:11 -07:00
|
|
|
import 'common/options_reader.dart';
|
2015-02-17 08:38:54 -08:00
|
|
|
|
2015-02-27 14:42:21 -08:00
|
|
|
export 'common/options.dart';
|
2015-02-17 08:38:54 -08:00
|
|
|
|
2015-03-13 13:55:49 -07:00
|
|
|
/// Replaces Angular 2 mirror use with generated code.
|
2015-02-27 14:42:21 -08:00
|
|
|
class AngularTransformerGroup extends TransformerGroup {
|
2015-03-19 14:10:28 -07:00
|
|
|
AngularTransformerGroup._(phases) : super(phases) {
|
|
|
|
formatter.init(new DartFormatter());
|
|
|
|
}
|
|
|
|
|
|
|
|
factory AngularTransformerGroup(TransformerOptions options) {
|
2015-04-09 17:49:11 -07:00
|
|
|
var phases = [
|
|
|
|
[new ReflectionRemover(options)],
|
2015-05-22 14:15:18 -07:00
|
|
|
[new DirectiveProcessor(options)]
|
|
|
|
];
|
|
|
|
phases.addAll(new List.generate(
|
|
|
|
options.optimizationPhases, (_) => [new EmptyNgDepsRemover()]));
|
|
|
|
phases.addAll([
|
2015-05-01 13:57:44 -07:00
|
|
|
[new DirectiveLinker(), new DirectiveMetadataExtractor()],
|
2015-04-09 17:49:11 -07:00
|
|
|
[new BindGenerator(options)],
|
|
|
|
[new TemplateCompiler(options)]
|
2015-05-22 14:15:18 -07:00
|
|
|
]);
|
2015-03-19 14:10:28 -07:00
|
|
|
return new AngularTransformerGroup._(phases);
|
2015-02-17 08:38:54 -08:00
|
|
|
}
|
|
|
|
|
2015-02-27 14:42:21 -08:00
|
|
|
factory AngularTransformerGroup.asPlugin(BarbackSettings settings) {
|
2015-04-09 17:49:11 -07:00
|
|
|
return new AngularTransformerGroup(parseBarbackSettings(settings));
|
2015-02-17 08:38:54 -08:00
|
|
|
}
|
|
|
|
}
|