Skip to content

Commit

Permalink
chore: move injector to being non-internal but private (angular#10339)
Browse files Browse the repository at this point in the history
* chore: move injector to being non-internal but private

* Add the new non-internal method to the public API.
  • Loading branch information
hansl authored Jul 28, 2016
1 parent b58e9ea commit a67cc82
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions modules/@angular/compiler/src/runtime_compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export class RuntimeCompiler implements Compiler {
private _compiledNgModuleCache = new Map<Type, NgModuleFactory<any>>();

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<T>(moduleType: ConcreteType<T>): NgModuleFactory<T> {
return this._compileModuleAndComponents(moduleType, true).syncResult;
Expand Down Expand Up @@ -381,7 +381,7 @@ class ModuleBoundCompiler implements Compiler, ComponentResolver {
private _delegate: RuntimeCompiler, private _ngModule: ConcreteType<any>,
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<ComponentFactory<any>> {
if (isString(component)) {
Expand Down
4 changes: 1 addition & 3 deletions modules/@angular/core/src/linker/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/@angular/core/testing/test_bed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions tools/public_api_guard/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export declare class CollectionChangeRecord {

/** @stable */
export declare class Compiler {
_injector: Injector;
clearCache(): void;
clearCacheFor(type: Type): void;
compileComponentAsync<T>(component: ConcreteType<T>, ngModule?: Type): Promise<ComponentFactory<T>>;
Expand Down

0 comments on commit a67cc82

Please sign in to comment.