feat(dart/transform): Record Type interfaces
To support interface-based lifecycle methods (#2220), we need to be able to query for the `interface`s a class supports. Record implemented interfaces to allow mirror-less querying at runtime. Closes #2204
This commit is contained in:
@@ -42,6 +42,15 @@ void allTests() {
|
||||
|
||||
_testNgDeps('should inline `templateUrl`s expressed as adjacent strings.',
|
||||
'split_url_expression_files/hello.dart');
|
||||
|
||||
_testNgDeps('should report implemented types as `interfaces`.',
|
||||
'interfaces_files/soup.dart');
|
||||
|
||||
_testNgDeps('should not include transitively implemented types.',
|
||||
'interface_chain_files/soup.dart');
|
||||
|
||||
_testNgDeps('should not include superclasses in `interfaces`.',
|
||||
'superclass_files/soup.dart');
|
||||
}
|
||||
|
||||
void _testNgDeps(String name, String inputPath,
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
library dinner.soup.ng_deps.dart;
|
||||
|
||||
import 'soup.dart';
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(ChangingSoupComponent, {
|
||||
'factory': () => new ChangingSoupComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(selector: '[soup]')],
|
||||
'interfaces': const [PrimaryInterface]
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
library dinner.soup;
|
||||
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
|
||||
@Component(selector: '[soup]')
|
||||
class ChangingSoupComponent implements PrimaryInterface {}
|
||||
|
||||
class TernaryInterface {}
|
||||
|
||||
class SecondaryInterface implements TernaryInterface {}
|
||||
|
||||
class PrimaryInterface implements SecondaryInterface {}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
library dinner.soup.ng_deps.dart;
|
||||
|
||||
import 'soup.dart';
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(ChangingSoupComponent, {
|
||||
'factory': () => new ChangingSoupComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(selector: '[soup]')],
|
||||
'interfaces': const [OnChange]
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
library dinner.soup;
|
||||
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
|
||||
@Component(selector: '[soup]')
|
||||
class ChangingSoupComponent implements OnChange {}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
library dinner.soup.ng_deps.dart;
|
||||
|
||||
import 'soup.dart';
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
|
||||
var _visited = false;
|
||||
void initReflector(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(ChangingSoupComponent, {
|
||||
'factory': () => new ChangingSoupComponent(),
|
||||
'parameters': const [],
|
||||
'annotations': const [const Component(selector: '[soup]')]
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
library dinner.soup;
|
||||
|
||||
import 'package:angular2/src/core/annotations_impl/annotations.dart';
|
||||
|
||||
@Component(selector: '[soup]')
|
||||
class ChangingSoupComponent extends Super {}
|
||||
|
||||
class Iface {}
|
||||
|
||||
class Super implements Iface {}
|
||||
Reference in New Issue
Block a user