refactor: remove most facades (#12399)
This commit is contained in:

committed by
Igor Minar

parent
e319cfefc3
commit
57051f01ce
@ -6,7 +6,6 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {BaseError, WrappedError} from '../facade/errors';
|
||||
import {stringify} from '../facade/lang';
|
||||
import {Type} from '../type';
|
||||
@ -17,7 +16,7 @@ import {ReflectiveKey} from './reflective_key';
|
||||
function findFirstClosedCycle(keys: any[]): any[] {
|
||||
var res: any[] = [];
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
if (ListWrapper.contains(res, keys[i])) {
|
||||
if (res.indexOf(keys[i]) > -1) {
|
||||
res.push(keys[i]);
|
||||
return res;
|
||||
}
|
||||
@ -28,8 +27,8 @@ function findFirstClosedCycle(keys: any[]): any[] {
|
||||
|
||||
function constructResolvingPath(keys: any[]): string {
|
||||
if (keys.length > 1) {
|
||||
var reversed = findFirstClosedCycle(ListWrapper.reversed(keys));
|
||||
var tokenStrs = reversed.map(k => stringify(k.token));
|
||||
const reversed = findFirstClosedCycle(keys.slice().reverse());
|
||||
const tokenStrs = reversed.map(k => stringify(k.token));
|
||||
return ' (' + tokenStrs.join(' -> ') + ')';
|
||||
}
|
||||
|
||||
@ -88,7 +87,7 @@ export class AbstractProviderError extends BaseError {
|
||||
export class NoProviderError extends AbstractProviderError {
|
||||
constructor(injector: ReflectiveInjector, key: ReflectiveKey) {
|
||||
super(injector, key, function(keys: any[]) {
|
||||
var first = stringify(ListWrapper.first(keys).token);
|
||||
const first = stringify(keys[0].token);
|
||||
return `No provider for ${first}!${constructResolvingPath(keys)}`;
|
||||
});
|
||||
}
|
||||
@ -167,7 +166,7 @@ export class InstantiationError extends WrappedError {
|
||||
}
|
||||
|
||||
get message(): string {
|
||||
var first = stringify(ListWrapper.first(this.keys).token);
|
||||
var first = stringify(this.keys[0].token);
|
||||
return `${this.originalError.message}: Error during instantiation of ${first}!${constructResolvingPath(this.keys)}.`;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ListWrapper} from '../facade/collection';
|
||||
import {unimplemented} from '../facade/errors';
|
||||
import {Type} from '../type';
|
||||
|
||||
@ -17,8 +16,6 @@ import {AbstractProviderError, CyclicDependencyError, InstantiationError, NoProv
|
||||
import {ReflectiveKey} from './reflective_key';
|
||||
import {ReflectiveDependency, ResolvedReflectiveFactory, ResolvedReflectiveProvider, resolveReflectiveProviders} from './reflective_provider';
|
||||
|
||||
var __unused: Type<any>; // avoid unused import when Type union types are erased
|
||||
|
||||
// Threshold for the dynamic version
|
||||
const _MAX_CONSTRUCTION_COUNTER = 10;
|
||||
const UNDEFINED = new Object();
|
||||
@ -286,8 +283,7 @@ export class ReflectiveInjectorDynamicStrategy implements ReflectiveInjectorStra
|
||||
constructor(
|
||||
public protoStrategy: ReflectiveProtoInjectorDynamicStrategy,
|
||||
public injector: ReflectiveInjector_) {
|
||||
this.objs = new Array(protoStrategy.providers.length);
|
||||
ListWrapper.fill(this.objs, UNDEFINED);
|
||||
this.objs = new Array(protoStrategy.providers.length).fill(UNDEFINED);
|
||||
}
|
||||
|
||||
resetConstructionCounter(): void { this.injector._constructionCounter = 0; }
|
||||
@ -297,9 +293,9 @@ export class ReflectiveInjectorDynamicStrategy implements ReflectiveInjectorStra
|
||||
}
|
||||
|
||||
getObjByKeyId(keyId: number): any {
|
||||
var p = this.protoStrategy;
|
||||
const p = this.protoStrategy;
|
||||
|
||||
for (var i = 0; i < p.keyIds.length; i++) {
|
||||
for (let i = 0; i < p.keyIds.length; i++) {
|
||||
if (p.keyIds[i] === keyId) {
|
||||
if (this.objs[i] === UNDEFINED) {
|
||||
this.objs[i] = this.injector._new(p.providers[i]);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ListWrapper, MapWrapper} from '../facade/collection';
|
||||
import {MapWrapper} from '../facade/collection';
|
||||
import {isBlank, isPresent} from '../facade/lang';
|
||||
import {reflector} from '../reflection/reflection';
|
||||
import {Type} from '../type';
|
||||
@ -170,7 +170,7 @@ export function mergeResolvedReflectiveProviders(
|
||||
var resolvedProvider: ResolvedReflectiveProvider;
|
||||
if (provider.multiProvider) {
|
||||
resolvedProvider = new ResolvedReflectiveProvider_(
|
||||
provider.key, ListWrapper.clone(provider.resolvedFactories), provider.multiProvider);
|
||||
provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
|
||||
} else {
|
||||
resolvedProvider = provider;
|
||||
}
|
||||
|
Reference in New Issue
Block a user