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:
@@ -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,
|
||||
|
||||
+20
@@ -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}}''')
|
||||
]
|
||||
});
|
||||
}
|
||||
+8
@@ -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 {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{{greeting}}
|
||||
Reference in New Issue
Block a user