Skip to content

Commit

Permalink
refactor: rename all const to UPPER_CASE
Browse files Browse the repository at this point in the history
Closes angular#3573

BREAKING CHANGE

Rename:
- `appComponentTypeToken` => `APP_COMPONENT`
- `coreDirectives` => `CORE_DIRECTIVES`
- `formDirectives` => `FORM_DIRECTIVES`
- `formInjectables` => `FORM_BINDINGS`
- `httpInjectables` => `HTTP_BINDINGS`
- `jsonpInjectables` => `JSONP_BINDINGS`
- `PROTO_CHANGE_DETECTOR_KEY` => `PROTO_CHANGE_DETECTOR`
- `appComponentRefPromiseToken` => `APP_COMPONENT_REF_PROMISE`
- `appComponentTypeToken` => `APP_COMPONENT`
- `undefinedValue` => `UNDEFINED`
- `formDirectives` => `FORM_DIRECTIVES`
- `DOCUMENT_TOKEN` => `DOCUMENT`
- `APP_ID_TOKEN` => `APP_ID`
- `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN` => `MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE`
- `appBaseHrefToken` => `APP_BASE_HREF`
  • Loading branch information
mhevery committed Aug 13, 2015
1 parent 1d65b38 commit 60af19f
Show file tree
Hide file tree
Showing 54 changed files with 203 additions and 205 deletions.
2 changes: 1 addition & 1 deletion modules/angular2/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @description
* Define angular core API here.
*/
export {appComponentTypeToken} from 'angular2/src/core/application_tokens';
export {APP_COMPONENT} from 'angular2/src/core/application_tokens';
export {ApplicationRef} from 'angular2/src/core/application_common';
export {Type} from 'angular2/src/facade/lang';

Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/di.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export {
PUBLIC_AND_PRIVATE,
PUBLIC,
PRIVATE,
undefinedValue
UNDEFINED
} from './src/di/injector';
export {Binding, BindingBuilder, ResolvedBinding, Dependency, bind} from './src/di/binding';
export {Key, KeyRegistry, TypeLiteral} from './src/di/key';
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ export * from './src/directives/ng_switch';
* ```
*
*/
export const coreDirectives: List<Type> =
export const CORE_DIRECTIVES: List<Type> =
CONST_EXPR([NgClass, NgFor, NgIf, NgNonBindable, NgSwitch, NgSwitchWhen, NgSwitchDefault]);
4 changes: 2 additions & 2 deletions modules/angular2/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export {
NgSelectOption,
SelectControlValueAccessor
} from './src/forms/directives/select_control_value_accessor';
export {formDirectives} from './src/forms/directives';
export {FORM_DIRECTIVES} from './src/forms/directives';
export {Validators} from './src/forms/validators';
export {NgValidator, NgRequiredValidator} from './src/forms/directives/validators';
export {FormBuilder} from './src/forms/form_builder';

import {FormBuilder} from './src/forms/form_builder';
import {CONST_EXPR, Type} from './src/facade/lang';

export const formInjectables: List<Type> = CONST_EXPR([FormBuilder]);
export const FORM_BINDINGS: List<Type> = CONST_EXPR([FormBuilder]);
6 changes: 3 additions & 3 deletions modules/angular2/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export {
RenderFragmentRef,
RenderViewWithFragments,
ViewDefinition,
DOCUMENT_TOKEN,
APP_ID_TOKEN,
DOCUMENT,
APP_ID,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE
} from './src/render/render';
6 changes: 3 additions & 3 deletions modules/angular2/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export {RouteRegistry} from './src/router/route_registry';
export {LocationStrategy} from './src/router/location_strategy';
export {HashLocationStrategy} from './src/router/hash_location_strategy';
export {HTML5LocationStrategy} from './src/router/html5_location_strategy';
export {Location, appBaseHrefToken} from './src/router/location';
export {Location, APP_BASE_HREF} from './src/router/location';
export {Pipeline} from './src/router/pipeline';
export * from './src/router/route_config_decorator';
export * from './src/router/route_definition';
Expand All @@ -31,7 +31,7 @@ import {RouterLink} from './src/router/router_link';
import {RouteRegistry} from './src/router/route_registry';
import {Pipeline} from './src/router/pipeline';
import {Location} from './src/router/location';
import {appComponentTypeToken} from './src/core/application_tokens';
import {APP_COMPONENT} from './src/core/application_tokens';
import {bind} from './di';
import {CONST_EXPR} from './src/facade/lang';
import {List} from './src/facade/collection';
Expand All @@ -46,5 +46,5 @@ export var routerInjectables: List<any> = [
bind(Router)
.toFactory((registry, pipeline, location,
appRoot) => { return new RootRouter(registry, pipeline, location, appRoot);},
[RouteRegistry, Pipeline, Location, appComponentTypeToken])
[RouteRegistry, Pipeline, Location, APP_COMPONENT])
];
4 changes: 2 additions & 2 deletions modules/angular2/src/change_detection/change_detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const defaultKeyValueDiffers = CONST_EXPR(new KeyValueDiffers(keyValDiff)
// dart2js. See https://github.com/dart-lang/sdk/issues/23630 for details.
export var preGeneratedProtoDetectors: StringMap<string, Function> = {};

export const PROTO_CHANGE_DETECTOR_KEY = CONST_EXPR(new OpaqueToken('ProtoChangeDetectors'));
export const PROTO_CHANGE_DETECTOR = CONST_EXPR(new OpaqueToken('ProtoChangeDetectors'));

/**
* Implements change detection using a map of pregenerated proto detectors.
Expand All @@ -82,7 +82,7 @@ export class PreGeneratedChangeDetection extends ChangeDetection {
_dynamicChangeDetection: ChangeDetection;
_protoChangeDetectorFactories: StringMap<string, Function>;

constructor(@Inject(PROTO_CHANGE_DETECTOR_KEY) @Optional() protoChangeDetectorsForTest?:
constructor(@Inject(PROTO_CHANGE_DETECTOR) @Optional() protoChangeDetectorsForTest?:
StringMap<string, Function>) {
super();
this._dynamicChangeDetection = new DynamicChangeDetection();
Expand Down
18 changes: 9 additions & 9 deletions modules/angular2/src/core/application_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ import {ProtoViewFactory} from 'angular2/src/core/compiler/proto_view_factory';
import {Renderer, RenderCompiler} from 'angular2/src/render/api';
import {
DomRenderer,
DOCUMENT_TOKEN,
DOCUMENT,
DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES,
DefaultDomCompiler,
APP_ID_RANDOM_BINDING,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN,
MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE,
TemplateCloner
} from 'angular2/src/render/render';
import {ElementSchemaRegistry} from 'angular2/src/render/dom/schema/element_schema_registry';
Expand All @@ -74,7 +74,7 @@ import {
DomSharedStylesHost
} from 'angular2/src/render/dom/view/shared_styles_host';
import {internalView} from 'angular2/src/core/compiler/view_ref';
import {appComponentRefPromiseToken, appComponentTypeToken} from './application_tokens';
import {APP_COMPONENT_REF_PROMISE, APP_COMPONENT} from './application_tokens';
import {wtfInit} from '../profile/wtf_init';

var _rootInjector: Injector;
Expand All @@ -90,11 +90,11 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bestChangeDetection = JitChangeDetection;
}
return [
bind(DOCUMENT_TOKEN)
bind(DOCUMENT)
.toValue(DOM.defaultDoc()),
bind(DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES).toValue(false),
bind(appComponentTypeToken).toValue(appComponentType),
bind(appComponentRefPromiseToken)
bind(APP_COMPONENT).toValue(appComponentType),
bind(APP_COMPONENT_REF_PROMISE)
.toFactory(
(dynamicComponentLoader, injector, testability, registry) => {
// TODO(rado): investigate whether to support bindings on root component.
Expand All @@ -107,7 +107,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
[DynamicComponentLoader, Injector, Testability, TestabilityRegistry]),

bind(appComponentType)
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [appComponentRefPromiseToken]),
.toFactory((p: Promise<any>) => p.then(ref => ref.instance), [APP_COMPONENT_REF_PROMISE]),
bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(null, assertionsEnabled()),
[ExceptionHandler]),
bind(EventManager)
Expand All @@ -122,7 +122,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
bind(Renderer).toAlias(DomRenderer),
APP_ID_RANDOM_BINDING,
TemplateCloner,
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE_TOKEN).toValue(20),
bind(MAX_IN_MEMORY_ELEMENTS_PER_TEMPLATE).toValue(20),
DefaultDomCompiler,
bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
bind(RenderCompiler).toAlias(DefaultDomCompiler),
Expand Down Expand Up @@ -305,7 +305,7 @@ export function commonBootstrap(
exceptionHandler = appInjector.get(ExceptionHandler);
zone.overrideOnErrorHandler((e, s) => exceptionHandler.call(e, s));

var compRefToken: Promise<any> = appInjector.get(appComponentRefPromiseToken);
var compRefToken: Promise<any> = appInjector.get(APP_COMPONENT_REF_PROMISE);
var tick = (componentRef) => {
var appChangeDetector = internalView(componentRef.hostView).changeDetector;
// retrieve life cycle: may have already been created if injected in root component
Expand Down
4 changes: 2 additions & 2 deletions modules/angular2/src/core/application_tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {CONST_EXPR} from 'angular2/src/facade/lang';
/**
* @private
*/
export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>'));
export const APP_COMPONENT_REF_PROMISE = CONST_EXPR(new OpaqueToken('Promise<ComponentRef>'));

/**
* An opaque token representing the application root type in the {@link Injector}.
Expand All @@ -22,4 +22,4 @@ export const appComponentRefPromiseToken = CONST_EXPR(new OpaqueToken('Promise<C
*
* ```
*/
export const appComponentTypeToken: OpaqueToken = CONST_EXPR(new OpaqueToken('RootComponent'));
export const APP_COMPONENT: OpaqueToken = CONST_EXPR(new OpaqueToken('AppComponent'));
70 changes: 35 additions & 35 deletions modules/angular2/src/core/compiler/element_injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
PUBLIC_AND_PRIVATE,
PUBLIC,
PRIVATE,
undefinedValue,
UNDEFINED,
Key,
Dependency,
bind,
Expand Down Expand Up @@ -645,7 +645,7 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
}
}

