chore: removed angular2.api.ts

BREACKING CHANGE:

We export InjectMetadata instead of InjectAnnotation
This commit is contained in:
vsavkin 2015-07-08 12:04:24 -07:00
parent d6dadc6efc
commit b54e7214f0
25 changed files with 254 additions and 208 deletions

View File

@ -17,9 +17,7 @@ module.exports = function createTypeDefinitionFile(log) {
{
id: 'angular2/angular2',
modules: {
// The shape of the public API is determined by what is reexported into
// angular2/angular2, with hacks layered into angular2.api.ts
'angular2/angular2': 'angular2/angular2.api',
'angular2/angular2': 'angular2/angular2',
}
},
{

View File

@ -1,3 +0,0 @@
library angular2.angular2.api;
// Ignore this file for dart emit.
// It is used only for generating the TypeScript .d.ts file.

View File

@ -1,24 +0,0 @@
// This module is used by dgeni to produce the angular2.d.ts file.
// Re-export everything we export to the application runtime
export * from './angular2';
// Horrible hack. See
// https://docs.google.com/document/d/1nNebWTiLzz5ePcit_bjZPtaiSIFU4EsQKUlX7LX0c0A/edit
// Exports needed to make angular2.d.ts work,
// because these symbols are dependencies of other exports but are not otherwise exported.
// This should be cleaned up in one of two ways:
// 1) if the symbol is intended to be part of the public API, then re-export somewhere else
// 2) if the symbol should be omitted from the public API, then the class exposing it should
// not be exported, or should avoid exposing the symbol.
export * from './src/core/compiler/element_injector';
export {DependencyAnnotation} from './src/di/annotations_impl';
export {LifecycleEvent} from './src/core/annotations_impl/annotations';
export {Form} from './src/forms/directives/form_interface';
export {TypeDecorator, ClassDefinition} from './src/util/decorators';
export {Query} from './src/core/annotations_impl/di';
export {ControlContainer} from './src/forms/directives/control_container';
export {Injectable, Visibility} from './src/di/annotations_impl';
export {BaseQueryList} from './src/core/compiler/base_query_list';
export {AppProtoView, AppView, AppViewContainer} from './src/core/compiler/view';
export * from './src/change_detection/parser/ast';

View File

@ -4,15 +4,16 @@
export * from 'angular2/annotations';
export * from 'angular2/core';
// TO BE CLEANED UP.
export {
DehydratedException,
ExpressionChangedAfterItHasBeenChecked,
ChangeDetectionError,
ChangeDetection,
ON_PUSH,
DEFAULT,
ChangeDetectorRef,
PipeRegistry,
WrappedValue,
Pipe,
@ -20,52 +21,14 @@ export {
NullPipe,
NullPipeFactory,
defaultPipes,
DynamicChangeDetection,
JitChangeDetection,
PreGeneratedChangeDetection,
preGeneratedProtoDetectors,
defaultPipeRegistry,
DirectiveIndex,
BindingRecord,
ProtoChangeDetector,
ChangeDispatcher,
ChangeDetector,
Locals,
ChangeDetectorDefinition,
BasePipe,
DirectiveRecord
Locals
} from './change_detection';
export {
Inject,
Optional,
Injectable,
forwardRef,
resolveForwardRef,
ForwardRefFn,
Injector,
ProtoInjector,
Binding,
bind,
Key,
NoBindingError,
AbstractBindingError,
AsyncBindingError,
CyclicDependencyError,
InstantiationError,
InvalidBindingError,
NoAnnotationError,
OpaqueToken,
ResolvedBinding,
BindingBuilder,
Dependency,
Visibility,
Self,
Parent,
Ancestor,
Unbounded,
DependencyProvider
} from './di';
export * from './di';
export * from './forms';
export * from './directives';
@ -95,5 +58,11 @@ export {
} from './forms';
export * from './http';
export * from 'angular2/src/render/api';
export {
EventDispatcher,
Renderer,
RenderElementRef,
RenderViewRef,
RenderProtoViewRef
} from 'angular2/src/render/api';
export {DomRenderer, DOCUMENT_TOKEN} from 'angular2/src/render/dom/dom_renderer';

View File

@ -17,6 +17,7 @@ export {Compiler} from 'angular2/src/core/compiler/compiler';
export {AppViewManager} from 'angular2/src/core/compiler/view_manager';
export {QueryList} from 'angular2/src/core/compiler/query_list';
export {BaseQueryList} from 'angular2/src/core/compiler/base_query_list';
export {ElementRef} from 'angular2/src/core/compiler/element_ref';
export {RenderElementRef} from 'angular2/src/render/api';
export {ViewRef, ProtoViewRef} from 'angular2/src/core/compiler/view_ref';

View File

@ -6,28 +6,22 @@
*/
export {
InjectAnnotation,
OptionalAnnotation,
InjectableAnnotation,
DependencyAnnotation,
VisibilityAnnotation,
SelfAnnotation,
ParentAnnotation,
AncestorAnnotation,
UnboundedAnnotation
} from './src/di/annotations';
InjectMetadata,
OptionalMetadata,
InjectableMetadata,
VisibilityMetadata,
SelfMetadata,
ParentMetadata,
AncestorMetadata,
UnboundedMetadata,
DependencyMetadata,
self,
unbounded
} from './src/di/metadata';
// we have to reexport * because Dart and TS export two different sets of types
export * from './src/di/decorators';
export {
Inject,
Optional,
Injectable,
Visibility,
Self,
Parent,
Ancestor,
Unbounded
} from './src/di/decorators';
export {self} from './src/di/annotations_impl';
export {forwardRef, resolveForwardRef, ForwardRefFn} from './src/di/forward_ref';
export {
resolveBindings,
@ -38,6 +32,7 @@ export {
PUBLIC,
PRIVATE,
undefinedValue
} from './src/di/injector';
export {Binding, BindingBuilder, ResolvedBinding, Dependency, bind} from './src/di/binding';
export {Key, KeyRegistry, TypeLiteral} from './src/di/key';

View File

@ -1,6 +0,0 @@
/**
* @module
* @public
* @description
* Annotations which control how the dependencies are resolved by the {@link Injector}.
*/

View File

@ -0,0 +1,6 @@
/**
* @module
* @public
* @description
* Metadata which control how the dependencies are resolved by the {@link Injector}.
*/

View File

@ -16,6 +16,8 @@
export {AbstractControl, Control, ControlGroup, ControlArray} from './src/forms/model';
export {AbstractControlDirective} from './src/forms/directives/abstract_control_directive';
export {Form} from './src/forms/directives/form_interface';
export {ControlContainer} from './src/forms/directives/control_container';
export {NgControlName} from './src/forms/directives/ng_control_name';
export {NgFormControl} from './src/forms/directives/ng_form_control';
export {NgModel} from './src/forms/directives/ng_model';

View File

@ -1,6 +1,6 @@
import {CONST, CONST_EXPR} from 'angular2/src/facade/lang';
import {List} from 'angular2/src/facade/collection';
import {Injectable, self} from 'angular2/src/di/annotations_impl';
import {InjectableMetadata, self} from 'angular2/src/di/metadata';
import {DEFAULT} from 'angular2/change_detection';
/**
@ -407,7 +407,7 @@ import {DEFAULT} from 'angular2/change_detection';
* @exportedAs angular2/annotations
*/
@CONST()
export class Directive extends Injectable {
export class Directive extends InjectableMetadata {
/**
* The CSS selector that triggers the instantiation of a directive.
*

View File

@ -1,5 +1,5 @@
import {CONST, Type, stringify, isPresent, StringWrapper, isString} from 'angular2/src/facade/lang';
import {DependencyAnnotation} from 'angular2/src/di/annotations_impl';
import {DependencyMetadata} from 'angular2/src/di/metadata';
import {resolveForwardRef} from 'angular2/di';
/**
@ -31,7 +31,7 @@ import {resolveForwardRef} from 'angular2/di';
* @exportedAs angular2/annotations
*/
@CONST()
export class Attribute extends DependencyAnnotation {
export class Attribute extends DependencyMetadata {
constructor(public attributeName: string) { super(); }
get token() {
@ -53,7 +53,7 @@ export class Attribute extends DependencyAnnotation {
* @exportedAs angular2/annotations
*/
@CONST()
export class Query extends DependencyAnnotation {
export class Query extends DependencyMetadata {
descendants: boolean;
constructor(private _selector: Type | string,
{descendants = false}: {descendants?: boolean} = {}) {

View File

@ -26,8 +26,7 @@ import {
CyclicDependencyError,
resolveForwardRef,
resolveBindings,
Visibility,
VisibilityAnnotation,
VisibilityMetadata,
DependencyProvider,
self
} from 'angular2/di';

View File

@ -19,8 +19,8 @@ export class AppViewManager {
/**
* @private
*/
constructor(public _viewPool: AppViewPool, public _viewListener: AppViewListener,
public _utils: AppViewManagerUtils, public _renderer: Renderer) {}
constructor(private _viewPool: AppViewPool, private _viewListener: AppViewListener,
private _utils: AppViewManagerUtils, private _renderer: Renderer) {}
/**
* Returns associated Component {@link ViewRef} from {@link ElementRef}.

View File

@ -1,3 +0,0 @@
library angular2.di.annotations;
export './annotations_impl.dart';

View File

@ -1,16 +0,0 @@
/**
* This indirection is needed to free up Component, etc symbols in the public API
* to be used by the decorator versions of these annotations.
*/
export {
Inject as InjectAnnotation,
Optional as OptionalAnnotation,
Injectable as InjectableAnnotation,
Visibility as VisibilityAnnotation,
Self as SelfAnnotation,
Parent as ParentAnnotation,
Ancestor as AncestorAnnotation,
Unbounded as UnboundedAnnotation,
DependencyAnnotation, // abstract base class, does not need a decorator
} from './annotations_impl';

View File

@ -12,13 +12,13 @@ import {List, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {reflector} from 'angular2/src/reflection/reflection';
import {Key} from './key';
import {
Inject,
Injectable,
Visibility,
Optional,
InjectMetadata,
InjectableMetadata,
VisibilityMetadata,
OptionalMetadata,
unbounded,
DependencyAnnotation
} from './annotations_impl';
DependencyMetadata
} from './metadata';
import {NoAnnotationError} from './exceptions';
import {resolveForwardRef} from './forward_ref';
@ -26,7 +26,7 @@ import {resolveForwardRef} from './forward_ref';
* @private
*/
export class Dependency {
constructor(public key: Key, public optional: boolean, public visibility: Visibility,
constructor(public key: Key, public optional: boolean, public visibility: VisibilityMetadata,
public properties: List<any>) {}
static fromKey(key: Key): Dependency {
@ -421,16 +421,16 @@ function _extractToken(typeOrFunc, annotations /*List<any> | any*/,
token = paramAnnotation;
defaultVisibility = _defaulVisiblity(token);
} else if (paramAnnotation instanceof Inject) {
} else if (paramAnnotation instanceof InjectMetadata) {
token = paramAnnotation.token;
} else if (paramAnnotation instanceof Optional) {
} else if (paramAnnotation instanceof OptionalMetadata) {
optional = true;
} else if (paramAnnotation instanceof Visibility) {
} else if (paramAnnotation instanceof VisibilityMetadata) {
visibility = paramAnnotation;
} else if (paramAnnotation instanceof DependencyAnnotation) {
} else if (paramAnnotation instanceof DependencyMetadata) {
if (isPresent(paramAnnotation.token)) {
token = paramAnnotation.token;
}
@ -454,7 +454,8 @@ function _extractToken(typeOrFunc, annotations /*List<any> | any*/,
function _defaulVisiblity(typeOrFunc) {
try {
if (!(typeOrFunc instanceof Type)) return unbounded;
var f = ListWrapper.filter(reflector.annotations(typeOrFunc), s => s instanceof Injectable);
var f =
ListWrapper.filter(reflector.annotations(typeOrFunc), s => s instanceof InjectableMetadata);
return f.length === 0 ? unbounded : f[0].visibility;
} catch (e) {
return unbounded;

View File

@ -1,5 +1,53 @@
library angular2.di.decorators;
/* This file is empty because, Dart does not have decorators. */
import 'metadata.dart';
export 'metadata.dart';
export 'annotations.dart';
/**
* {@link InjectMetadata}.
*/
class Inject extends InjectMetadata {
const Inject(dynamic token): super(token);
}
/**
* {@link OptionalMetadata}.
*/
class Optional extends OptionalMetadata {
const Optional(): super();
}
/**
* {@link InjectableMetadata}.
*/
class Injectable extends InjectableMetadata {
const Injectable([VisibilityMetadata visibility = unbounded]): super(visibility);
}
/**
* {@link SelfMetadata}.
*/
class Self extends SelfMetadata {
const Self(): super();
}
/**
* {@link ParentMetadata}.
*/
class Parent extends ParentMetadata {
const Parent({bool self}): super(self:self);
}
/**
* {@link AncestorMetadata}.
*/
class Ancestor extends AncestorMetadata {
const Ancestor({bool self}): super(self:self);
}
/**
* {@link UnboundedMetadata}.
*/
class Unbounded extends UnboundedMetadata {
const Unbounded({bool self}): super(self:self);
}

View File

@ -1,20 +1,102 @@
import {
InjectAnnotation,
OptionalAnnotation,
InjectableAnnotation,
VisibilityAnnotation,
SelfAnnotation,
ParentAnnotation,
AncestorAnnotation,
UnboundedAnnotation
} from './annotations';
import {makeDecorator, makeParamDecorator} from '../util/decorators';
InjectMetadata,
OptionalMetadata,
InjectableMetadata,
SelfMetadata,
VisibilityMetadata,
ParentMetadata,
AncestorMetadata,
UnboundedMetadata
} from './metadata';
import {makeDecorator, makeParamDecorator, TypeDecorator} from '../util/decorators';
export var Inject = makeParamDecorator(InjectAnnotation);
export var Optional = makeParamDecorator(OptionalAnnotation);
export var Injectable = makeDecorator(InjectableAnnotation);
export var Visibility = makeParamDecorator(VisibilityAnnotation);
export var Self = makeParamDecorator(SelfAnnotation);
export var Parent = makeParamDecorator(ParentAnnotation);
export var Ancestor = makeParamDecorator(AncestorAnnotation);
export var Unbounded = makeParamDecorator(UnboundedAnnotation);
/**
* Factory for creating {@link InjectMetadata}.
*/
export interface InjectFactory {
(token: any): any;
new (token: any): InjectMetadata;
}
/**
* Factory for creating {@link OptionalMetadata}.
*/
export interface OptionalFactory {
(): any;
new (): OptionalMetadata;
}
/**
* Factory for creating {@link InjectableMetadata}.
*/
export interface InjectableFactory {
(visibility?: VisibilityMetadata): any;
new (visibility?: VisibilityMetadata): InjectableMetadata;
}
/**
* Factory for creating {@link SelfMetadata}.
*/
export interface SelfFactory {
(): any;
new (): SelfMetadata;
}
/**
* Factory for creating {@link ParentMetadata}.
*/
export interface ParentFactory {
({self: boolean}?): any;
new ({self: boolean}?): ParentMetadata;
}
/**
* Factory for creating {@link AncestorMetadata}.
*/
export interface AncestorFactory {
({self: boolean}?): any;
new ({self: boolean}?): AncestorMetadata;
}
/**
* Factory for creating {@link UnboundedMetadata}.
*/
export interface UnboundedFactory {
({self: boolean}?): any;
new ({self: boolean}?): UnboundedMetadata;
}
/**
* Factory for creating {@link InjectMetadata}.
*/
export var Inject: InjectFactory = makeParamDecorator(InjectMetadata);
/**
* Factory for creating {@link OptionalMetadata}.
*/
export var Optional: OptionalFactory = makeParamDecorator(OptionalMetadata);
/**
* Factory for creating {@link InjectableMetadata}.
*/
export var Injectable: InjectableFactory = <InjectableFactory>makeDecorator(InjectableMetadata);
/**
* Factory for creating {@link SelfMetadata}.
*/
export var Self: SelfFactory = makeParamDecorator(SelfMetadata);
/**
* Factory for creating {@link ParentMetadata}.
*/
export var Parent: ParentFactory = makeParamDecorator(ParentMetadata);
/**
* Factory for creating {@link AncestorMetadata}.
*/
export var Ancestor: AncestorFactory = makeParamDecorator(AncestorMetadata);
/**
* Factory for creating {@link UnboundedMetadata}.
*/
export var Unbounded: UnboundedFactory = makeParamDecorator(UnboundedMetadata);

View File

@ -14,7 +14,7 @@ import {
import {FunctionWrapper, Type, isPresent, isBlank, CONST_EXPR} from 'angular2/src/facade/lang';
import {Key} from './key';
import {resolveForwardRef} from './forward_ref';
import {Visibility, unbounded} from './annotations_impl';
import {VisibilityMetadata, unbounded} from './metadata';
const _constructing = CONST_EXPR(new Object());
const _notFound = CONST_EXPR(new Object());
@ -713,7 +713,7 @@ export class Injector {
}
}
private _getByKey(key: Key, depVisibility: Visibility, optional: boolean,
private _getByKey(key: Key, depVisibility: VisibilityMetadata, optional: boolean,
bindingVisibility: number): any {
if (key.token === Injector) {
return this;

View File

@ -1,7 +1,7 @@
import {CONST, CONST_EXPR, stringify, isBlank, isPresent} from "angular2/src/facade/lang";
/**
* A parameter annotation that specifies a dependency.
* A parameter metadata that specifies a dependency.
*
* ```
* class AComponent {
@ -9,17 +9,17 @@ import {CONST, CONST_EXPR, stringify, isBlank, isPresent} from "angular2/src/fac
* }
* ```
*
* @exportedAs angular2/di_annotations
* @exportedAs angular2/di_metadata
*/
@CONST()
export class Inject {
export class InjectMetadata {
constructor(public token) {}
toString(): string { return `@Inject(${stringify(this.token)})`; }
}
/**
* A parameter annotation that marks a dependency as optional. {@link Injector} provides `null` if
* A parameter metadata that marks a dependency as optional. {@link Injector} provides `null` if
* the dependency is not found.
*
* ```
@ -30,23 +30,23 @@ export class Inject {
* }
* ```
*
* @exportedAs angular2/di_annotations
* @exportedAs angular2/di_metadata
*/
@CONST()
export class Optional {
export class OptionalMetadata {
toString(): string { return `@Optional()`; }
}
/**
* `DependencyAnnotation` is used by the framework to extend DI.
* `DependencyMetadata is used by the framework to extend DI.
*
* Only annotations implementing `DependencyAnnotation` are added to the list of dependency
* Only metadata implementing `DependencyMetadata` are added to the list of dependency
* properties.
*
* For example:
*
* ```
* class Parent extends DependencyAnnotation {}
* class Parent extends DependencyMetadata {}
* class NotDependencyProperty {}
*
* class AComponent {
@ -63,15 +63,15 @@ export class Optional {
* The framework can use `new Parent()` to handle the `aService` dependency
* in a specific way.
*
* @exportedAs angular2/di_annotations
* @exportedAs angular2/di_metadata
*/
@CONST()
export class DependencyAnnotation {
export class DependencyMetadata {
get token() { return null; }
}
/**
* A marker annotation that marks a class as available to `Injector` for creation. Used by tooling
* A marker metadata that marks a class as available to `Injector` for creation. Used by tooling
* for generating constructor stubs.
*
* ```
@ -82,11 +82,11 @@ export class DependencyAnnotation {
* @Injectable
* class UsefulService {}
* ```
* @exportedAs angular2/di_annotations
* @exportedAs angular2/di_metadata
*/
@CONST()
export class Injectable {
constructor(public visibility: Visibility = unbounded) {}
export class InjectableMetadata {
constructor(public visibility: VisibilityMetadata = unbounded) {}
}
/**
@ -94,10 +94,10 @@ export class Injectable {
*
* See {@link Self}, {@link Parent}, {@link Ancestor}, {@link Unbounded}.
*
* @exportedAs angular2/di_annotations
* @exportedAs angular2/di_metadata
*/
@CONST()
export class Visibility {
export class VisibilityMetadata {
constructor(public depth: number, public crossBoundaries: boolean, public _includeSelf: boolean) {
}
@ -129,12 +129,12 @@ export class Visibility {
* @exportedAs angular2/di
*/
@CONST()
export class Self extends Visibility {
export class SelfMetadata extends VisibilityMetadata {
constructor() { super(0, false, true); }
toString(): string { return `@Self()`; }
}
export const self = CONST_EXPR(new Self());
export const self = CONST_EXPR(new SelfMetadata());
/**
* Specifies that an injector should retrieve a dependency from the direct parent.
@ -169,7 +169,7 @@ export const self = CONST_EXPR(new Self());
* @exportedAs angular2/di
*/
@CONST()
export class Parent extends Visibility {
export class ParentMetadata extends VisibilityMetadata {
constructor({self}: {self?: boolean} = {}) { super(1, false, self); }
toString(): string { return `@Parent(self: ${this.includeSelf}})`; }
}
@ -208,7 +208,7 @@ export class Parent extends Visibility {
* @exportedAs angular2/di
*/
@CONST()
export class Ancestor extends Visibility {
export class AncestorMetadata extends VisibilityMetadata {
constructor({self}: {self?: boolean} = {}) { super(999999, false, self); }
toString(): string { return `@Ancestor(self: ${this.includeSelf}})`; }
}
@ -247,9 +247,9 @@ export class Ancestor extends Visibility {
* @exportedAs angular2/di
*/
@CONST()
export class Unbounded extends Visibility {
export class UnboundedMetadata extends VisibilityMetadata {
constructor({self}: {self?: boolean} = {}) { super(999999, true, self); }
toString(): string { return `@Unbounded(self: ${this.includeSelf}})`; }
}
export const unbounded = CONST_EXPR(new Unbounded({self: true}));
export const unbounded = CONST_EXPR(new UnboundedMetadata({self: true}));

View File

@ -10,10 +10,6 @@ import 'logging.dart' show logger;
/// on a class. These classes are re-exported in many places so this covers all
/// the possible libraries which could provide them.
const INJECTABLES = const [
const AnnotationDescriptor(
'Injectable', 'package:angular2/src/di/annotations.dart', null),
const AnnotationDescriptor(
'Injectable', 'package:angular2/src/di/annotations_impl.dart', null),
const AnnotationDescriptor(
'Injectable', 'package:angular2/src/di/decorators.dart', null),
const AnnotationDescriptor('Injectable', 'package:angular2/di.dart', null),

View File

@ -40,8 +40,7 @@ import {
Directive,
onDestroy
} from 'angular2/annotations';
import {bind, Injector, Binding, resolveBindings, Optional, Inject, Injectable, Self, Parent, Ancestor, Unbounded, self} from 'angular2/di';
import * as diAnn from 'angular2/src/di/annotations_impl';
import {bind, Injector, Binding, resolveBindings, Optional, Inject, Injectable, Self, Parent, Ancestor, Unbounded, self, InjectMetadata, ParentMetadata} from 'angular2/di';
import {AppProtoView, AppView} from 'angular2/src/core/compiler/view';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
@ -595,7 +594,7 @@ export function main() {
bind('injectable2')
.toFactory(
(val) => `${val}-injectable2`,
[[new diAnn.Inject('injectable1'), new diAnn.Parent()]])
[[new InjectMetadata('injectable1'), new ParentMetadata()]])
]
}))]);
expect(childInj.get('injectable2')).toEqual('injectable1-injectable2');

View File

@ -43,7 +43,8 @@ import {
Inject,
Parent,
Ancestor,
Unbounded
Unbounded,
UnboundedMetadata
} from 'angular2/di';
import {
PipeFactory,
@ -58,7 +59,6 @@ import {
import {Directive, Component, View, Attribute, Query} from 'angular2/annotations';
import * as viewAnn from 'angular2/src/core/annotations_impl/view';
import * as visAnn from 'angular2/src/di/annotations_impl';
import {QueryList} from 'angular2/src/core/compiler/query_list';
@ -1779,7 +1779,7 @@ function createParentBus(peb) {
selector: 'parent-providing-event-bus',
hostInjector: [
new Binding(EventBus,
{toFactory: createParentBus, deps: [[EventBus, new visAnn.Unbounded()]]})
{toFactory: createParentBus, deps: [[EventBus, new UnboundedMetadata()]]})
]
})
@View({

View File

@ -14,20 +14,22 @@ import {
ResolvedBinding,
Key,
forwardRef,
DependencyAnnotation,
Injectable
DependencyMetadata,
Injectable,
InjectMetadata,
self,
unbounded
} from 'angular2/di';
import {InjectorInlineStrategy, InjectorDynamicStrategy} from 'angular2/src/di/injector';
import {Optional, Inject} from 'angular2/src/di/decorators';
import * as ann from 'angular2/src/di/annotations_impl';
class CustomDependencyAnnotation extends DependencyAnnotation {}
class CustomDependencyMetadata extends DependencyMetadata {}
class Engine {}
@Injectable(ann.self)
@Injectable(self)
class EngineWithSetVisibility {
}
@ -407,12 +409,12 @@ export function main() {
var bindings = Injector.resolve([
bind("token")
.toFactory((e) => "result",
[[new ann.Inject("dep"), new CustomDependencyAnnotation()]])
[[new InjectMetadata("dep"), new CustomDependencyMetadata()]])
]);
var binding = bindings[0];
expect(binding.dependencies[0].key.token).toEqual("dep");
expect(binding.dependencies[0].properties).toEqual([new CustomDependencyAnnotation()]);
expect(binding.dependencies[0].properties).toEqual([new CustomDependencyMetadata()]);
});
});
@ -420,13 +422,13 @@ export function main() {
it("should use the provided visibility", () => {
var bindings = Injector.resolve([CarNeedsEngineWithSetVisibility, EngineWithSetVisibility]);
var carBinding = bindings[0];
expect(carBinding.dependencies[0].visibility).toEqual(ann.self);
expect(carBinding.dependencies[0].visibility).toEqual(self);
});
it("should set the default visibility to unbounded", () => {
var bindings = Injector.resolve([Car, Engine]);
var carBinding = bindings[0];
expect(carBinding.dependencies[0].visibility).toEqual(ann.unbounded);
expect(carBinding.dependencies[0].visibility).toEqual(unbounded);
});
});
});

View File

@ -43,8 +43,8 @@ void allTests() {
'angular2|lib/src/reflection/reflection_capabilities.dart':
'../common/reflection_capabilities.dart',
'angular2|lib/di.dart': '../../../lib/di.dart',
'angular2|lib/src/di/annotations_impl.dart':
'../../../lib/src/di/annotations_impl.dart',
'angular2|lib/src/di/decorators.dart':
'../../../lib/src/di/decorators.dart',
};
var tests = [