feat(dart/transform): Improve constant evaluation

Use `package:analyzer`'s `ConstantEvaluator` to read from the AST.
This cleanly builds values for us from adjacent strings, interpolations,
etc.
This commit is contained in:
Tim Blasi
2015-05-26 16:53:14 -07:00
parent a9be2ebf1b
commit 5d2af54730
11 changed files with 114 additions and 82 deletions
@@ -39,6 +39,9 @@ void allTests() {
_testNgDeps(
'should inline `templateUrl` values.', 'url_expression_files/hello.dart');
_testNgDeps('should inline `templateUrl`s expressed as adjacent strings.',
'split_url_expression_files/hello.dart');
}
void _testNgDeps(String name, String inputPath,
@@ -0,0 +1,20 @@
library examples.src.hello_world.index_common_dart.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerType(HelloCmp, {
'factory': () => new HelloCmp(),
'parameters': const [],
'annotations': const [
const Component(selector: 'hello-app'),
const View(template: r'''{{greeting}}''')
]
});
}
@@ -0,0 +1,8 @@
library examples.src.hello_world.index_common_dart;
import 'package:angular2/angular2.dart'
show bootstrap, Component, Directive, View, NgElement;
@Component(selector: 'hello-app')
@View(templateUrl: 'templ' 'ate.html')
class HelloCmp {}