fix: Improve error message on missing dependency

This commit is contained in:
Misko Hevery
2015-05-18 17:19:54 -07:00
parent 7501ad11ca
commit 2ccc65d7fd
16 changed files with 85 additions and 48 deletions
@@ -0,0 +1,13 @@
import {Type} from 'angular2/src/facade/lang';
import {GetterFn, SetterFn, MethodFn} from './types';
import {List} from 'angular2/src/facade/collection';
export interface PlatformReflectionCapabilities {
factory(type: Type): Function;
interfaces(type: Type): List<any>;
parameters(type: Type): List<List<any>>;
annotations(type: Type): List<any>;
getter(name: string): GetterFn;
setter(name: string): SetterFn;
method(name: string): MethodFn;
}
@@ -3,13 +3,18 @@ library reflection.reflection;
import 'reflector.dart';
import 'types.dart';
export 'reflector.dart';
import 'platform_reflection_capabilities.dart';
import 'package:angular2/src/facade/lang.dart';
class NoReflectionCapabilities implements IReflectionCapabilities {
class NoReflectionCapabilities implements PlatformReflectionCapabilities {
Function factory(Type type) {
throw "Cannot find reflection information on ${stringify(type)}";
}
List interfaces(Type type) {
throw "Cannot find reflection information on ${stringify(type)}";
}
List parameters(Type type) {
throw "Cannot find reflection information on ${stringify(type)}";
}
@@ -3,8 +3,9 @@ library reflection.reflection_capabilities;
import 'package:angular2/src/facade/lang.dart';
import 'types.dart';
import 'dart:mirrors';
import 'platform_reflection_capabilities.dart';
class ReflectionCapabilities implements IReflectionCapabilities {
class ReflectionCapabilities implements PlatformReflectionCapabilities {
ReflectionCapabilities([metadataReader]) {}
Function factory(Type type) {
@@ -1,8 +1,9 @@
import {Type, isPresent, global, stringify, BaseException} from 'angular2/src/facade/lang';
import {List, ListWrapper} from 'angular2/src/facade/collection';
import {GetterFn, SetterFn, MethodFn, IReflectionCapabilities} from './types';
import {GetterFn, SetterFn, MethodFn} from './types';
import {PlatformReflectionCapabilities} from 'platform_reflection_capabilities';
export class ReflectionCapabilities implements IReflectionCapabilities {
export class ReflectionCapabilities implements PlatformReflectionCapabilities {
private _reflect: any;
constructor(reflect?: any) { this._reflect = isPresent(reflect) ? reflect : global.Reflect; }
+6 -4
View File
@@ -7,17 +7,19 @@ import {
StringMap,
StringMapWrapper
} from 'angular2/src/facade/collection';
import {SetterFn, GetterFn, MethodFn, IReflectionCapabilities} from './types';
export {SetterFn, GetterFn, MethodFn, IReflectionCapabilities} from './types';
import {SetterFn, GetterFn, MethodFn} from './types';
import {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
export {SetterFn, GetterFn, MethodFn} from './types';
export {PlatformReflectionCapabilities} from './platform_reflection_capabilities';
export class Reflector {
_typeInfo: Map<Type, any>;
_getters: Map<string, GetterFn>;
_setters: Map<string, SetterFn>;
_methods: Map<string, MethodFn>;
reflectionCapabilities: IReflectionCapabilities;
reflectionCapabilities: PlatformReflectionCapabilities;
constructor(reflectionCapabilities: IReflectionCapabilities) {
constructor(reflectionCapabilities: PlatformReflectionCapabilities) {
this._typeInfo = MapWrapper.create();
this._getters = MapWrapper.create();
this._setters = MapWrapper.create();
@@ -3,13 +3,3 @@ library reflection.types;
typedef SetterFn(Object obj, value);
typedef GetterFn(Object obj);
typedef MethodFn(Object obj, List args);
abstract class IReflectionCapabilities {
Function factory(Type type);
List<List<Type>> parameters(Type type);
List<Type> interfaces(Type type);
List annotations(Type type);
GetterFn getter(String name);
SetterFn setter(String name);
MethodFn method(String name);
}
+6 -14
View File
@@ -1,21 +1,13 @@
import {Type} from 'angular2/src/facade/lang';
import {List} from 'angular2/src/facade/collection';
// HACK: workaround for Traceur behavior.
// It expects all transpiled modules to contain this marker.
// TODO: remove this when we no longer use traceur
export var __esModule = true;
export {Function as GetterFn};
export {Function as SetterFn};
export {Function as MethodFn};
// TODO replace once dgeni is fixed
/**
export type SetterFn = (obj: any, value: any) => void;
export type GetterFn = (obj: any) => any;
export type MethodFn = (obj: any, args: List<any>) => any;
export interface IReflectionCapabilities {
factory(type: Type): Function;
parameters(type: Type): List<List<any>>;
interfaces(type: Type): List<any>;
annotations(type: Type): List<any>;
getter(name: string): GetterFn;
setter(name: string): SetterFn;
method(name: string): MethodFn;
}
**/