return undefinedValue;
return UNDEFINED;
}

private _buildAttribute(dep: DirectiveDependency): string {
Expand Down Expand Up @@ -892,41 +892,41 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = i.protoStrategy;
i.resetConstructionCounter();

if (p.binding0 instanceof DirectiveBinding && isPresent(p.keyId0) && i.obj0 === undefinedValue)
if (p.binding0 instanceof DirectiveBinding && isPresent(p.keyId0) && i.obj0 === UNDEFINED)
i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
if (p.binding1 instanceof DirectiveBinding && isPresent(p.keyId1) && i.obj1 === undefinedValue)
if (p.binding1 instanceof DirectiveBinding && isPresent(p.keyId1) && i.obj1 === UNDEFINED)
i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
if (p.binding2 instanceof DirectiveBinding && isPresent(p.keyId2) && i.obj2 === undefinedValue)
if (p.binding2 instanceof DirectiveBinding && isPresent(p.keyId2) && i.obj2 === UNDEFINED)
i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
if (p.binding3 instanceof DirectiveBinding && isPresent(p.keyId3) && i.obj3 === undefinedValue)
if (p.binding3 instanceof DirectiveBinding && isPresent(p.keyId3) && i.obj3 === UNDEFINED)
i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
if (p.binding4 instanceof DirectiveBinding && isPresent(p.keyId4) && i.obj4 === undefinedValue)
if (p.binding4 instanceof DirectiveBinding && isPresent(p.keyId4) && i.obj4 === UNDEFINED)
i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
if (p.binding5 instanceof DirectiveBinding && isPresent(p.keyId5) && i.obj5 === undefinedValue)
if (p.binding5 instanceof DirectiveBinding && isPresent(p.keyId5) && i.obj5 === UNDEFINED)
i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
if (p.binding6 instanceof DirectiveBinding && isPresent(p.keyId6) && i.obj6 === undefinedValue)
if (p.binding6 instanceof DirectiveBinding && isPresent(p.keyId6) && i.obj6 === UNDEFINED)
i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
if (p.binding7 instanceof DirectiveBinding && isPresent(p.keyId7) && i.obj7 === undefinedValue)
if (p.binding7 instanceof DirectiveBinding && isPresent(p.keyId7) && i.obj7 === UNDEFINED)
i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
if (p.binding8 instanceof DirectiveBinding && isPresent(p.keyId8) && i.obj8 === undefinedValue)
if (p.binding8 instanceof DirectiveBinding && isPresent(p.keyId8) && i.obj8 === UNDEFINED)
i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
if (p.binding9 instanceof DirectiveBinding && isPresent(p.keyId9) && i.obj9 === undefinedValue)
if (p.binding9 instanceof DirectiveBinding && isPresent(p.keyId9) && i.obj9 === UNDEFINED)
i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
}

