This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ class SourceMetadataExtractor {
95
95
class DirectiveMetadataCollectingAstVisitor extends RecursiveAstVisitor {
96
96
final List <DirectiveMetadata > metadata;
97
97
final List <String > templates;
98
+ final RegExp _COMPONENT_OR_DECORATOR_EXPR = new RegExp (r"\.?(Component|Decorator)$" );
98
99
99
100
DirectiveMetadataCollectingAstVisitor (this .metadata, this .templates);
100
101
@@ -120,7 +121,8 @@ class DirectiveMetadataCollectingAstVisitor extends RecursiveAstVisitor {
120
121
if (ann.arguments == null ) return ; // Ignore non-class annotations.
121
122
// TODO(pavelj): this is not a safe check for the type of the
122
123
// annotations, but good enough for now.
123
- if (ann.name.name != 'Component' && ann.name.name != 'Decorator' ) return ;
124
+ if (! _COMPONENT_OR_DECORATOR_EXPR .hasMatch (ann.name.name))
125
+ return ;
124
126
125
127
var meta = new DirectiveMetadata ()..className = clazz.name.name;
126
128
metadata.add (meta);
Original file line number Diff line number Diff line change @@ -177,6 +177,28 @@ main() {
177
177
htmlFiles.clear ();
178
178
});
179
179
});
180
+
181
+ it ('should extract functions as getters when named import is used' , () {
182
+ return generates (phases,
183
+ inputs: {
184
+ 'a|web/main.dart' : '''
185
+ import 'package:angular/angular.dart' as ng;
186
+
187
+ @ng.Component(selector: 'cmp', template: '{{foo}}')
188
+ class TestComponent {
189
+ String foo = "foo";
190
+ }
191
+
192
+ main() {} ''' ,
193
+ 'a|web/index.html' : '''
194
+ <cmp></cmp>
195
+ <script src='main.dart' type='application/dart'></script>''' ,
196
+ 'angular|lib/angular.dart' : libAngular,
197
+ },
198
+ getters: ['foo' ],
199
+ setters: ['foo' ],
200
+ symbols: []);
201
+ });
180
202
});
181
203
}
182
204
You can’t perform that action at this time.
0 commit comments