feat(dart/transform): Add quick_transformer

Add an implementation of the transformer which runs only the phases
which replace `Asset`s, rather than generate them.

Closes #5484
This commit is contained in:
Tim Blasi 2015-11-25 14:55:59 -08:00 committed by Timothy Blasi
parent 922da62720
commit f77ca7b5e2
1 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,68 @@
library angular2.src.transform.quick_transformer;
import 'package:barback/barback.dart';
import 'package:dart_style/dart_style.dart';
import 'common/formatter.dart' as formatter;
import 'common/options.dart';
import 'common/options_reader.dart';
import 'deferred_rewriter/transformer.dart';
// import 'directive_metadata_linker/transformer.dart';
// import 'directive_processor/transformer.dart';
import 'inliner_for_test/transformer.dart';
import 'reflection_remover/transformer.dart';
// import 'stylesheet_compiler/transformer.dart';
// import 'template_compiler/transformer.dart';
export 'common/options.dart';
/// Replaces Angular 2 mirror use with generated code.
///
/// Typical users should not use this implementation and should instead use
/// package:angular2/transformer.dart.
///
/// This alternative excludes phases that generate new [Asset]s, including only
/// the phases that replace existing [Asset]s.
///
/// This can be used if all code that would be generated already exists as real
/// files, rather than needing to be generated by [Transformer]s.
class AngularTransformerGroup extends TransformerGroup {
AngularTransformerGroup._(phases, {bool formatCode: false}) : super(phases) {
if (formatCode) {
formatter.init(new DartFormatter());
}
}
factory AngularTransformerGroup(TransformerOptions options) {
var phases;
if (options.inlineViews) {
phases = [
[new InlinerForTest(options)]
];
} else {
// Only the phases that replace [Asset]s.
phases = [
[new ReflectionRemover(options)],
[new DeferredRewriter(options)],
];
/*
phases = [
[new DirectiveProcessor(options)],
[new DirectiveMetadataLinker()],
[new ReflectionRemover(options)],
[
new DeferredRewriter(options),
new StylesheetCompiler(),
new TemplateCompiler(options)
],
];
*/
}
return new AngularTransformerGroup._(phases,
formatCode: options.formatCode);
}
factory AngularTransformerGroup.asPlugin(BarbackSettings settings) {
return new AngularTransformerGroup(parseBarbackSettings(settings));
}
}