-
Notifications
You must be signed in to change notification settings - Fork 248
Add support for inheritance in Directives and Components #829
Conversation
yes, you are on the right track See: https://github.com/angular/angular.dart/search?q=MetadataExtractor&ref=cmdform |
return metadata; | ||
} | ||
|
||
Iterable<InstanceMirror> _mergeMetadata(Iterable first, Iterable second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Refactor this mess
This looks like the right approach. Does this cause the transformer tests to fail? If not this means we need to add more tests to the transformer. |
Iterable _mergeMetadata( | ||
Iterable superClassMetadataList, Iterable classMetadataList) { | ||
|
||
if(superClassMetadataList == null || superClassMetadataList.isEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit- I believe that this DynamicMetadataExtractor should never return null, so the null superClassMetadataList case and null classMetadataList cases should never be hit.
It seems that the static route requires that the subclass has an annotation on it, but that the dynamic one does not. Should the subclass always have an annotation? |
@blois Yes, I'll fix that. I need to refactor the dynamic generator a bit. Essentially it should not require an annotation on the base class. |
@@ -13,7 +13,7 @@ import 'package:unittest/unittest.dart'; | |||
|
|||
void main() { | |||
describe('expression_extractor', () { | |||
it('should extract all expressions from source and templates', () { | |||
xit('should extract all expressions from source and templates', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is broken by ClassElement classElement = clazz.element;
in source_metadata_extractor.dart:171. As @blois already said, element is not yet resolved and thus it is null. This works fine when transformers are used as element is resolved, it should only fail if command line (generate-expressions.sh) is used.
This breaks bin/expression_extractor.dart which is invoked from scripts/generate-expressions.sh - @mhevery Is this still used?
So the command-line extractor is working again? Cool! Changes look good to me (with one test comment). |
@blois Fixed "iit". Yes, it works (depending on what's your definition of work). - Inheritance will not work if one uses command line generator, but the old functionality is not broken. |
This patch supports the following scenario: ``` class Base { @Ngattr('foo') var foo; } @ngdirective(selector:'my-directive') class MyDirective extends Base { @Ngattr('bar') var bar; } ``` MyDirective will now have both properties, foo and bar.
Implements #457