refactor(dart/transform): Minor renames
Rename `setupReflection` => `initReflector` Rename `TemplateComplier` => `TemplateCompiler` Closes #1180
This commit is contained in:
parent
a6736ff9f2
commit
bc909d1d0f
|
@ -1,6 +1,6 @@
|
|||
library angular2.transform.common.names;
|
||||
|
||||
const SETUP_METHOD_NAME = 'setupReflection';
|
||||
const SETUP_METHOD_NAME = 'initReflector';
|
||||
const REFLECTOR_VAR_NAME = 'reflector';
|
||||
const DEPS_EXTENSION = '.ng_deps.dart';
|
||||
const REGISTER_TYPE_METHOD_NAME = 'registerType';
|
||||
|
|
|
@ -14,14 +14,14 @@ import 'generator.dart';
|
|||
|
||||
/// [Transformer] responsible for detecting and processing Angular 2 templates.
|
||||
///
|
||||
/// [TemplateComplier] uses the Angular 2 `Compiler` to process the templates,
|
||||
/// [TemplateCompiler] uses the Angular 2 `Compiler` to process the templates,
|
||||
/// extracting information about what reflection is necessary to render and
|
||||
/// use that template. It then generates code in place of those reflective
|
||||
/// accesses.
|
||||
class TemplateComplier extends Transformer {
|
||||
class TemplateCompiler extends Transformer {
|
||||
final TransformerOptions options;
|
||||
|
||||
TemplateComplier(this.options);
|
||||
TemplateCompiler(this.options);
|
||||
|
||||
@override
|
||||
bool isPrimary(AssetId id) => id.path.endsWith(DEPS_EXTENSION);
|
||||
|
|
|
@ -25,7 +25,7 @@ class AngularTransformerGroup extends TransformerGroup {
|
|||
if (options.modeName == TRANSFORM_MODE) {
|
||||
phases.addAll([
|
||||
[new BindGenerator(options)],
|
||||
[new TemplateComplier(options)],
|
||||
[new TemplateCompiler(options)],
|
||||
[new ReflectionRemover(options)]
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'bar.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'bar.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:angular2/src/core/annotations/annotations.dart';
|
|||
import 'soup.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'package:angular2/src/core/annotations/annotations.dart';
|
|||
import 'soup.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/core/annotations/annotations.dart';
|
|||
export 'foo.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'foo.ng_deps.dart' as i0;
|
|||
export 'foo.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -16,5 +16,5 @@ void setupReflection(reflector) {
|
|||
'parameters': const [],
|
||||
'annotations': const [const Component(selector: '[soup]')]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'foo.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -6,8 +6,8 @@ import 'bar.dart';
|
|||
import 'bar.ng_deps.dart' as i0;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
i0.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'foo.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/reflection/reflection_capabilities.dart';
|
|||
import 'bar.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/core/annotations/annotations.dart';
|
|||
import 'foo.dart' as dep;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'foo.dart' as dep;
|
|||
import 'foo.ng_deps.dart' as i0;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -18,5 +18,5 @@ void setupReflection(reflector) {
|
|||
selector: '[soup]', services: const [dep.DependencyComponent])
|
||||
]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'foo.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -6,8 +6,8 @@ import 'bar.dart';
|
|||
import 'bar.ng_deps.dart' as i0;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
i0.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'foo.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/reflection/reflection_capabilities.dart';
|
|||
import 'bar.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import 'soup.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'foo.ng_deps.dart' as i0;
|
|||
import 'package:angular2/src/core/annotations/annotations.ng_deps.dart' as i1;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -17,6 +17,6 @@ void setupReflection(reflector) {
|
|||
'annotations':
|
||||
const [const Component(componentServices: const [MyContext])]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i1.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
i1.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/core/annotations/annotations.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.ng_deps.dart' as i0;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -14,5 +14,5 @@ void setupReflection(reflector) {
|
|||
'parameters': const [],
|
||||
'annotations': const [const Component(selector: '[soup]')]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import 'package:angular2/src/reflection/reflection_capabilities.ng_deps.dart'
|
|||
as i2;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
i0.setupReflection(reflector);
|
||||
i1.setupReflection(reflector);
|
||||
i2.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
i1.initReflector(reflector);
|
||||
i2.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/src/core/annotations/annotations.dart';
|
|||
import 'package:angular2/src/core/annotations/annotations.ng_deps.dart' as i0;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -14,5 +14,5 @@ void setupReflection(reflector) {
|
|||
'parameters': const [],
|
||||
'annotations': const [const Component(selector: '[soup]')]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'package:angular2/src/core/annotations/template.ng_deps.dart' as i0;
|
|||
import 'package:angular2/src/core/annotations/annotations.ng_deps.dart' as i1;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -19,6 +19,6 @@ void setupReflection(reflector) {
|
|||
const Template(inline: 'Salad')
|
||||
]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i1.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
i1.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'foo.ng_deps.dart' as i0;
|
|||
import 'package:angular2/src/core/annotations/annotations.ng_deps.dart' as i1;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
@ -18,6 +18,6 @@ void setupReflection(reflector) {
|
|||
'annotations':
|
||||
const [const Component(selector: prefix.preDefinedSelector)]
|
||||
});
|
||||
i0.setupReflection(reflector);
|
||||
i1.setupReflection(reflector);
|
||||
i0.initReflector(reflector);
|
||||
i1.initReflector(reflector);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@ Tests that the reflection removal step:
|
|||
1. Comments out the import of reflection_capabilities.dart
|
||||
2. Comments out the instantiation of `ReflectionCapabilities`
|
||||
3. Adds the appropriate import.
|
||||
4. Adds the call to `setupReflection`
|
||||
4. Adds the call to `initReflector`
|
||||
5. Does not change line numbers in the source.
|
||||
6. Makes minimal changes to source offsets.
|
|
@ -16,7 +16,7 @@ import 'package:angular2/src/reflection/reflection.dart';
|
|||
/*import 'package:angular2/src/reflection/reflection_capabilities.dart';*/import 'index.ng_deps.dart' as ngStaticInit;
|
||||
|
||||
void main() {
|
||||
/*reflector.reflectionCapabilities = new ReflectionCapabilities();*/ngStaticInit.setupReflection(reflector);
|
||||
/*reflector.reflectionCapabilities = new ReflectionCapabilities();*/ngStaticInit.initReflector(reflector);
|
||||
bootstrap(MyComponent);
|
||||
}
|
||||
""";
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:angular2/angular2.dart'
|
|||
show bootstrap, Component, Decorator, Template, NgElement;
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
|
|
Loading…
Reference in New Issue