@@ -40,10 +40,10 @@ function constructResolvingMessage(resolving, token) {
4040class Injector {
4141
4242 constructor ( modules = [ ] , parentInjector = null , providers = new Map ( ) , scopes = [ ] ) {
43- this . cache = new Map ( ) ;
44- this . providers = providers ;
45- this . parent = parentInjector ;
46- this . scopes = scopes ;
43+ this . _cache = new Map ( ) ;
44+ this . _providers = providers ;
45+ this . _parent = parentInjector ;
46+ this . _scopes = scopes ;
4747
4848 this . _loadModules ( modules ) ;
4949
@@ -54,20 +54,20 @@ class Injector {
5454 // Collect all registered providers that has given annotation.
5555 // Inclugind providers defined in parent injectors.
5656 _collectProvidersWithAnnotation ( annotationClass , collectedProviders ) {
57- this . providers . forEach ( ( provider , token ) => {
57+ this . _providers . forEach ( ( provider , token ) => {
5858 if ( ! collectedProviders . has ( token ) && hasAnnotation ( provider . provider , annotationClass ) ) {
5959 collectedProviders . set ( token , provider ) ;
6060 }
6161 } ) ;
6262
63- if ( this . parent ) {
64- this . parent . _collectProvidersWithAnnotation ( annotationClass , collectedProviders ) ;
63+ if ( this . _parent ) {
64+ this . _parent . _collectProvidersWithAnnotation ( annotationClass , collectedProviders ) ;
6565 }
6666 }
6767
6868
6969 // Load modules/function/classes.
70- // This mutates `this.providers `, but it is only called during the constructor.
70+ // This mutates `this._providers `, but it is only called during the constructor.
7171 _loadModules ( modules ) {
7272 for ( var module of modules ) {
7373 // A single provider (class or function).
@@ -82,26 +82,26 @@ class Injector {
8282
8383
8484 // Load a function or class.
85- // This mutates `this.providers `, but it is only called during the constructor.
85+ // This mutates `this._providers `, but it is only called during the constructor.
8686 _loadFnOrClass ( fnOrClass ) {
8787 // TODO(vojta): should we expose provider.token?
8888 var annotations = readAnnotations ( fnOrClass ) ;
8989 var token = annotations . provide . token || fnOrClass ;
9090 var provider = createProviderFromFnOrClass ( fnOrClass , annotations ) ;
9191
92- this . providers . set ( token , provider ) ;
92+ this . _providers . set ( token , provider ) ;
9393 }
9494
9595
9696 // Returns true if there is any provider registered for given token.
9797 // Inclugind parent injectors.
9898 _hasProviderFor ( token ) {
99- if ( this . providers . has ( token ) ) {
99+ if ( this . _providers . has ( token ) ) {
100100 return true ;
101101 }
102102
103- if ( this . parent ) {
104- return this . parent . _hasProviderFor ( token ) ;
103+ if ( this . _parent ) {
104+ return this . _parent . _hasProviderFor ( token ) ;
105105 }
106106
107107 return false ;
@@ -110,21 +110,21 @@ class Injector {
110110 // Find the correct injector where the default provider should be instantiated and cached.
111111 _instantiateDefaultProvider ( provider , token , resolving , wantPromise , wantLazy ) {
112112 // In root injector, instantiate here.
113- if ( ! this . parent ) {
114- this . providers . set ( token , provider ) ;
113+ if ( ! this . _parent ) {
114+ this . _providers . set ( token , provider ) ;
115115 return this . get ( token , resolving , wantPromise , wantLazy ) ;
116116 }
117117
118118 // Check if this injector forces new instance of this provider.
119- for ( var ScopeClass of this . scopes ) {
119+ for ( var ScopeClass of this . _scopes ) {
120120 if ( hasAnnotation ( provider . provider , ScopeClass ) ) {
121- this . providers . set ( token , provider ) ;
121+ this . _providers . set ( token , provider ) ;
122122 return this . get ( token , resolving , wantPromise , wantLazy ) ;
123123 }
124124 }
125125
126126 // Otherwise ask parent injector.
127- return this . parent . _instantiateDefaultProvider ( provider , token , resolving , wantPromise , wantLazy ) ;
127+ return this . _parent . _instantiateDefaultProvider ( provider , token , resolving , wantPromise , wantLazy ) ;
128128 }
129129
130130
@@ -178,9 +178,9 @@ class Injector {
178178 }
179179
180180 // Check if there is a cached instance already.
181- if ( this . cache . has ( token ) ) {
182- instance = this . cache . get ( token ) ;
183- provider = this . providers . get ( token ) ;
181+ if ( this . _cache . has ( token ) ) {
182+ instance = this . _cache . get ( token ) ;
183+ provider = this . _providers . get ( token ) ;
184184
185185 if ( provider . isPromise && ! wantPromise ) {
186186 resolvingMsg = constructResolvingMessage ( resolving , token ) ;
@@ -194,7 +194,7 @@ class Injector {
194194 return instance ;
195195 }
196196
197- provider = this . providers . get ( token ) ;
197+ provider = this . _providers . get ( token ) ;
198198
199199 // No provider defined (overriden), use the default provider (token).
200200 if ( ! provider && isFunction ( token ) && ! this . _hasProviderFor ( token ) ) {
@@ -203,12 +203,12 @@ class Injector {
203203 }
204204
205205 if ( ! provider ) {
206- if ( ! this . parent ) {
206+ if ( ! this . _parent ) {
207207 resolvingMsg = constructResolvingMessage ( resolving , token ) ;
208208 throw new Error ( `No provider for ${ toString ( token ) } !${ resolvingMsg } ` ) ;
209209 }
210210
211- return this . parent . get ( token , resolving , wantPromise , wantLazy ) ;
211+ return this . _parent . get ( token , resolving , wantPromise , wantLazy ) ;
212212 }
213213
214214 if ( resolving . indexOf ( token ) !== - 1 ) {
@@ -254,7 +254,7 @@ class Injector {
254254 }
255255
256256 if ( ! hasAnnotation ( provider . provider , TransientScopeAnnotation ) ) {
257- injector . cache . set ( token , instance ) ;
257+ injector . _cache . set ( token , instance ) ;
258258 }
259259
260260 // TODO(vojta): if a provider returns a promise (but is not declared as @ProvidePromise),
@@ -276,7 +276,7 @@ class Injector {
276276 }
277277
278278 if ( ! hasAnnotation ( provider . provider , TransientScopeAnnotation ) ) {
279- this . cache . set ( token , instance ) ;
279+ this . _cache . set ( token , instance ) ;
280280 }
281281
282282 if ( ! wantPromise && provider . isPromise ) {
0 commit comments