|
| 1 | +library angular2.src.transform.quick_transformer; |
| 2 | + |
| 3 | +import 'package:barback/barback.dart'; |
| 4 | +import 'package:dart_style/dart_style.dart'; |
| 5 | + |
| 6 | +import 'common/formatter.dart' as formatter; |
| 7 | +import 'common/options.dart'; |
| 8 | +import 'common/options_reader.dart'; |
| 9 | +import 'deferred_rewriter/transformer.dart'; |
| 10 | +// import 'directive_metadata_linker/transformer.dart'; |
| 11 | +// import 'directive_processor/transformer.dart'; |
| 12 | +import 'inliner_for_test/transformer.dart'; |
| 13 | +import 'reflection_remover/transformer.dart'; |
| 14 | +// import 'stylesheet_compiler/transformer.dart'; |
| 15 | +// import 'template_compiler/transformer.dart'; |
| 16 | + |
| 17 | +export 'common/options.dart'; |
| 18 | + |
| 19 | +/// Replaces Angular 2 mirror use with generated code. |
| 20 | +/// |
| 21 | +/// Typical users should not use this implementation and should instead use |
| 22 | +/// package:angular2/transformer.dart. |
| 23 | +/// |
| 24 | +/// This alternative excludes phases that generate new [Asset]s, including only |
| 25 | +/// the phases that replace existing [Asset]s. |
| 26 | +/// |
| 27 | +/// This can be used if all code that would be generated already exists as real |
| 28 | +/// files, rather than needing to be generated by [Transformer]s. |
| 29 | +class AngularTransformerGroup extends TransformerGroup { |
| 30 | + AngularTransformerGroup._(phases, {bool formatCode: false}) : super(phases) { |
| 31 | + if (formatCode) { |
| 32 | + formatter.init(new DartFormatter()); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + factory AngularTransformerGroup(TransformerOptions options) { |
| 37 | + var phases; |
| 38 | + if (options.inlineViews) { |
| 39 | + phases = [ |
| 40 | + [new InlinerForTest(options)] |
| 41 | + ]; |
| 42 | + } else { |
| 43 | + // Only the phases that replace [Asset]s. |
| 44 | + phases = [ |
| 45 | + [new ReflectionRemover(options)], |
| 46 | + [new DeferredRewriter(options)], |
| 47 | + ]; |
| 48 | + /* |
| 49 | + phases = [ |
| 50 | + [new DirectiveProcessor(options)], |
| 51 | + [new DirectiveMetadataLinker()], |
| 52 | + [new ReflectionRemover(options)], |
| 53 | + [ |
| 54 | + new DeferredRewriter(options), |
| 55 | + new StylesheetCompiler(), |
| 56 | + new TemplateCompiler(options) |
| 57 | + ], |
| 58 | + ]; |
| 59 | + */ |
| 60 | + } |
| 61 | + return new AngularTransformerGroup._(phases, |
| 62 | + formatCode: options.formatCode); |
| 63 | + } |
| 64 | + |
| 65 | + factory AngularTransformerGroup.asPlugin(BarbackSettings settings) { |
| 66 | + return new AngularTransformerGroup(parseBarbackSettings(settings)); |
| 67 | + } |
| 68 | +} |
0 commit comments