
committed by
Harry Terkelsen

parent
c320240086
commit
d8c5ab232c
@ -25,8 +25,8 @@ export class CodegenLogicUtil {
|
||||
* value of the record. Used by property bindings.
|
||||
*/
|
||||
genPropertyBindingEvalValue(protoRec: ProtoRecord): string {
|
||||
return this.genEvalValue(protoRec, idx => this._names.getLocalName(idx),
|
||||
this._names.getLocalsAccessorName());
|
||||
return this._genEvalValue(protoRec, idx => this._names.getLocalName(idx),
|
||||
this._names.getLocalsAccessorName());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,12 +34,12 @@ export class CodegenLogicUtil {
|
||||
* value of the record. Used by event bindings.
|
||||
*/
|
||||
genEventBindingEvalValue(eventRecord: any, protoRec: ProtoRecord): string {
|
||||
return this.genEvalValue(protoRec, idx => this._names.getEventLocalName(eventRecord, idx),
|
||||
"locals");
|
||||
return this._genEvalValue(protoRec, idx => this._names.getEventLocalName(eventRecord, idx),
|
||||
"locals");
|
||||
}
|
||||
|
||||
private genEvalValue(protoRec: ProtoRecord, getLocalName: Function,
|
||||
localsAccessor: string): string {
|
||||
private _genEvalValue(protoRec: ProtoRecord, getLocalName: Function,
|
||||
localsAccessor: string): string {
|
||||
var context = (protoRec.contextIndex == -1) ?
|
||||
this._names.getDirectiveName(protoRec.directiveIndex) :
|
||||
getLocalName(protoRec.contextIndex);
|
||||
|
@ -44,17 +44,17 @@ export class CodegenNameUtil {
|
||||
_sanitizedNames: string[];
|
||||
_sanitizedEventNames: Map<EventBinding, string[]>;
|
||||
|
||||
constructor(private records: ProtoRecord[], private eventBindings: EventBinding[],
|
||||
private directiveRecords: any[], private utilName: string) {
|
||||
this._sanitizedNames = ListWrapper.createFixedSize(this.records.length + 1);
|
||||
constructor(private _records: ProtoRecord[], private _eventBindings: EventBinding[],
|
||||
private _directiveRecords: any[], private _utilName: string) {
|
||||
this._sanitizedNames = ListWrapper.createFixedSize(this._records.length + 1);
|
||||
this._sanitizedNames[CONTEXT_INDEX] = _CONTEXT_ACCESSOR;
|
||||
for (var i = 0, iLen = this.records.length; i < iLen; ++i) {
|
||||
this._sanitizedNames[i + 1] = sanitizeName(`${this.records[i].name}${i}`);
|
||||
for (var i = 0, iLen = this._records.length; i < iLen; ++i) {
|
||||
this._sanitizedNames[i + 1] = sanitizeName(`${this._records[i].name}${i}`);
|
||||
}
|
||||
|
||||
this._sanitizedEventNames = new Map();
|
||||
for (var ebIndex = 0; ebIndex < eventBindings.length; ++ebIndex) {
|
||||
var eb = eventBindings[ebIndex];
|
||||
for (var ebIndex = 0; ebIndex < _eventBindings.length; ++ebIndex) {
|
||||
var eb = _eventBindings[ebIndex];
|
||||
var names = [_CONTEXT_ACCESSOR];
|
||||
for (var i = 0, iLen = eb.records.length; i < iLen; ++i) {
|
||||
names.push(sanitizeName(`${eb.records[i].name}${i}_${ebIndex}`));
|
||||
@ -99,7 +99,7 @@ export class CodegenNameUtil {
|
||||
if (i == CONTEXT_INDEX) {
|
||||
declarations.push(`${this.getLocalName(i)} = ${this.getFieldName(i)}`);
|
||||
} else {
|
||||
var rec = this.records[i - 1];
|
||||
var rec = this._records[i - 1];
|
||||
if (rec.argumentToPureFunction) {
|
||||
var changeName = this.getChangeName(i);
|
||||
declarations.push(`${this.getLocalName(i)},${changeName}`);
|
||||
@ -138,20 +138,20 @@ export class CodegenNameUtil {
|
||||
getAllFieldNames(): string[] {
|
||||
var fieldList = [];
|
||||
for (var k = 0, kLen = this.getFieldCount(); k < kLen; ++k) {
|
||||
if (k === 0 || this.records[k - 1].shouldBeChecked()) {
|
||||
if (k === 0 || this._records[k - 1].shouldBeChecked()) {
|
||||
fieldList.push(this.getFieldName(k));
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0, iLen = this.records.length; i < iLen; ++i) {
|
||||
var rec = this.records[i];
|
||||
for (var i = 0, iLen = this._records.length; i < iLen; ++i) {
|
||||
var rec = this._records[i];
|
||||
if (rec.isPipeRecord()) {
|
||||
fieldList.push(this.getPipeName(rec.selfIndex));
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0, jLen = this.directiveRecords.length; j < jLen; ++j) {
|
||||
var dRec = this.directiveRecords[j];
|
||||
for (var j = 0, jLen = this._directiveRecords.length; j < jLen; ++j) {
|
||||
var dRec = this._directiveRecords[j];
|
||||
fieldList.push(this.getDirectiveName(dRec.directiveIndex));
|
||||
if (!dRec.isDefaultChangeDetection()) {
|
||||
fieldList.push(this.getDetectorName(dRec.directiveIndex));
|
||||
@ -169,7 +169,7 @@ export class CodegenNameUtil {
|
||||
if (ListWrapper.isEmpty(fields)) return '';
|
||||
|
||||
// At least one assignment.
|
||||
fields.push(`${this.utilName}.uninitialized;`);
|
||||
fields.push(`${this._utilName}.uninitialized;`);
|
||||
return ListWrapper.join(fields, ' = ');
|
||||
}
|
||||
|
||||
@ -179,9 +179,9 @@ export class CodegenNameUtil {
|
||||
genPipeOnDestroy(): string {
|
||||
return ListWrapper.join(
|
||||
ListWrapper.map(
|
||||
ListWrapper.filter(this.records, (r) => { return r.isPipeRecord(); }),
|
||||
ListWrapper.filter(this._records, (r) => { return r.isPipeRecord(); }),
|
||||
(r) => {
|
||||
return `${this.utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`;
|
||||
return `${this._utilName}.callPipeOnDestroy(${this.getPipeName(r.selfIndex)});`;
|
||||
}),
|
||||
'\n');
|
||||
}
|
||||
|
@ -26,12 +26,12 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
|
||||
constructor(id: string, dispatcher: any, numberOfPropertyProtoRecords: number,
|
||||
propertyBindingTargets: BindingTarget[], directiveIndices: DirectiveIndex[],
|
||||
strategy: ChangeDetectionStrategy, private records: ProtoRecord[],
|
||||
private eventBindings: EventBinding[], private directiveRecords: DirectiveRecord[],
|
||||
private genConfig: ChangeDetectorGenConfig) {
|
||||
strategy: ChangeDetectionStrategy, private _records: ProtoRecord[],
|
||||
private _eventBindings: EventBinding[], private _directiveRecords: DirectiveRecord[],
|
||||
private _genConfig: ChangeDetectorGenConfig) {
|
||||
super(id, dispatcher, numberOfPropertyProtoRecords, propertyBindingTargets, directiveIndices,
|
||||
strategy);
|
||||
var len = records.length + 1;
|
||||
var len = _records.length + 1;
|
||||
this.values = ListWrapper.createFixedSize(len);
|
||||
this.localPipes = ListWrapper.createFixedSize(len);
|
||||
this.prevContexts = ListWrapper.createFixedSize(len);
|
||||
@ -80,7 +80,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
}
|
||||
|
||||
_matchingEventBindings(eventName: string, elIndex: number): EventBinding[] {
|
||||
return ListWrapper.filter(this.eventBindings,
|
||||
return ListWrapper.filter(this._eventBindings,
|
||||
eb => eb.eventName == eventName && eb.elIndex === elIndex);
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
checkNoChanges(): void { this.runDetectChanges(true); }
|
||||
|
||||
detectChangesInRecordsInternal(throwOnChange: boolean) {
|
||||
var protos = this.records;
|
||||
var protos = this._records;
|
||||
|
||||
var changes = null;
|
||||
var isChanged = false;
|
||||
@ -162,12 +162,12 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
}
|
||||
|
||||
_firstInBinding(r: ProtoRecord): boolean {
|
||||
var prev = ChangeDetectionUtil.protoByIndex(this.records, r.selfIndex - 1);
|
||||
var prev = ChangeDetectionUtil.protoByIndex(this._records, r.selfIndex - 1);
|
||||
return isBlank(prev) || prev.bindingRecord !== r.bindingRecord;
|
||||
}
|
||||
|
||||
afterContentLifecycleCallbacksInternal() {
|
||||
var dirs = this.directiveRecords;
|
||||
var dirs = this._directiveRecords;
|
||||
for (var i = dirs.length - 1; i >= 0; --i) {
|
||||
var dir = dirs[i];
|
||||
if (dir.callAfterContentInit && !this.alreadyChecked) {
|
||||
@ -181,7 +181,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
}
|
||||
|
||||
afterViewLifecycleCallbacksInternal() {
|
||||
var dirs = this.directiveRecords;
|
||||
var dirs = this._directiveRecords;
|
||||
for (var i = dirs.length - 1; i >= 0; --i) {
|
||||
var dir = dirs[i];
|
||||
if (dir.callAfterViewInit && !this.alreadyChecked) {
|
||||
@ -201,7 +201,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
bindingRecord.setter(this._getDirectiveFor(directiveIndex), change.currentValue);
|
||||
}
|
||||
|
||||
if (this.genConfig.logBindingUpdate) {
|
||||
if (this._genConfig.logBindingUpdate) {
|
||||
super.logBindingUpdate(change.currentValue);
|
||||
}
|
||||
}
|
||||
|
@ -42,19 +42,19 @@ export class DynamicProtoChangeDetector implements ProtoChangeDetector {
|
||||
_eventBindingRecords: EventBinding[];
|
||||
_directiveIndices: DirectiveIndex[];
|
||||
|
||||
constructor(private definition: ChangeDetectorDefinition) {
|
||||
this._propertyBindingRecords = createPropertyRecords(definition);
|
||||
this._eventBindingRecords = createEventRecords(definition);
|
||||
this._propertyBindingTargets = this.definition.bindingRecords.map(b => b.target);
|
||||
this._directiveIndices = this.definition.directiveRecords.map(d => d.directiveIndex);
|
||||
constructor(private _definition: ChangeDetectorDefinition) {
|
||||
this._propertyBindingRecords = createPropertyRecords(_definition);
|
||||
this._eventBindingRecords = createEventRecords(_definition);
|
||||
this._propertyBindingTargets = this._definition.bindingRecords.map(b => b.target);
|
||||
this._directiveIndices = this._definition.directiveRecords.map(d => d.directiveIndex);
|
||||
}
|
||||
|
||||
instantiate(dispatcher: any): ChangeDetector {
|
||||
return new DynamicChangeDetector(
|
||||
this.definition.id, dispatcher, this._propertyBindingRecords.length,
|
||||
this._propertyBindingTargets, this._directiveIndices, this.definition.strategy,
|
||||
this._propertyBindingRecords, this._eventBindingRecords, this.definition.directiveRecords,
|
||||
this.definition.genConfig);
|
||||
this._definition.id, dispatcher, this._propertyBindingRecords.length,
|
||||
this._propertyBindingTargets, this._directiveIndices, this._definition.strategy,
|
||||
this._propertyBindingRecords, this._eventBindingRecords, this._definition.directiveRecords,
|
||||
this._definition.genConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,13 +40,13 @@ export class NgFor {
|
||||
_ngForOf: any;
|
||||
private _differ: IterableDiffer;
|
||||
|
||||
constructor(private viewContainer: ViewContainerRef, private templateRef: TemplateRef,
|
||||
private iterableDiffers: IterableDiffers, private cdr: ChangeDetectorRef) {}
|
||||
constructor(private _viewContainer: ViewContainerRef, private _templateRef: TemplateRef,
|
||||
private _iterableDiffers: IterableDiffers, private _cdr: ChangeDetectorRef) {}
|
||||
|
||||
set ngForOf(value: any) {
|
||||
this._ngForOf = value;
|
||||
if (isBlank(this._differ) && isPresent(value)) {
|
||||
this._differ = this.iterableDiffers.find(value).create(this.cdr);
|
||||
this._differ = this._iterableDiffers.find(value).create(this._cdr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,19 +67,19 @@ export class NgFor {
|
||||
changes.forEachMovedItem((movedRecord) =>
|
||||
recordViewTuples.push(new RecordViewTuple(movedRecord, null)));
|
||||
|
||||
var insertTuples = NgFor.bulkRemove(recordViewTuples, this.viewContainer);
|
||||
var insertTuples = NgFor.bulkRemove(recordViewTuples, this._viewContainer);
|
||||
|
||||
changes.forEachAddedItem((addedRecord) =>
|
||||
insertTuples.push(new RecordViewTuple(addedRecord, null)));
|
||||
|
||||
NgFor.bulkInsert(insertTuples, this.viewContainer, this.templateRef);
|
||||
NgFor.bulkInsert(insertTuples, this._viewContainer, this._templateRef);
|
||||
|
||||
for (var i = 0; i < insertTuples.length; i++) {
|
||||
this._perViewChange(insertTuples[i].view, insertTuples[i].record);
|
||||
}
|
||||
|
||||
for (var i = 0, ilen = this.viewContainer.length; i < ilen; i++) {
|
||||
this.viewContainer.get(i).setLocal('last', i === ilen - 1);
|
||||
for (var i = 0, ilen = this._viewContainer.length; i < ilen; i++) {
|
||||
this._viewContainer.get(i).setLocal('last', i === ilen - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class _ArrayLogger {
|
||||
*/
|
||||
@Injectable()
|
||||
export class ExceptionHandler {
|
||||
constructor(private logger: any, private rethrowException: boolean = true) {}
|
||||
constructor(private _logger: any, private _rethrowException: boolean = true) {}
|
||||
|
||||
static exceptionToString(exception: any, stackTrace: any = null, reason: string = null): string {
|
||||
var l = new _ArrayLogger();
|
||||
@ -47,36 +47,36 @@ export class ExceptionHandler {
|
||||
var originalStack = this._findOriginalStack(exception);
|
||||
var context = this._findContext(exception);
|
||||
|
||||
this.logger.logGroup(`EXCEPTION: ${exception}`);
|
||||
this._logger.logGroup(`EXCEPTION: ${exception}`);
|
||||
|
||||
if (isPresent(stackTrace) && isBlank(originalStack)) {
|
||||
this.logger.logError("STACKTRACE:");
|
||||
this.logger.logError(this._longStackTrace(stackTrace));
|
||||
this._logger.logError("STACKTRACE:");
|
||||
this._logger.logError(this._longStackTrace(stackTrace));
|
||||
}
|
||||
|
||||
if (isPresent(reason)) {
|
||||
this.logger.logError(`REASON: ${reason}`);
|
||||
this._logger.logError(`REASON: ${reason}`);
|
||||
}
|
||||
|
||||
if (isPresent(originalException)) {
|
||||
this.logger.logError(`ORIGINAL EXCEPTION: ${originalException}`);
|
||||
this._logger.logError(`ORIGINAL EXCEPTION: ${originalException}`);
|
||||
}
|
||||
|
||||
if (isPresent(originalStack)) {
|
||||
this.logger.logError("ORIGINAL STACKTRACE:");
|
||||
this.logger.logError(this._longStackTrace(originalStack));
|
||||
this._logger.logError("ORIGINAL STACKTRACE:");
|
||||
this._logger.logError(this._longStackTrace(originalStack));
|
||||
}
|
||||
|
||||
if (isPresent(context)) {
|
||||
this.logger.logError("ERROR CONTEXT:");
|
||||
this.logger.logError(context);
|
||||
this._logger.logError("ERROR CONTEXT:");
|
||||
this._logger.logError(context);
|
||||
}
|
||||
|
||||
this.logger.logGroupEnd();
|
||||
this._logger.logGroupEnd();
|
||||
|
||||
// We rethrow exceptions, so operations like 'bootstrap' will result in an error
|
||||
// when an exception happens. If we do not rethrow, bootstrap will always succeed.
|
||||
if (this.rethrowException) throw exception;
|
||||
if (this._rethrowException) throw exception;
|
||||
}
|
||||
|
||||
_longStackTrace(stackTrace: any): any {
|
||||
|
@ -110,5 +110,5 @@ export class DatePipe implements PipeTransform {
|
||||
return DateFormatter.format(value, defaultLocale, pattern);
|
||||
}
|
||||
|
||||
private supports(obj: any): boolean { return isDate(obj) || isNumber(obj); }
|
||||
supports(obj: any): boolean { return isDate(obj) || isNumber(obj); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user