Skip to content

Commit 9a70f84

Browse files
committed
refactor(pipes): rename PipeRegistry to Pipes
BREAKING CHANGE: This change renames all instances of PipeRegistry to Pipes. As part of this change, the former "defaultPipes" export is now a Pipes instance, instead of a map. The map that was previously called "defaultPipes" no longer exists, but may be accessed via defaultPipes.config.
1 parent 8b3efdf commit 9a70f84

20 files changed

Lines changed: 90 additions & 104 deletions

File tree

modules/angular2/angular2.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ export {
1414

1515
ChangeDetectorRef,
1616

17-
PipeRegistry,
17+
Pipes,
1818
WrappedValue,
1919
Pipe,
2020
PipeFactory,
2121
NullPipe,
2222
NullPipeFactory,
2323
defaultPipes,
24-
defaultPipeRegistry,
2524
BasePipe,
2625

2726
Locals

modules/angular2/change_detection.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export {BindingRecord} from './src/change_detection/binding_record';
4343
export {DirectiveIndex, DirectiveRecord} from './src/change_detection/directive_record';
4444
export {DynamicChangeDetector} from './src/change_detection/dynamic_change_detector';
4545
export {ChangeDetectorRef} from './src/change_detection/change_detector_ref';
46-
export {PipeRegistry} from './src/change_detection/pipes/pipes';
46+
export {Pipes} from './src/change_detection/pipes/pipes';
4747
export {uninitialized} from './src/change_detection/change_detection_util';
4848
export {WrappedValue, Pipe, PipeFactory, BasePipe} from './src/change_detection/pipes/pipe';
4949
export {NullPipe, NullPipeFactory} from './src/change_detection/pipes/null_pipe';
@@ -52,6 +52,5 @@ export {
5252
DynamicChangeDetection,
5353
JitChangeDetection,
5454
PreGeneratedChangeDetection,
55-
preGeneratedProtoDetectors,
56-
defaultPipeRegistry
55+
preGeneratedProtoDetectors
5756
} from './src/change_detection/change_detection';

modules/angular2/src/change_detection/change_detection.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {JitProtoChangeDetector} from './jit_proto_change_detector';
22
import {PregenProtoChangeDetector} from './pregen_proto_change_detector';
33
import {DynamicProtoChangeDetector} from './proto_change_detector';
44
import {PipeFactory, Pipe} from './pipes/pipe';
5-
import {PipeRegistry} from './pipes/pipes';
5+
import {Pipes} from './pipes/pipes';
66
import {IterableChangesFactory} from './pipes/iterable_changes';
77
import {KeyValueChangesFactory} from './pipes/keyvalue_changes';
88
import {ObservablePipeFactory} from './pipes/observable_pipe';
@@ -111,7 +111,7 @@ export const date: List<PipeFactory> =
111111
CONST_EXPR([CONST_EXPR(new DatePipe()), CONST_EXPR(new NullPipeFactory())]);
112112

113113

114-
export const defaultPipes = CONST_EXPR({
114+
export const defaultPipes: Pipes = CONST_EXPR(new Pipes({
115115
"iterableDiff": iterableDiff,
116116
"keyValDiff": keyValDiff,
117117
"async": async,
@@ -123,11 +123,11 @@ export const defaultPipes = CONST_EXPR({
123123
"percent": percent,
124124
"currency": currency,
125125
"date": date
126-
});
126+
}));
127127

128128
/**
129129
* Map from {@link ChangeDetectorDefinition#id} to a factory method which takes a
130-
* {@link PipeRegistry} and a {@link ChangeDetectorDefinition} and generates a
130+
* {@link Pipes} and a {@link ChangeDetectorDefinition} and generates a
131131
* {@link ProtoChangeDetector} associated with the definition.
132132
*/
133133
// TODO(kegluneq): Use PregenProtoChangeDetectorFactory rather than Function once possible in
@@ -198,5 +198,3 @@ export class JitChangeDetection extends ChangeDetection {
198198
return new JitProtoChangeDetector(definition);
199199
}
200200
}
201-
202-
export const defaultPipeRegistry: PipeRegistry = CONST_EXPR(new PipeRegistry(defaultPipes));

modules/angular2/src/change_detection/change_detection_jit_generator.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {ProtoRecord, RecordType} from './proto_record';
2020
var ABSTRACT_CHANGE_DETECTOR = "AbstractChangeDetector";
2121
var UTIL = "ChangeDetectionUtil";
2222
var DISPATCHER_ACCESSOR = "this.dispatcher";
23-
var PIPE_REGISTRY_ACCESSOR = "this.pipeRegistry";
23+
var PIPES_ACCESSOR = "this.pipes";
2424
var PROTOS_ACCESSOR = "this.protos";
2525
var DIRECTIVES_ACCESSOR = "this.directiveRecords";
2626
var CONTEXT_ACCESSOR = "this.context";
@@ -74,7 +74,7 @@ export class ChangeDetectorJITGenerator {
7474
${DIRECTIVES_ACCESSOR} = directiveRecords;
7575
${LOCALS_ACCESSOR} = null;
7676
${CURRENT_PROTO} = null;
77-
${PIPE_REGISTRY_ACCESSOR} = null;
77+
${PIPES_ACCESSOR} = null;
7878
${ALREADY_CHECKED_ACCESSOR} = false;
7979
${this._genFieldDefinitions()}
8080
}
@@ -111,21 +111,21 @@ export class ChangeDetectorJITGenerator {
111111
${this._genCallOnAllChangesDoneBody()}
112112
}
113113
114-
${typeName}.prototype.hydrate = function(context, locals, directives, pipeRegistry) {
114+
${typeName}.prototype.hydrate = function(context, locals, directives, pipes) {
115115
${MODE_ACCESSOR} = "${ChangeDetectionUtil.changeDetectionMode(this.changeDetectionStrategy)}";
116116
${CONTEXT_ACCESSOR} = context;
117117
${LOCALS_ACCESSOR} = locals;
118118
${this._genHydrateDirectives()}
119119
${this._genHydrateDetectors()}
120-
${PIPE_REGISTRY_ACCESSOR} = pipeRegistry;
120+
${PIPES_ACCESSOR} = pipes;
121121
${ALREADY_CHECKED_ACCESSOR} = false;
122122
}
123123
124124
${typeName}.prototype.dehydrate = function() {
125125
${this._genPipeOnDestroy()}
126126
${this._genFieldDefinitions()}
127127
${LOCALS_ACCESSOR} = null;
128-
${PIPE_REGISTRY_ACCESSOR} = null;
128+
${PIPES_ACCESSOR} = null;
129129
}
130130
131131
${typeName}.prototype.hydrated = function() {
@@ -267,10 +267,10 @@ export class ChangeDetectorJITGenerator {
267267
return `
268268
${CURRENT_PROTO} = ${PROTOS_ACCESSOR}[${protoIndex}];
269269
if (${pipe} === ${UTIL}.uninitialized()) {
270-
${pipe} = ${PIPE_REGISTRY_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
270+
${pipe} = ${PIPES_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
271271
} else if (!${pipe}.supports(${context})) {
272272
${pipe}.onDestroy();
273-
${pipe} = ${PIPE_REGISTRY_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
273+
${pipe} = ${PIPES_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
274274
}
275275
276276
${newValue} = ${pipe}.transform(${context}, [${argString}]);

modules/angular2/src/change_detection/dynamic_change_detector.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Locals} from 'angular2/src/change_detection/parser/locals';
44

55
import {AbstractChangeDetector} from './abstract_change_detector';
66
import {BindingRecord} from './binding_record';
7-
import {PipeRegistry} from './pipes/pipes';
7+
import {Pipes} from './pipes/pipes';
88
import {ChangeDetectionUtil, SimpleChange, uninitialized} from './change_detection_util';
99

1010

@@ -14,51 +14,51 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
1414
locals: Locals = null;
1515
values: List<any>;
1616
changes: List<any>;
17-
pipes: List<any>;
17+
localPipes: List<any>;
1818
prevContexts: List<any>;
1919
directives: any = null;
2020
alreadyChecked: boolean = false;
21-
private pipeRegistry: PipeRegistry = null;
21+
private pipes: Pipes = null;
2222

2323
constructor(id: string, private changeControlStrategy: string, private dispatcher: any,
2424
private protos: List<ProtoRecord>, private directiveRecords: List<any>) {
2525
super(id);
2626
this.values = ListWrapper.createFixedSize(protos.length + 1);
27-
this.pipes = ListWrapper.createFixedSize(protos.length + 1);
27+
this.localPipes = ListWrapper.createFixedSize(protos.length + 1);
2828
this.prevContexts = ListWrapper.createFixedSize(protos.length + 1);
2929
this.changes = ListWrapper.createFixedSize(protos.length + 1);
3030

3131
this.values[0] = null;
3232
ListWrapper.fill(this.values, uninitialized, 1);
33-
ListWrapper.fill(this.pipes, null);
33+
ListWrapper.fill(this.localPipes, null);
3434
ListWrapper.fill(this.prevContexts, uninitialized);
3535
ListWrapper.fill(this.changes, false);
3636
}
3737

38-
hydrate(context: any, locals: Locals, directives: any, pipeRegistry: PipeRegistry): void {
38+
hydrate(context: any, locals: Locals, directives: any, pipes: Pipes): void {
3939
this.mode = ChangeDetectionUtil.changeDetectionMode(this.changeControlStrategy);
4040
this.values[0] = context;
4141
this.locals = locals;
4242
this.directives = directives;
4343
this.alreadyChecked = false;
44-
this.pipeRegistry = pipeRegistry;
44+
this.pipes = pipes;
4545
}
4646

4747
dehydrate() {
4848
this._destroyPipes();
4949
this.values[0] = null;
5050
ListWrapper.fill(this.values, uninitialized, 1);
5151
ListWrapper.fill(this.changes, false);
52-
ListWrapper.fill(this.pipes, null);
52+
ListWrapper.fill(this.localPipes, null);
5353
ListWrapper.fill(this.prevContexts, uninitialized);
5454
this.locals = null;
55-
this.pipeRegistry = null;
55+
this.pipes = null;
5656
}
5757

5858
_destroyPipes() {
59-
for (var i = 0; i < this.pipes.length; ++i) {
60-
if (isPresent(this.pipes[i])) {
61-
this.pipes[i].onDestroy();
59+
for (var i = 0; i < this.localPipes.length; ++i) {
60+
if (isPresent(this.localPipes[i])) {
61+
this.localPipes[i].onDestroy();
6262
}
6363
}
6464
}
@@ -270,7 +270,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
270270
if (isPresent(storedPipe)) {
271271
storedPipe.onDestroy();
272272
}
273-
var pipe = this.pipeRegistry.get(proto.name, context, this.ref);
273+
var pipe = this.pipes.get(proto.name, context, this.ref);
274274
this._writePipe(proto, pipe);
275275
return pipe;
276276
}
@@ -289,9 +289,9 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
289289

290290
_writeSelf(proto: ProtoRecord, value) { this.values[proto.selfIndex] = value; }
291291

292-
_readPipe(proto: ProtoRecord) { return this.pipes[proto.selfIndex]; }
292+
_readPipe(proto: ProtoRecord) { return this.localPipes[proto.selfIndex]; }
293293

294-
_writePipe(proto: ProtoRecord, value) { this.pipes[proto.selfIndex] = value; }
294+
_writePipe(proto: ProtoRecord, value) { this.localPipes[proto.selfIndex] = value; }
295295

296296
_setChanged(proto: ProtoRecord, value: boolean) { this.changes[proto.selfIndex] = value; }
297297

modules/angular2/src/change_detection/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface ChangeDetector {
5151
removeChild(cd: ChangeDetector): void;
5252
removeShadowDomChild(cd: ChangeDetector): void;
5353
remove(): void;
54-
hydrate(context: any, locals: Locals, directives: any, pipeRegistry: any): void;
54+
hydrate(context: any, locals: Locals, directives: any, pipes: any): void;
5555
dehydrate(): void;
5656
markPathToRootAsCheckOnce(): void;
5757

modules/angular2/src/change_detection/pipes/pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
66

77
@Injectable()
88
@CONST()
9-
export class PipeRegistry {
9+
export class Pipes {
1010
constructor(public config) {}
1111

1212
get(type: string, obj, cdRef?: ChangeDetectorRef, existingPipe?: Pipe): Pipe {

modules/angular2/src/change_detection/pregen_proto_change_detector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export 'package:angular2/src/change_detection/directive_record.dart'
1616
export 'package:angular2/src/change_detection/interfaces.dart'
1717
show ChangeDetector, ChangeDetectorDefinition, ProtoChangeDetector;
1818
export 'package:angular2/src/change_detection/pipes/pipes.dart'
19-
show PipeRegistry;
19+
show Pipes;
2020
export 'package:angular2/src/change_detection/proto_record.dart'
2121
show ProtoRecord;
2222
export 'package:angular2/src/change_detection/change_detection_util.dart'

modules/angular2/src/core/application.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
DynamicChangeDetection,
2121
JitChangeDetection,
2222
PreGeneratedChangeDetection,
23-
PipeRegistry,
24-
defaultPipeRegistry
23+
Pipes,
24+
defaultPipes
2525
} from 'angular2/change_detection';
2626
import {ExceptionHandler} from './exception_handler';
2727
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
@@ -118,7 +118,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
118118
Compiler,
119119
CompilerCache,
120120
ViewResolver,
121-
bind(PipeRegistry).toValue(defaultPipeRegistry),
121+
bind(Pipes).toValue(defaultPipes),
122122
bind(ChangeDetection).toClass(bestChangeDetection),
123123
ViewLoader,
124124
DirectiveResolver,

modules/angular2/src/core/compiler/element_injector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
onAllChangesDone
5353
} from 'angular2/src/core/annotations_impl/annotations';
5454
import {hasLifecycleHook} from './directive_lifecycle_reflector';
55-
import {ChangeDetector, ChangeDetectorRef, PipeRegistry} from 'angular2/change_detection';
55+
import {ChangeDetector, ChangeDetectorRef, Pipes} from 'angular2/change_detection';
5656
import {QueryList} from './query_list';
5757
import {reflector} from 'angular2/src/reflection/reflection';
5858
import {DirectiveMetadata} from 'angular2/src/render/api';
@@ -65,7 +65,7 @@ export class StaticKeys {
6565
viewContainerId: number;
6666
changeDetectorRefId: number;
6767
elementRefId: number;
68-
pipeRegistryKey: Key;
68+
pipesKey: Key;
6969

7070
constructor() {
7171
this.viewManagerId = Key.get(avmModule.AppViewManager).id;
@@ -74,7 +74,7 @@ export class StaticKeys {
7474
this.changeDetectorRefId = Key.get(ChangeDetectorRef).id;
7575
this.elementRefId = Key.get(ElementRef).id;
7676
// not an id because the public API of injector works only with keys and tokens
77-
this.pipeRegistryKey = Key.get(PipeRegistry);
77+
this.pipesKey = Key.get(Pipes);
7878
}
7979

8080
static instance(): StaticKeys {
@@ -550,9 +550,9 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
550550
injector.internalStrategy.hydrate();
551551
}
552552

553-
getPipeRegistry(): PipeRegistry {
554-
var pipeRegistryKey = StaticKeys.instance().pipeRegistryKey;
555-
return this._injector.getOptional(pipeRegistryKey);
553+
getPipes(): Pipes {
554+
var pipesKey = StaticKeys.instance().pipesKey;
555+
return this._injector.getOptional(pipesKey);
556556
}
557557

558558
hasVariableBinding(name: string): boolean {

0 commit comments

Comments
 (0)