Tim Blasi 3b6aaf9054 feat(dart/transform) Remove import of dart:mirrors
+ Precede the call to `new ReflectionCapabilities()` with our generated
code which populates the reflection map statically.
+ Add the import of our generated code.
+ Once we are generating all necessary code, we will remove the
import of reflection_capabilities.dart and the instantiation of
`ReflectionCapabilities`, cutting the dependency on dart:mirrors.

Closes #761
2015-02-23 18:36:29 -08:00

42 lines
1.4 KiB
Dart

library angular2.src.transform;
const entryPointParam = 'entry_point';
const reflectionEntryPointParam = 'reflection_entry_point';
const newEntryPointParam = 'new_entry_point';
/// Provides information necessary to transform an Angular2 app.
class TransformerOptions {
/// The file where the application's call to [bootstrap] is.
// TODO(kegluneq): Allow multiple entry points.
final String entryPoint;
/// The reflection entry point, that is, where the
/// application's [ReflectionCapabilities] are set.
final String reflectionEntryPoint;
/// The path where we should generate code.
final String newEntryPoint;
TransformerOptions._internal(
this.entryPoint, this.reflectionEntryPoint, this.newEntryPoint);
factory TransformerOptions(String entryPoint,
{String reflectionEntryPoint, String newEntryPoint}) {
if (entryPoint == null || entryPoint.isEmpty) {
throw new ArgumentError.notNull(entryPointParam);
}
if (reflectionEntryPoint == null || entryPoint.isEmpty) {
reflectionEntryPoint = entryPoint;
}
if (newEntryPoint == null || newEntryPoint.isEmpty) {
newEntryPoint =
reflectionEntryPoint.replaceFirst('.dart', '.bootstrap.dart');
if (newEntryPoint == reflectionEntryPoint) {
newEntryPoint = 'bootstrap.${newEntryPoint}';
}
}
return new TransformerOptions._internal(
entryPoint, reflectionEntryPoint, newEntryPoint);
}
}