dehydrate() {
var i = this.injectorStrategy;

i.obj0 = undefinedValue;
i.obj1 = undefinedValue;
i.obj2 = undefinedValue;
i.obj3 = undefinedValue;
i.obj4 = undefinedValue;
i.obj5 = undefinedValue;
i.obj6 = undefinedValue;
i.obj7 = undefinedValue;
i.obj8 = undefinedValue;
i.obj9 = undefinedValue;
i.obj0 = UNDEFINED;
i.obj1 = UNDEFINED;
i.obj2 = UNDEFINED;
i.obj3 = UNDEFINED;
i.obj4 = UNDEFINED;
i.obj5 = UNDEFINED;
i.obj6 = UNDEFINED;
i.obj7 = UNDEFINED;
i.obj8 = UNDEFINED;
i.obj9 = UNDEFINED;
}

callOnDestroy(): void {
Expand Down Expand Up @@ -1012,43 +1012,43 @@ class ElementInjectorInlineStrategy implements _ElementInjectorStrategy {
var p = i.protoStrategy;

if (isPresent(p.binding0) && p.binding0.key.token === query.selector) {
if (i.obj0 === undefinedValue) i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
if (i.obj0 === UNDEFINED) i.obj0 = i.instantiateBinding(p.binding0, p.visibility0);
list.push(i.obj0);
}
if (isPresent(p.binding1) && p.binding1.key.token === query.selector) {
if (i.obj1 === undefinedValue) i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
if (i.obj1 === UNDEFINED) i.obj1 = i.instantiateBinding(p.binding1, p.visibility1);
list.push(i.obj1);
}
if (isPresent(p.binding2) && p.binding2.key.token === query.selector) {
if (i.obj2 === undefinedValue) i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
if (i.obj2 === UNDEFINED) i.obj2 = i.instantiateBinding(p.binding2, p.visibility2);
list.push(i.obj2);
}
if (isPresent(p.binding3) && p.binding3.key.token === query.selector) {
if (i.obj3 === undefinedValue) i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
if (i.obj3 === UNDEFINED) i.obj3 = i.instantiateBinding(p.binding3, p.visibility3);
list.push(i.obj3);
}
if (isPresent(p.binding4) && p.binding4.key.token === query.selector) {
if (i.obj4 === undefinedValue) i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
if (i.obj4 === UNDEFINED) i.obj4 = i.instantiateBinding(p.binding4, p.visibility4);
list.push(i.obj4);
}
if (isPresent(p.binding5) && p.binding5.key.token === query.selector) {
if (i.obj5 === undefinedValue) i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
if (i.obj5 === UNDEFINED) i.obj5 = i.instantiateBinding(p.binding5, p.visibility5);
list.push(i.obj5);
}
if (isPresent(p.binding6) && p.binding6.key.token === query.selector) {
if (i.obj6 === undefinedValue) i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
if (i.obj6 === UNDEFINED) i.obj6 = i.instantiateBinding(p.binding6, p.visibility6);
list.push(i.obj6);
}
if (isPresent(p.binding7) && p.binding7.key.token === query.selector) {
if (i.obj7 === undefinedValue) i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
if (i.obj7 === UNDEFINED) i.obj7 = i.instantiateBinding(p.binding7, p.visibility7);
list.push(i.obj7);
}
if (isPresent(p.binding8) && p.binding8.key.token === query.selector) {
if (i.obj8 === undefinedValue) i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
if (i.obj8 === UNDEFINED) i.obj8 = i.instantiateBinding(p.binding8, p.visibility8);
list.push(i.obj8);
}
if (isPresent(p.binding9) && p.binding9.key.token === query.selector) {
if (i.obj9 === undefinedValue) i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
if (i.obj9 === UNDEFINED) i.obj9 = i.instantiateBinding(p.binding9, p.visibility9);
list.push(i.obj9);
}
}
Expand All @@ -1072,15 +1072,15 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {

for (var i = 0; i < p.keyIds.length; i++) {
if (p.bindings[i] instanceof DirectiveBinding && isPresent(p.keyIds[i]) &&
inj.objs[i] === undefinedValue) {
inj.objs[i] === UNDEFINED) {
inj.objs[i] = inj.instantiateBinding(p.bindings[i], p.visibilities[i]);
}
}
}

dehydrate(): void {
var inj = this.injectorStrategy;
ListWrapper.fill(inj.objs, undefinedValue);
ListWrapper.fill(inj.objs, UNDEFINED);
}

callOnDestroy(): void {
Expand Down Expand Up @@ -1119,7 +1119,7 @@ class ElementInjectorDynamicStrategy implements _ElementInjectorStrategy {

for (var i = 0; i < p.bindings.length; i++) {
if (p.bindings[i].key.token === query.selector) {
if (ist.objs[i] === undefinedValue) {
if (ist.objs[i] === UNDEFINED) {
ist.objs[i] = ist.instantiateBinding(p.bindings[i], p.visibilities[i]);
}
list.push(ist.objs[i]);
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/di/binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class Dependency {
const _EMPTY_LIST = CONST_EXPR([]);

/**
* Describes how the {@link Injector} should instantiate a given token.
* Describes how_ the {@link Injector} should instantiate a given token.
*
* See {@link bind}.
*
Expand Down
Loading

0 comments on commit 60af19f

Please sign in to comment.