refactor: rename annotations to metadata
BREAKING CHANGE (maybe) Well as long as our customers use public API this should not be a breaking change, but we have changed import structure as well as internal names, so it could be breaking. import: angular2/annotations => angular2/metadata Classes: *Annotations => *Metadata renderer.DirectiveMetadata => renderer.RendererDirectiveMetadata renderer.ElementBinder => renderer.RendererElementBinder impl.Directive => impl.DirectiveMetadata impl.Component => impl.ComponentMetadata impl.View => impl.ViewMetadata Closes #3660
This commit is contained in:
committed by
Miško Hevery
parent
5e6317fecc
commit
ea6673947c
@@ -18,16 +18,11 @@ const INJECTABLES = const [
|
||||
];
|
||||
|
||||
const DIRECTIVES = const [
|
||||
const ClassDescriptor(
|
||||
'Directive', 'package:angular2/src/core/annotations/annotations.dart',
|
||||
const ClassDescriptor('Directive', 'package:angular2/src/core/metadatada/directive.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor(
|
||||
'Directive', 'package:angular2/src/core/annotations/decorators.dart',
|
||||
const ClassDescriptor('Directive', 'package:angular2/src/core/metadata.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor('Directive',
|
||||
'package:angular2/src/core/annotations_impl/annotations.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor('Directive', 'package:angular2/annotations.dart',
|
||||
const ClassDescriptor('Directive', 'package:angular2/metadata.dart',
|
||||
superClass: 'Injectable'),
|
||||
const ClassDescriptor('Directive', 'package:angular2/angular2.dart',
|
||||
superClass: 'Injectable'),
|
||||
@@ -38,34 +33,26 @@ const DIRECTIVES = const [
|
||||
];
|
||||
|
||||
const COMPONENTS = const [
|
||||
const ClassDescriptor(
|
||||
'Component', 'package:angular2/src/core/annotations/annotations.dart',
|
||||
const ClassDescriptor('Component', 'package:angular2/src/core/metadata/directive.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor(
|
||||
'Component', 'package:angular2/src/core/annotations/decorators.dart',
|
||||
const ClassDescriptor('Component', 'package:angular2/src/core/metadata.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component',
|
||||
'package:angular2/src/core/annotations_impl/annotations.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/annotations.dart',
|
||||
const ClassDescriptor('Component', 'package:angular2/metadata.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/angular2.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/bootstrap_static.dart',
|
||||
superClass: 'Directive'),
|
||||
const ClassDescriptor('Component', 'package:angular2/core.dart',
|
||||
superClass: 'Directive'),
|
||||
superClass: '`Directive'),
|
||||
];
|
||||
|
||||
const VIEWS = const [
|
||||
const ClassDescriptor('View', 'package:angular2/view.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/bootstrap_static.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/core.dart'),
|
||||
const ClassDescriptor(
|
||||
'View', 'package:angular2/src/core/annotations/view.dart'),
|
||||
const ClassDescriptor(
|
||||
'View', 'package:angular2/src/core/annotations_impl/view.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/src/core/metadata/view.dart'),
|
||||
const ClassDescriptor('View', 'package:angular2/src/core/metadata.dart'),
|
||||
];
|
||||
|
||||
/// Checks if a given [Annotation] matches any of the given
|
||||
|
||||
@@ -4,10 +4,10 @@ import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/element.dart';
|
||||
import 'package:angular2/src/render/api.dart';
|
||||
|
||||
/// Reads [DirectiveMetadata] from the `node`. `node` is expected to be an
|
||||
/// Reads [RenderDirectiveMetadata] from the `node`. `node` is expected to be an
|
||||
/// instance of [Annotation], [NodeList<Annotation>], ListLiteral, or
|
||||
/// [InstanceCreationExpression].
|
||||
DirectiveMetadata readDirectiveMetadata(dynamic node) {
|
||||
RenderDirectiveMetadata readDirectiveMetadata(dynamic node) {
|
||||
assert(node is Annotation ||
|
||||
node is NodeList ||
|
||||
node is InstanceCreationExpression ||
|
||||
@@ -22,10 +22,10 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||
// TODO(kegluneq): Detect subtypes & implementations of `Directive`s.
|
||||
switch (annotationName) {
|
||||
case 'Directive':
|
||||
byNameMatch = DirectiveMetadata.DIRECTIVE_TYPE;
|
||||
byNameMatch = RenderDirectiveMetadata.DIRECTIVE_TYPE;
|
||||
break;
|
||||
case 'Component':
|
||||
byNameMatch = DirectiveMetadata.COMPONENT_TYPE;
|
||||
byNameMatch = RenderDirectiveMetadata.COMPONENT_TYPE;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
@@ -34,8 +34,8 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||
var byResolvedAst = -1;
|
||||
var libName = element.library.name;
|
||||
// If we have resolved, ensure the library is correct.
|
||||
if (libName == 'angular2.src.core.annotations.annotations' ||
|
||||
libName == 'angular2.src.core.annotations_impl.annotations') {
|
||||
if (libName == 'angular2.src.core.metadata.directives' ||
|
||||
libName == 'angular2.src.core.metadata') {
|
||||
byResolvedAst = byNameMatch;
|
||||
}
|
||||
// TODO(kegluneq): @keertip, can we expose this as a warning?
|
||||
@@ -45,7 +45,7 @@ num _getDirectiveType(String annotationName, Element element) {
|
||||
}
|
||||
|
||||
/// Visitor responsible for processing the `annotations` property of a
|
||||
/// [RegisterType] object and pulling out [DirectiveMetadata].
|
||||
/// [RegisterType] object and pulling out [RenderDirectiveMetadata].
|
||||
class _DirectiveMetadataVisitor extends Object
|
||||
with RecursiveAstVisitor<Object> {
|
||||
bool get _hasMeta => _type != null;
|
||||
@@ -87,7 +87,7 @@ class _DirectiveMetadataVisitor extends Object
|
||||
_events = [];
|
||||
}
|
||||
|
||||
DirectiveMetadata get meta => DirectiveMetadata.create(
|
||||
RenderDirectiveMetadata get meta => RenderDirectiveMetadata.create(
|
||||
type: _type,
|
||||
selector: _selector,
|
||||
compileChildren: _compileChildren,
|
||||
|
||||
@@ -11,32 +11,32 @@ export 'class_matcher_base.dart' show ClassDescriptor;
|
||||
/// covers all libraries which provide them.
|
||||
const _ON_CHANGE_INTERFACES = const [
|
||||
const ClassDescriptor('OnChange', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnChange', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnChange', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnChange', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_DESTROY_INTERFACES = const [
|
||||
const ClassDescriptor('OnDestroy', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnDestroy', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnDestroy', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnDestroy', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_CHECK_INTERFACES = const [
|
||||
const ClassDescriptor('OnCheck', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnCheck', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnCheck', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnCheck', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_INIT_INTERFACES = const [
|
||||
const ClassDescriptor('OnInit', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor('OnInit', 'package:angular2/annotations.dart'),
|
||||
const ClassDescriptor('OnInit', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnInit', 'package:angular2/src/core/compiler/interfaces.dart'),
|
||||
];
|
||||
const _ON_ALL_CHANGES_DONE_INTERFACES = const [
|
||||
const ClassDescriptor('OnAllChangesDone', 'package:angular2/angular2.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnAllChangesDone', 'package:angular2/annotations.dart'),
|
||||
'OnAllChangesDone', 'package:angular2/metadata.dart'),
|
||||
const ClassDescriptor(
|
||||
'OnAllChangesDone', 'package:angular2/src/core/compiler/interfaces.dart')
|
||||
];
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'logging.dart';
|
||||
/// easier.
|
||||
class NgMeta {
|
||||
/// Directive metadata for each type annotated as a directive.
|
||||
final Map<String, DirectiveMetadata> types;
|
||||
final Map<String, RenderDirectiveMetadata> types;
|
||||
|
||||
/// List of other types and names associated with a given name.
|
||||
final Map<String, List<String>> aliases;
|
||||
@@ -66,7 +66,7 @@ class NgMeta {
|
||||
}
|
||||
|
||||
/// Returns the metadata for every type associated with the given [alias].
|
||||
List<DirectiveMetadata> flatten(String alias) {
|
||||
List<RenderDirectiveMetadata> flatten(String alias) {
|
||||
var result = [];
|
||||
var seen = new Set();
|
||||
helper(name) {
|
||||
|
||||
@@ -23,7 +23,7 @@ class RegisteredType {
|
||||
/// The annotations registered.
|
||||
final Expression annotations;
|
||||
|
||||
DirectiveMetadata _directiveMetadata = null;
|
||||
RenderDirectiveMetadata _directiveMetadata = null;
|
||||
|
||||
RegisteredType._(this.typeName, this.registerMethod, this.factoryFn,
|
||||
this.parameters, this.annotations);
|
||||
@@ -37,7 +37,7 @@ class RegisteredType {
|
||||
visitor.factoryFn, visitor.parameters, visitor.annotations);
|
||||
}
|
||||
|
||||
DirectiveMetadata get directiveMetadata {
|
||||
RenderDirectiveMetadata get directiveMetadata {
|
||||
if (_directiveMetadata == null) {
|
||||
try {
|
||||
_directiveMetadata = readDirectiveMetadata(annotations);
|
||||
|
||||
@@ -3,7 +3,7 @@ library angular2.transform.directive_processor.visitors;
|
||||
import 'dart:async';
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/java_core.dart';
|
||||
import 'package:angular2/annotations.dart' show LifecycleEvent;
|
||||
import 'package:angular2/metadata.dart' show LifecycleEvent;
|
||||
import 'package:angular2/src/render/xhr.dart' show XHR;
|
||||
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
||||
import 'package:angular2/src/transform/common/async_string_writer.dart';
|
||||
|
||||
@@ -27,7 +27,7 @@ class ViewDefinitionResults {
|
||||
}
|
||||
|
||||
class ViewDefinitionEntry {
|
||||
final DirectiveMetadata hostMetadata;
|
||||
final RenderDirectiveMetadata hostMetadata;
|
||||
final ViewDefinition viewDef;
|
||||
|
||||
ViewDefinitionEntry._(this.hostMetadata, this.viewDef);
|
||||
@@ -113,7 +113,7 @@ class _ViewDefinitionCreator {
|
||||
|
||||
/// Reads the `.ng_meta.json` files associated with all of `entryPoint`'s
|
||||
/// imports and creates a map `Type` name, prefixed if appropriate to the
|
||||
/// associated [DirectiveMetadata].
|
||||
/// associated [RenderDirectiveMetadata].
|
||||
///
|
||||
/// For example, if in `entryPoint` we have:
|
||||
///
|
||||
@@ -129,13 +129,13 @@ class _ViewDefinitionCreator {
|
||||
/// ```
|
||||
///
|
||||
/// This method will look for `component.ng_meta.json`to contain the
|
||||
/// serialized [DirectiveMetadata] for `MyComponent` and any other
|
||||
/// serialized [RenderDirectiveMetadata] for `MyComponent` and any other
|
||||
/// `Directive`s declared in `component.dart`. We use this information to
|
||||
/// build a map:
|
||||
///
|
||||
/// ```
|
||||
/// {
|
||||
/// "prefix.MyComponent": [DirectiveMetadata for MyComponent],
|
||||
/// "prefix.MyComponent": [RenderDirectiveMetadata for MyComponent],
|
||||
/// ...<any other entries>...
|
||||
/// }
|
||||
/// ```
|
||||
@@ -184,7 +184,7 @@ class _TemplateExtractVisitor extends Object with RecursiveAstVisitor<Object> {
|
||||
@override
|
||||
Object visitInstanceCreationExpression(InstanceCreationExpression node) {
|
||||
if (_isViewAnnotation(node)) {
|
||||
viewDef = new ViewDefinition(directives: <DirectiveMetadata>[]);
|
||||
viewDef = new ViewDefinition(directives: <RenderDirectiveMetadata>[]);
|
||||
node.visitChildren(this);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user