From a67cc8229d1f21b9f3f23c42024b0becf5801f7c Mon Sep 17 00:00:00 2001 From: Hans Date: Thu, 28 Jul 2016 10:38:29 -0700 Subject: [PATCH] chore: move injector to being non-internal but private (#10339) * chore: move injector to being non-internal but private * Add the new non-internal method to the public API. --- modules/@angular/compiler/src/runtime_compiler.ts | 6 +++--- modules/@angular/core/src/linker/compiler.ts | 4 +--- modules/@angular/core/testing/test_bed.ts | 2 +- tools/public_api_guard/core/index.d.ts | 1 + 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/@angular/compiler/src/runtime_compiler.ts b/modules/@angular/compiler/src/runtime_compiler.ts index 524d249e1f17b..b06e0a30e904a 100644 --- a/modules/@angular/compiler/src/runtime_compiler.ts +++ b/modules/@angular/compiler/src/runtime_compiler.ts @@ -44,13 +44,13 @@ export class RuntimeCompiler implements Compiler { private _compiledNgModuleCache = new Map>(); constructor( - private _injector: Injector, private _metadataResolver: CompileMetadataResolver, + private __injector: Injector, private _metadataResolver: CompileMetadataResolver, private _templateNormalizer: DirectiveNormalizer, private _templateParser: TemplateParser, private _styleCompiler: StyleCompiler, private _viewCompiler: ViewCompiler, private _ngModuleCompiler: NgModuleCompiler, private _compilerConfig: CompilerConfig, private _console: Console) {} - get injector(): Injector { return this._injector; } + get _injector(): Injector { return this.__injector; } compileModuleSync(moduleType: ConcreteType): NgModuleFactory { return this._compileModuleAndComponents(moduleType, true).syncResult; @@ -381,7 +381,7 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver { private _delegate: RuntimeCompiler, private _ngModule: ConcreteType, private _parentComponentResolver: ComponentResolver, private _console: Console) {} - get injector(): Injector { return this._delegate.injector; } + get _injector(): Injector { return this._delegate._injector; } resolveComponent(component: Type|string): Promise> { if (isString(component)) { diff --git a/modules/@angular/core/src/linker/compiler.ts b/modules/@angular/core/src/linker/compiler.ts index 17e54c3df18cb..59df4df5a6b9f 100644 --- a/modules/@angular/core/src/linker/compiler.ts +++ b/modules/@angular/core/src/linker/compiler.ts @@ -41,10 +41,8 @@ export class ComponentStillLoadingError extends BaseException { export class Compiler { /** * Returns the injector with which the compiler has been created. - * - * @internal */ - get injector(): Injector { + get _injector(): Injector { throw new BaseException(`Runtime compiler is not loaded. Tried to read the injector.`); } diff --git a/modules/@angular/core/testing/test_bed.ts b/modules/@angular/core/testing/test_bed.ts index ca117f129aadd..10e485f4a8b1a 100644 --- a/modules/@angular/core/testing/test_bed.ts +++ b/modules/@angular/core/testing/test_bed.ts @@ -168,7 +168,7 @@ export class TestBed implements Injector { // Tests can inject things from the ng module and from the compiler, // but the ng module can't inject things from the compiler and vice versa. let result = this._moduleRef.injector.get(token, UNDEFINED); - return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue) : result; + return result === UNDEFINED ? this._compiler._injector.get(token, notFoundValue) : result; } execute(tokens: any[], fn: Function): any { diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts index d5c8be1acad8b..61b230e2d8ce4 100644 --- a/tools/public_api_guard/core/index.d.ts +++ b/tools/public_api_guard/core/index.d.ts @@ -237,6 +237,7 @@ export declare class CollectionChangeRecord { /** @stable */ export declare class Compiler { + _injector: Injector; clearCache(): void; clearCacheFor(type: Type): void; compileComponentAsync(component: ConcreteType, ngModule?: Type): Promise>;