chore: kill ListWrapper.create() and .push().

These wrappers are not natively understood by
ts2dart. Removing them will improve Dart2JS
compilation due to fewer megamorphic calls to List
functions.

It also makes Angular code more succinct and
improves type safety in Angular due to better type
inference of the Array component type.

This change exposed several bugs in Angular.
This commit is contained in:
Martin Probst 2015-06-17 11:17:21 -07:00
parent 6af41a4543
commit c7e48350d3
88 changed files with 360 additions and 387 deletions

View File

@ -17,14 +17,14 @@ export class AbstractChangeDetector extends ChangeDetector {
}
addChild(cd: ChangeDetector): void {
ListWrapper.push(this.lightDomChildren, cd);
this.lightDomChildren.push(cd);
cd.parent = this;
}
removeChild(cd: ChangeDetector): void { ListWrapper.remove(this.lightDomChildren, cd); }
addShadowDomChild(cd: ChangeDetector): void {
ListWrapper.push(this.shadowDomChildren, cd);
this.shadowDomChildren.push(cd);
cd.parent = this;
}

View File

@ -13,7 +13,7 @@ import {RecordType, ProtoRecord} from './proto_record';
* replaced with very cheap SELF records.
*/
export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
var res: List<ProtoRecord> = ListWrapper.create();
var res: List<ProtoRecord> = [];
var indexMap: Map<number, number> = MapWrapper.create();
for (var i = 0; i < records.length; ++i) {
@ -22,14 +22,14 @@ export function coalesce(records: List<ProtoRecord>): List<ProtoRecord> {
var matchingRecord = _findMatching(record, res);
if (isPresent(matchingRecord) && record.lastInBinding) {
ListWrapper.push(res, _selfRecord(record, matchingRecord.selfIndex, res.length + 1));
res.push(_selfRecord(record, matchingRecord.selfIndex, res.length + 1));
MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex);
} else if (isPresent(matchingRecord) && !record.lastInBinding) {
MapWrapper.set(indexMap, r.selfIndex, matchingRecord.selfIndex);
} else {
ListWrapper.push(res, record);
res.push(record);
MapWrapper.set(indexMap, r.selfIndex, record.selfIndex);
}
}

View File

@ -23,7 +23,7 @@ enum TokenType {
var tokens = [];
var token = scanner.scanToken();
while (token != null) {
ListWrapper.push(tokens, token);
tokens.push(token);
token = scanner.scanToken();
}
return tokens;

View File

@ -99,11 +99,11 @@ export class Parser {
var part = parts[i];
if (i % 2 === 0) {
// fixed string
ListWrapper.push(strings, part);
strings.push(part);
} else {
var tokens = this._lexer.tokenize(part);
var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
ListWrapper.push(expressions, ast);
expressions.push(ast);
}
}
return new ASTWithSource(new Interpolation(strings, expressions), input, location);
@ -194,7 +194,7 @@ class _ParseAST {
var exprs = [];
while (this.index < this.tokens.length) {
var expr = this.parsePipe();
ListWrapper.push(exprs, expr);
exprs.push(expr);
if (this.optionalCharacter($SEMICOLON)) {
if (!this.parseAction) {
@ -222,7 +222,7 @@ class _ParseAST {
var name = this.expectIdentifierOrKeyword();
var args = [];
while (this.optionalCharacter($COLON)) {
ListWrapper.push(args, this.parsePipe());
args.push(this.parsePipe());
}
result = new Pipe(result, name, args, true);
} while (this.optionalOperator("|"));
@ -456,7 +456,7 @@ class _ParseAST {
var result = [];
if (!this.next.isCharacter(terminator)) {
do {
ListWrapper.push(result, this.parsePipe());
result.push(this.parsePipe());
} while (this.optionalCharacter($COMMA));
}
return result;
@ -469,9 +469,9 @@ class _ParseAST {
if (!this.optionalCharacter($RBRACE)) {
do {
var key = this.expectIdentifierOrKeywordOrString();
ListWrapper.push(keys, key);
keys.push(key);
this.expectCharacter($COLON);
ListWrapper.push(values, this.parsePipe());
values.push(this.parsePipe());
} while (this.optionalCharacter($COMMA));
this.expectCharacter($RBRACE);
}
@ -500,7 +500,7 @@ class _ParseAST {
if (this.next.isCharacter($RPAREN)) return [];
var positionals = [];
do {
ListWrapper.push(positionals, this.parsePipe());
positionals.push(this.parsePipe());
} while (this.optionalCharacter($COMMA));
return positionals;
}
@ -522,7 +522,7 @@ class _ParseAST {
var exprs = [];
while (this.index < this.tokens.length && !this.next.isCharacter($RBRACE)) {
var expr = this.parseExpression();
ListWrapper.push(exprs, expr);
exprs.push(expr);
if (this.optionalCharacter($SEMICOLON)) {
while (this.optionalCharacter($SEMICOLON)) {
@ -581,7 +581,7 @@ class _ParseAST {
var source = this.input.substring(start, this.inputIndex);
expression = new ASTWithSource(ast, source, this.location);
}
ListWrapper.push(bindings, new TemplateBinding(key, keyIsVar, name, expression));
bindings.push(new TemplateBinding(key, keyIsVar, name, expression));
if (!this.optionalCharacter($SEMICOLON)) {
this.optionalCharacter($COMMA);
}

View File

@ -448,26 +448,26 @@ export class IterableChanges extends Pipe {
var list = [];
for (record = this._itHead; record !== null; record = record._next) {
ListWrapper.push(list, record);
list.push(record);
}
var previous = [];
for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
ListWrapper.push(previous, record);
previous.push(record);
}
var additions = [];
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
ListWrapper.push(additions, record);
additions.push(record);
}
var moves = [];
for (record = this._movesHead; record !== null; record = record._nextMoved) {
ListWrapper.push(moves, record);
moves.push(record);
}
var removals = [];
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
ListWrapper.push(removals, record);
removals.push(record);
}
return "collection: " + list.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" +

View File

@ -299,19 +299,19 @@ export class KeyValueChanges extends Pipe {
var record: KVChangeRecord;
for (record = this._mapHead; record !== null; record = record._next) {
ListWrapper.push(items, stringify(record));
items.push(stringify(record));
}
for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
ListWrapper.push(previous, stringify(record));
previous.push(stringify(record));
}
for (record = this._changesHead; record !== null; record = record._nextChanged) {
ListWrapper.push(changes, stringify(record));
changes.push(stringify(record));
}
for (record = this._additionsHead; record !== null; record = record._nextAdded) {
ListWrapper.push(additions, stringify(record));
additions.push(stringify(record));
}
for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
ListWrapper.push(removals, stringify(record));
removals.push(stringify(record));
}
return "map: " + items.join(', ') + "\n" + "previous: " + previous.join(', ') + "\n" +

View File

@ -82,10 +82,9 @@ export class ProtoRecordBuilder {
_appendRecords(b: BindingRecord, variableNames: List<string>) {
if (b.isDirectiveLifecycle()) {
ListWrapper.push(
this.records,
new ProtoRecord(RecordType.DIRECTIVE_LIFECYCLE, b.lifecycleEvent, null, [], [], -1, null,
this.records.length + 1, b, null, false, false));
this.records.push(new ProtoRecord(RecordType.DIRECTIVE_LIFECYCLE, b.lifecycleEvent, null, [],
[], -1, null, this.records.length + 1, b, null, false,
false));
} else {
_ConvertAstIntoProtoRecords.append(this.records, b, variableNames);
}
@ -215,13 +214,13 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
_addRecord(type, name, funcOrValue, args, fixedArgs, context) {
var selfIndex = this._records.length + 1;
if (context instanceof DirectiveIndex) {
ListWrapper.push(this._records, new ProtoRecord(type, name, funcOrValue, args, fixedArgs, -1,
context, selfIndex, this._bindingRecord,
this._expressionAsString, false, false));
this._records.push(new ProtoRecord(type, name, funcOrValue, args, fixedArgs, -1, context,
selfIndex, this._bindingRecord, this._expressionAsString,
false, false));
} else {
ListWrapper.push(this._records, new ProtoRecord(type, name, funcOrValue, args, fixedArgs,
context, null, selfIndex, this._bindingRecord,
this._expressionAsString, false, false));
this._records.push(new ProtoRecord(type, name, funcOrValue, args, fixedArgs, context, null,
selfIndex, this._bindingRecord, this._expressionAsString,
false, false));
}
return selfIndex;
}

View File

@ -342,9 +342,9 @@ export class ApplicationRef {
function _createAppInjector(appComponentType: Type, bindings: List<Type | Binding | List<any>>,
zone: NgZone): Injector {
if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings);
var mergedBindings = isPresent(bindings) ?
ListWrapper.concat(_injectorBindings(appComponentType), bindings) :
_injectorBindings(appComponentType);
ListWrapper.push(mergedBindings, bind(NgZone).toValue(zone));
var mergedBindings: any[] =
isPresent(bindings) ? ListWrapper.concat(_injectorBindings(appComponentType), bindings) :
_injectorBindings(appComponentType);
mergedBindings.push(bind(NgZone).toValue(zone));
return _rootInjector.resolveAndCreateChild(mergedBindings);
}

View File

@ -22,7 +22,7 @@ export class BaseQueryList<T> {
}
add(obj) {
ListWrapper.push(this._results, obj);
this._results.push(obj);
this._dirty = true;
}
@ -33,7 +33,7 @@ export class BaseQueryList<T> {
}
}
onChange(callback) { ListWrapper.push(this._callbacks, callback); }
onChange(callback) { this._callbacks.push(callback); }
removeCallback(callback) { ListWrapper.remove(this._callbacks, callback); }

View File

@ -187,8 +187,7 @@ export class Compiler {
(nestedPv: AppProtoView) => { elementBinder.nestedProtoView = nestedPv; };
var nestedCall = this._compile(nestedComponent);
if (isPromise(nestedCall)) {
ListWrapper.push(nestedPVPromises,
(<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
nestedPVPromises.push((<Promise<AppProtoView>>nestedCall).then(elementBinderDone));
} else {
elementBinderDone(<AppProtoView>nestedCall);
}
@ -206,7 +205,7 @@ export class Compiler {
ListWrapper.forEach(protoViews, (protoView) => {
ListWrapper.forEach(protoView.elementBinders, (elementBinder) => {
if (isPresent(elementBinder.componentDirective)) {
ListWrapper.push(componentElementBinders, elementBinder);
componentElementBinders.push(elementBinder);
}
});
});
@ -254,7 +253,7 @@ export class Compiler {
if (isArray(item)) {
this._flattenList(item, out);
} else {
ListWrapper.push(out, item);
out.push(item);
}
}
}

View File

@ -154,7 +154,7 @@ export class TreeNode<T extends TreeNode<any>> {
var res = [];
var child = this._head;
while (child != null) {
ListWrapper.push(res, child);
res.push(child);
child = child._next;
}
return res;
@ -285,7 +285,7 @@ export class DirectiveBinding extends ResolvedBinding {
var readAttributes = [];
ListWrapper.forEach(deps, (dep) => {
if (isPresent(dep.attributeName)) {
ListWrapper.push(readAttributes, dep.attributeName);
readAttributes.push(dep.attributeName);
}
});
return readAttributes;
@ -357,10 +357,9 @@ export class BindingData {
if (!(this.binding instanceof DirectiveBinding)) return [];
var res = [];
var db = <DirectiveBinding>this.binding;
MapWrapper.forEach(
db.hostActions,
(actionExpression, actionName) => {ListWrapper.push(
res, new HostActionAccessor(actionExpression, reflector.getter(actionName)))});
MapWrapper.forEach(db.hostActions, (actionExpression, actionName) => {
res.push(new HostActionAccessor(actionExpression, reflector.getter(actionName)));
});
return res;
}
}
@ -409,8 +408,8 @@ export class ProtoElementInjector {
bd: List<BindingData>,
firstBindingIsComponent: boolean) {
ListWrapper.forEach(dirBindings, dirBinding => {
ListWrapper.push(bd, ProtoElementInjector._createBindingData(
firstBindingIsComponent, dirBinding, dirBindings, dirBinding));
bd.push(ProtoElementInjector._createBindingData(firstBindingIsComponent, dirBinding,
dirBindings, dirBinding));
});
}
@ -425,9 +424,9 @@ export class ProtoElementInjector {
`Multiple directives defined the same host injectable: "${stringify(b.key.token)}"`);
}
MapWrapper.set(visitedIds, b.key.id, true);
ListWrapper.push(bd, ProtoElementInjector._createBindingData(
firstBindingIsComponent, dirBinding, dirBindings,
ProtoElementInjector._createBinding(b)));
bd.push(ProtoElementInjector._createBindingData(firstBindingIsComponent, dirBinding,
dirBindings,
ProtoElementInjector._createBinding(b)));
});
});
}
@ -442,8 +441,7 @@ export class ProtoElementInjector {
var db = <DirectiveBinding>bindings[0];
ListWrapper.forEach(
db.resolvedViewInjectables,
b => ListWrapper.push(bd,
new BindingData(ProtoElementInjector._createBinding(b), SHADOW_DOM)));
b => bd.push(new BindingData(ProtoElementInjector._createBinding(b), SHADOW_DOM)));
}
private static _createBinding(b: ResolvedBinding) {
@ -963,15 +961,15 @@ export class ElementInjector extends TreeNode<ElementInjector> {
var queriesToUpdate = [];
if (isPresent(this.parent._query0)) {
this._pruneQueryFromTree(this.parent._query0);
ListWrapper.push(queriesToUpdate, this.parent._query0);
queriesToUpdate.push(this.parent._query0);
}
if (isPresent(this.parent._query1)) {
this._pruneQueryFromTree(this.parent._query1);
ListWrapper.push(queriesToUpdate, this.parent._query1);
queriesToUpdate.push(this.parent._query1);
}
if (isPresent(this.parent._query2)) {
this._pruneQueryFromTree(this.parent._query2);
ListWrapper.push(queriesToUpdate, this.parent._query2);
queriesToUpdate.push(this.parent._query2);
}
this.remove();
@ -1454,10 +1452,10 @@ class QueryRef {
this.list.reset(aggregator);
}
visit(inj: ElementInjector, aggregator): void {
visit(inj: ElementInjector, aggregator: any[]): void {
if (isBlank(inj) || !inj._hasQuery(this)) return;
if (inj.hasDirective(this.query.directive)) {
ListWrapper.push(aggregator, inj.get(this.query.directive));
aggregator.push(inj.get(this.query.directive));
}
var child = inj._head;
while (isPresent(child)) {

View File

@ -47,10 +47,8 @@ class BindingRecordsCreator {
for (var elementIndex = 0; elementIndex < elementBinders.length; ++elementIndex) {
var dirs = elementBinders[elementIndex].directives;
for (var dirIndex = 0; dirIndex < dirs.length; ++dirIndex) {
ListWrapper.push(
directiveRecords,
this._getDirectiveRecord(elementIndex, dirIndex,
allDirectiveMetadatas[dirs[dirIndex].directiveIndex]));
directiveRecords.push(this._getDirectiveRecord(
elementIndex, dirIndex, allDirectiveMetadatas[dirs[dirIndex].directiveIndex]));
}
}
@ -62,15 +60,15 @@ class BindingRecordsCreator {
if (isBlank(renderElementBinder.textBindings)) return;
ListWrapper.forEach(renderElementBinder.textBindings, (b) => {
ListWrapper.push(bindings, BindingRecord.createForTextNode(b, this._textNodeIndex++));
bindings.push(BindingRecord.createForTextNode(b, this._textNodeIndex++));
});
}
_createElementPropertyRecords(bindings: List<BindingRecord>, boundElementIndex: number,
renderElementBinder: renderApi.ElementBinder) {
MapWrapper.forEach(renderElementBinder.propertyBindings, (astWithSource, propertyName) => {
ListWrapper.push(
bindings, BindingRecord.createForElement(astWithSource, boundElementIndex, propertyName));
bindings.push(BindingRecord.createForElement(astWithSource, boundElementIndex, propertyName));
});
}
@ -87,18 +85,18 @@ class BindingRecordsCreator {
// TODO: these setters should eventually be created by change detection, to make
// it monomorphic!
var setter = reflector.setter(propertyName);
ListWrapper.push(bindings, BindingRecord.createForDirective(astWithSource, propertyName,
setter, directiveRecord));
bindings.push(
BindingRecord.createForDirective(astWithSource, propertyName, setter, directiveRecord));
});
if (directiveRecord.callOnChange) {
ListWrapper.push(bindings, BindingRecord.createDirectiveOnChange(directiveRecord));
bindings.push(BindingRecord.createDirectiveOnChange(directiveRecord));
}
if (directiveRecord.callOnInit) {
ListWrapper.push(bindings, BindingRecord.createDirectiveOnInit(directiveRecord));
bindings.push(BindingRecord.createDirectiveOnInit(directiveRecord));
}
if (directiveRecord.callOnCheck) {
ListWrapper.push(bindings, BindingRecord.createDirectiveOnCheck(directiveRecord));
bindings.push(BindingRecord.createDirectiveOnCheck(directiveRecord));
}
}
@ -107,8 +105,8 @@ class BindingRecordsCreator {
// host properties
MapWrapper.forEach(directiveBinder.hostPropertyBindings, (astWithSource, propertyName) => {
var dirIndex = new DirectiveIndex(boundElementIndex, i);
ListWrapper.push(
bindings, BindingRecord.createForHostProperty(dirIndex, astWithSource, propertyName));
bindings.push(BindingRecord.createForHostProperty(dirIndex, astWithSource, propertyName));
});
}
}
@ -185,8 +183,8 @@ function _collectNestedProtoViews(
if (isBlank(result)) {
result = [];
}
ListWrapper.push(result, new RenderProtoViewWithIndex(renderProtoView, result.length, parentIndex,
boundElementIndex));
result.push(
new RenderProtoViewWithIndex(renderProtoView, result.length, parentIndex, boundElementIndex));
var currentIndex = result.length - 1;
var childBoundElementIndex = 0;
ListWrapper.forEach(renderProtoView.elementBinders, (elementBinder) => {
@ -266,7 +264,6 @@ function _collectNestedProtoViewsVariableNames(
return nestedPvVariableNames;
}
function _createVariableNames(parentVariableNames, renderProtoView): List<string> {
var res = isBlank(parentVariableNames) ? [] : ListWrapper.clone(parentVariableNames);
MapWrapper.forEach(renderProtoView.variableBindings,

View File

@ -183,7 +183,7 @@ export class AppProtoView {
new ElementBinder(this.elementBinders.length, parent, distanceToParent,
protoElementInjector, directiveVariableBindings, componentDirective);
ListWrapper.push(this.elementBinders, elBinder);
this.elementBinders.push(elBinder);
return elBinder;
}

View File

@ -43,7 +43,7 @@ export class AppViewManagerUtils {
elementInjector = protoElementInjector.instantiate(parentElementInjector);
} else {
elementInjector = protoElementInjector.instantiate(null);
ListWrapper.push(rootElementInjectors, elementInjector);
rootElementInjectors.push(elementInjector);
}
}
elementInjectors[binderIdx] = elementInjector;

View File

@ -34,7 +34,7 @@ export class AppViewPool {
}
var haveRemainingCapacity = pooledViews.length < this._poolCapacityPerProtoView;
if (haveRemainingCapacity) {
ListWrapper.push(pooledViews, view);
pooledViews.push(view);
}
return haveRemainingCapacity;
}

View File

@ -17,7 +17,7 @@ export class Testability {
constructor() {
this._pendingCount = 0;
this._callbacks = ListWrapper.create();
this._callbacks = [];
}
increaseCount(delta: number = 1) {
@ -37,7 +37,7 @@ export class Testability {
}
whenStable(callback: Function) {
ListWrapper.push(this._callbacks, callback);
this._callbacks.push(callback);
if (this._pendingCount === 0) {
this._runCallbacks();

View File

@ -69,7 +69,7 @@ export class DebugElement {
if (!isPresent(shadowView)) {
// The current element is not a component.
return ListWrapper.create();
return [];
}
return this._getChildElements(shadowView, null);
@ -123,7 +123,7 @@ export class DebugElement {
}
_getChildElements(view: AppView, parentBoundElementIndex: number): List<DebugElement> {
var els = ListWrapper.create();
var els = [];
var parentElementBinder = null;
if (isPresent(parentBoundElementIndex)) {
parentElementBinder = view.proto.elementBinders[parentBoundElementIndex];
@ -131,7 +131,7 @@ export class DebugElement {
for (var i = 0; i < view.proto.elementBinders.length; ++i) {
var binder = view.proto.elementBinders[i];
if (binder.parent == parentElementBinder) {
ListWrapper.push(els, new DebugElement(view, i));
els.push(new DebugElement(view, i));
var views = view.viewContainers[i];
if (isPresent(views)) {
@ -154,8 +154,8 @@ export function inspectElement(elementRef: ElementRef): DebugElement {
*/
export class Scope {
static all(debugElement): List<DebugElement> {
var scope = ListWrapper.create();
ListWrapper.push(scope, debugElement);
var scope = [];
scope.push(debugElement);
ListWrapper.forEach(debugElement.children,
(child) => { scope = ListWrapper.concat(scope, Scope.all(child)); });
@ -166,19 +166,19 @@ export class Scope {
return scope;
}
static light(debugElement): List<DebugElement> {
var scope = ListWrapper.create();
var scope = [];
ListWrapper.forEach(debugElement.children, (child) => {
ListWrapper.push(scope, child);
scope.push(child);
scope = ListWrapper.concat(scope, Scope.light(child));
});
return scope;
}
static view(debugElement): List<DebugElement> {
var scope = ListWrapper.create();
var scope = [];
ListWrapper.forEach(debugElement.componentViewChildren, (child) => {
ListWrapper.push(scope, child);
scope.push(child);
scope = ListWrapper.concat(scope, Scope.light(child));
});
return scope;

View File

@ -501,7 +501,7 @@ function _extractToken(typeOrFunc, annotations /*List<any> | any*/,
if (isPresent(paramAnnotation.token)) {
token = paramAnnotation.token;
}
ListWrapper.push(depProps, paramAnnotation);
depProps.push(paramAnnotation);
}
}

View File

@ -5,10 +5,10 @@ function findFirstClosedCycle(keys: List<any>): List<any> {
var res = [];
for (var i = 0; i < keys.length; ++i) {
if (ListWrapper.contains(res, keys[i])) {
ListWrapper.push(res, keys[i]);
res.push(keys[i]);
return res;
} else {
ListWrapper.push(res, keys[i]);
res.push(keys[i]);
}
}
return res;
@ -45,7 +45,7 @@ export class AbstractBindingError extends BaseException {
// TODO(tbosch): Can't do key:Key as this results in a circular dependency!
addKey(key): void {
ListWrapper.push(this.keys, key);
this.keys.push(key);
this.message = this.constructResolvingMessage(this.keys);
}
@ -182,13 +182,13 @@ export class NoAnnotationError extends BaseException {
message: string;
constructor(typeOrFunc, params: List<List<any>>) {
super();
var signature = ListWrapper.create();
var signature = [];
for (var i = 0, ii = params.length; i < ii; i++) {
var parameter = params[i];
if (isBlank(parameter) || parameter.length == 0) {
ListWrapper.push(signature, '?');
signature.push('?');
} else {
ListWrapper.push(signature, ListWrapper.map(parameter, stringify).join(' '));
signature.push(ListWrapper.map(parameter, stringify).join(' '));
}
}
this.message = "Cannot resolve all parameters for " + stringify(typeOrFunc) + "(" +

View File

@ -390,8 +390,8 @@ export function resolveBindings(bindings: List<Type | Binding | List<any>>): Lis
function flattenBindings(bindings: List<ResolvedBinding>): List<ResolvedBinding> {
var map = _flattenBindings(bindings, MapWrapper.create());
var res = ListWrapper.create();
MapWrapper.forEach(map, (binding, keyId) => ListWrapper.push(res, binding));
var res = [];
MapWrapper.forEach(map, (binding, keyId) => res.push(binding));
return res;
}

View File

@ -1,7 +1,6 @@
import {Directive} from 'angular2/annotations';
import {ViewContainerRef, ViewRef, ProtoViewRef} from 'angular2/core';
import {isPresent, isBlank} from 'angular2/src/facade/lang';
import {ListWrapper} from 'angular2/src/facade/collection';
/**
* The `NgFor` directive instantiates a template once per item from an iterable. The context for
@ -54,16 +53,16 @@ export class NgFor {
// TODO(rado): check if change detection can produce a change record that is
// easier to consume than current.
var recordViewTuples = [];
changes.forEachRemovedItem((removedRecord) => ListWrapper.push(
recordViewTuples, new RecordViewTuple(removedRecord, null)));
changes.forEachRemovedItem((removedRecord) =>
recordViewTuples.push(new RecordViewTuple(removedRecord, null)));
changes.forEachMovedItem((movedRecord) => ListWrapper.push(
recordViewTuples, new RecordViewTuple(movedRecord, null)));
changes.forEachMovedItem((movedRecord) =>
recordViewTuples.push(new RecordViewTuple(movedRecord, null)));
var insertTuples = NgFor.bulkRemove(recordViewTuples, this.viewContainer);
changes.forEachAddedItem(
(addedRecord) => ListWrapper.push(insertTuples, new RecordViewTuple(addedRecord, null)));
changes.forEachAddedItem((addedRecord) =>
insertTuples.push(new RecordViewTuple(addedRecord, null)));
NgFor.bulkInsert(insertTuples, this.viewContainer, this.protoViewRef);
@ -85,7 +84,7 @@ export class NgFor {
// separate moved views from removed views.
if (isPresent(tuple.record.currentIndex)) {
tuple.view = viewContainer.detach(tuple.record.previousIndex);
ListWrapper.push(movedTuples, tuple);
movedTuples.push(tuple);
} else {
viewContainer.remove(tuple.record.previousIndex);
}

View File

@ -53,7 +53,7 @@ export class NgSwitch {
constructor() {
this._valueViews = MapWrapper.create();
this._activeViews = ListWrapper.create();
this._activeViews = [];
this._useDefault = false;
}
@ -86,7 +86,7 @@ export class NgSwitch {
this._emptyAllActiveViews();
}
view.create();
ListWrapper.push(this._activeViews, view);
this._activeViews.push(view);
}
// Switch to default when there is no more active ViewContainers
@ -101,7 +101,7 @@ export class NgSwitch {
for (var i = 0; i < activeContainers.length; i++) {
activeContainers[i].destroy();
}
this._activeViews = ListWrapper.create();
this._activeViews = [];
}
_activateViews(views: List<SwitchView>): void {
@ -117,10 +117,10 @@ export class NgSwitch {
_registerView(value, view: SwitchView): void {
var views = MapWrapper.get(this._valueViews, value);
if (isBlank(views)) {
views = ListWrapper.create();
views = [];
MapWrapper.set(this._valueViews, value, views);
}
ListWrapper.push(views, view);
views.push(view);
}
_deregisterView(value, view: SwitchView): void {

View File

@ -13,7 +13,7 @@ export class GenericBrowserDomAdapter extends DomAdapter {
cssToRules(css: string): List<any> {
var style = this.createStyleElement(css);
this.appendChild(this.defaultDoc().head, style);
var rules = ListWrapper.create();
var rules = [];
if (isPresent(style.sheet)) {
// TODO(sorvell): Firefox throws when accessing the rules of a stylesheet
// with an @import

View File

@ -33,14 +33,14 @@ export class Parse5DomAdapter extends DomAdapter {
query(selector) { throw _notImplemented('query'); }
querySelector(el, selector: string) { return this.querySelectorAll(el, selector)[0]; }
querySelectorAll(el, selector: string) {
var res = ListWrapper.create();
var res = [];
var _recursive = (result, node, selector, matcher) => {
var cNodes = node.childNodes;
if (cNodes && cNodes.length > 0) {
for (var i = 0; i < cNodes.length; i++) {
var childNode = cNodes[i];
if (this.elementMatches(childNode, selector, matcher)) {
ListWrapper.push(result, childNode);
result.push(childNode);
}
_recursive(result, childNode, selector, matcher);
}
@ -86,9 +86,9 @@ export class Parse5DomAdapter extends DomAdapter {
}
var listeners = StringMapWrapper.get(listenersMap, evt);
if (isBlank(listeners)) {
listeners = ListWrapper.create();
listeners = [];
}
ListWrapper.push(listeners, listener);
listeners.push(listener);
StringMapWrapper.set(listenersMap, evt, listeners);
}
onAndCancel(el, evt, listener): Function {
@ -287,7 +287,7 @@ export class Parse5DomAdapter extends DomAdapter {
var classList = this.classList(element);
var index = classList.indexOf(classname);
if (index == -1) {
ListWrapper.push(classList, classname);
classList.push(classname);
element.attribs["class"] = element.className = ListWrapper.join(classList, " ");
}
}
@ -417,7 +417,7 @@ export class Parse5DomAdapter extends DomAdapter {
}
}
_buildRules(parsedRules, css?) {
var rules = ListWrapper.create();
var rules = [];
for (var i = 0; i < parsedRules.length; i++) {
var parsedRule = parsedRules[i];
var rule: StringMap<string, any> = StringMapWrapper.create();
@ -448,13 +448,13 @@ export class Parse5DomAdapter extends DomAdapter {
StringMapWrapper.set(rule, "cssRules", this._buildRules(parsedRule.rules));
}
}
ListWrapper.push(rules, rule);
rules.push(rule);
}
return rules;
}
cssToRules(css: string): List<any> {
css = css.replace(/url\(\'(.+)\'\)/g, 'url($1)');
var rules = ListWrapper.create();
var rules = [];
var parsedCSS = cssParse(css, {silent: true});
if (parsedCSS.stylesheet && parsedCSS.stylesheet.rules) {
rules = this._buildRules(parsedCSS.stylesheet.rules, css);

View File

@ -101,7 +101,6 @@ class StringMapWrapper {
class ListWrapper {
static List clone(Iterable l) => new List.from(l);
static List create() => new List();
static List createFixedSize(int size) => new List(size);
static get(List m, int k) => m[k];
static void set(List m, int k, v) {
@ -126,9 +125,6 @@ class ListWrapper {
static first(List list) => list.isEmpty ? null : list.first;
static last(List list) => list.isEmpty ? null : list.last;
static List reversed(List list) => list.reversed.toList();
static void push(List l, e) {
l.add(e);
}
static List concat(List a, List b) {
return new List()
..length = a.length + b.length

View File

@ -145,7 +145,6 @@ export class StringMapWrapper {
}
export class ListWrapper {
static create(): List<any> { return new List(); }
static createFixedSize(size): List<any> { return new List(size); }
static get(m, k) { return m[k]; }
static set(m, k, v) { m[k] = v; }
@ -156,7 +155,6 @@ export class ListWrapper {
fn(array[i]);
}
}
static push(array, el) { array.push(el); }
static first(array) {
if (!array) return null;
return array[0];

View File

@ -113,7 +113,7 @@ export class NgFormModel extends ControlContainer implements Form {
var c: any = this.form.find(dir.path);
setUpControl(c, dir);
c.updateValidity();
ListWrapper.push(this.directives, dir);
this.directives.push(dir);
}
getControl(dir: NgControl): Control { return <Control>this.form.find(dir.path); }

View File

@ -10,7 +10,7 @@ import {Renderer, ElementRef} from 'angular2/angular2';
export function controlPath(name, parent: ControlContainer) {
var p = ListWrapper.clone(parent.path);
ListWrapper.push(p, name);
p.push(name);
return p;
}

View File

@ -287,7 +287,7 @@ export class ControlArray extends AbstractControl {
at(index: number): AbstractControl { return this.controls[index]; }
push(control: AbstractControl): void {
ListWrapper.push(this.controls, control);
this.controls.push(control);
control.setParent(this);
this.updateValueAndValidity();
}

View File

@ -51,12 +51,13 @@ export class Validators {
return StringMapWrapper.isEmpty(res) ? null : res;
}
static _mergeErrors(control: modelModule.AbstractControl, res: StringMap<string, any>): void {
static _mergeErrors(control: modelModule.AbstractControl, res: StringMap<string, any[]>): void {
StringMapWrapper.forEach(control.errors, (value, error) => {
if (!StringMapWrapper.contains(res, error)) {
res[error] = [];
}
ListWrapper.push(res[error], control);
var current: any[] = res[error];
current.push(control);
});
}
}

View File

@ -33,8 +33,8 @@ export class Headers {
this._headersMap = MapWrapper.createFromStringMap(headers);
MapWrapper.forEach(this._headersMap, (v, k) => {
if (!isListLikeIterable(v)) {
var list = ListWrapper.create();
ListWrapper.push(list, v);
var list = [];
list.push(v);
MapWrapper.set(this._headersMap, k, list);
}
});
@ -42,8 +42,8 @@ export class Headers {
}
append(name: string, value: string): void {
var list = MapWrapper.get(this._headersMap, name) || ListWrapper.create();
ListWrapper.push(list, value);
var list = MapWrapper.get(this._headersMap, name) || [];
list.push(value);
MapWrapper.set(this._headersMap, name, list);
}
@ -61,11 +61,11 @@ export class Headers {
// TODO: this implementation seems wrong. create list then check if it's iterable?
set(header: string, value: string | List<string>): void {
var list = ListWrapper.create();
var list = [];
if (!isListLikeIterable(value)) {
ListWrapper.push(list, value);
list.push(value);
} else {
ListWrapper.push(list, ListWrapper.toString((<List<string>>value)));
list.push(ListWrapper.toString((<List<string>>value)));
}
MapWrapper.set(this._headersMap, header, list);
@ -73,9 +73,7 @@ export class Headers {
values() { return MapWrapper.values(this._headersMap); }
getAll(header: string): Array<string> {
return MapWrapper.get(this._headersMap, header) || ListWrapper.create();
}
getAll(header: string): Array<string> { return MapWrapper.get(this._headersMap, header) || []; }
entries() { throw new BaseException('"entries" method is not implemented on Headers class'); }
}

View File

@ -8,8 +8,8 @@ function paramParser(rawParams: string): Map<string, List<string>> {
var split: List<string> = StringWrapper.split(param, '=');
var key = ListWrapper.get(split, 0);
var val = ListWrapper.get(split, 1);
var list = MapWrapper.get(map, key) || ListWrapper.create();
ListWrapper.push(list, val);
var list = MapWrapper.get(map, key) || [];
list.push(val);
MapWrapper.set(map, key, list);
});
return map;
@ -23,20 +23,18 @@ export class URLSearchParams {
get(param: string): string { return ListWrapper.first(MapWrapper.get(this.paramsMap, param)); }
getAll(param: string): List<string> {
return MapWrapper.get(this.paramsMap, param) || ListWrapper.create();
}
getAll(param: string): List<string> { return MapWrapper.get(this.paramsMap, param) || []; }
append(param: string, val: string): void {
var list = MapWrapper.get(this.paramsMap, param) || ListWrapper.create();
ListWrapper.push(list, val);
var list = MapWrapper.get(this.paramsMap, param) || [];
list.push(val);
MapWrapper.set(this.paramsMap, param, list);
}
toString(): string {
var paramsList = ListWrapper.create();
var paramsList = [];
MapWrapper.forEach(this.paramsMap, (values, k) => {
ListWrapper.forEach(values, v => { ListWrapper.push(paramsList, k + '=' + v); });
ListWrapper.forEach(values, v => { paramsList.push(k + '=' + v); });
});
return ListWrapper.join(paramsList, '&');
}

View File

@ -10,7 +10,7 @@ export class DummyBrowserLocation extends SpyObject {
internalBaseHref: string = '/';
internalPath: string = '/';
internalTitle: string = '';
urlChanges: List<string> = ListWrapper.create();
urlChanges: List<string> = [];
_subject: EventEmitter = new EventEmitter();
constructor() { super(); }
@ -28,7 +28,7 @@ export class DummyBrowserLocation extends SpyObject {
pushState(ctx: any, title: string, url: string): void {
this.internalTitle = title;
this.internalPath = url;
ListWrapper.push(this.urlChanges, url);
this.urlChanges.push(url);
}
forward(): void { throw new BaseException('Not implemented yet!'); }

View File

@ -17,7 +17,7 @@ export class SpyLocation extends SpyObject {
constructor() {
super();
this._path = '/';
this.urlChanges = ListWrapper.create();
this.urlChanges = [];
this._subject = new EventEmitter();
this._baseHref = '';
}
@ -38,7 +38,7 @@ export class SpyLocation extends SpyObject {
return;
}
this._path = url;
ListWrapper.push(this.urlChanges, url);
this.urlChanges.push(url);
}
forward() {

View File

@ -10,14 +10,14 @@ import {CompileStep} from './compile_step';
export class CompileControl {
_currentStepIndex: number = 0;
_parent: CompileElement = null;
_results = null;
_additionalChildren = null;
_results: any[] = null;
_additionalChildren: any[] = null;
_ignoreCurrentElement: boolean;
constructor(public _steps: List<CompileStep>) {}
// only public so that it can be used by compile_pipeline
internalProcess(results, startStepIndex, parent: CompileElement, current: CompileElement) {
internalProcess(results: any[], startStepIndex, parent: CompileElement, current: CompileElement) {
this._results = results;
var previousStepIndex = this._currentStepIndex;
var previousParent = this._parent;
@ -33,7 +33,7 @@ export class CompileControl {
}
if (!this._ignoreCurrentElement) {
ListWrapper.push(results, current);
results.push(current);
}
this._currentStepIndex = previousStepIndex;
@ -51,9 +51,9 @@ export class CompileControl {
addChild(element: CompileElement) {
if (isBlank(this._additionalChildren)) {
this._additionalChildren = ListWrapper.create();
this._additionalChildren = [];
}
ListWrapper.push(this._additionalChildren, element);
this._additionalChildren.push(element);
}
/**

View File

@ -63,10 +63,10 @@ export class CompileElement {
classList(): List<string> {
if (isBlank(this._classList)) {
this._classList = ListWrapper.create();
this._classList = [];
var elClassList = DOM.classList(this.element);
for (var i = 0; i < elClassList.length; i++) {
ListWrapper.push(this._classList, elClassList[i]);
this._classList.push(elClassList[i]);
}
}
return this._classList;

View File

@ -20,7 +20,7 @@ export class CompilePipeline {
if (isBlank(protoViewType)) {
protoViewType = ViewType.COMPONENT;
}
var results = ListWrapper.create();
var results = [];
var rootCompileElement = new CompileElement(rootElement, compilationCtxtDescription);
rootCompileElement.inheritedProtoView = new ProtoViewBuilder(rootElement, protoViewType);
rootCompileElement.isViewRoot = true;

View File

@ -74,7 +74,7 @@ export class DirectiveParser implements CompileStep {
componentDirective = directive;
elementBinder.setComponentId(directive.id);
} else {
ListWrapper.push(foundDirectiveIndices, directiveIndex);
foundDirectiveIndices.push(directiveIndex);
}
});
ListWrapper.forEach(foundDirectiveIndices, (directiveIndex) => {

View File

@ -32,13 +32,13 @@ export class CssSelector {
notSelectors: List<CssSelector> = [];
static parse(selector: string): List<CssSelector> {
var results = ListWrapper.create();
var _addResult = (res, cssSel) => {
var results: CssSelector[] = [];
var _addResult = (res: CssSelector[], cssSel) => {
if (cssSel.notSelectors.length > 0 && isBlank(cssSel.element) &&
ListWrapper.isEmpty(cssSel.classNames) && ListWrapper.isEmpty(cssSel.attrs)) {
cssSel.element = "*";
}
ListWrapper.push(res, cssSel);
res.push(cssSel);
};
var cssSelector = new CssSelector();
var matcher = RegExpWrapper.matcher(_SELECTOR_REGEXP, selector);
@ -52,7 +52,7 @@ export class CssSelector {
}
inNot = true;
current = new CssSelector();
ListWrapper.push(cssSelector.notSelectors, current);
cssSelector.notSelectors.push(current);
}
if (isPresent(match[2])) {
current.setElement(match[2]);
@ -92,16 +92,16 @@ export class CssSelector {
}
addAttribute(name: string, value: string = _EMPTY_ATTR_VALUE) {
ListWrapper.push(this.attrs, name.toLowerCase());
this.attrs.push(name.toLowerCase());
if (isPresent(value)) {
value = value.toLowerCase();
} else {
value = _EMPTY_ATTR_VALUE;
}
ListWrapper.push(this.attrs, value);
this.attrs.push(value);
}
addClassName(name: string) { ListWrapper.push(this.classNames, name.toLowerCase()); }
addClassName(name: string) { this.classNames.push(name.toLowerCase()); }
toString(): string {
var res = '';
@ -141,11 +141,11 @@ export class SelectorMatcher {
return notMatcher;
}
private _elementMap: Map<string, List<string>> = MapWrapper.create();
private _elementMap: Map<string, List<SelectorContext>> = MapWrapper.create();
private _elementPartialMap: Map<string, SelectorMatcher> = MapWrapper.create();
private _classMap: Map<string, List<string>> = MapWrapper.create();
private _classMap: Map<string, List<SelectorContext>> = MapWrapper.create();
private _classPartialMap: Map<string, SelectorMatcher> = MapWrapper.create();
private _attrValueMap: Map<string, Map<string, List<string>>> = MapWrapper.create();
private _attrValueMap: Map<string, Map<string, List<SelectorContext>>> = MapWrapper.create();
private _attrValuePartialMap: Map<string, Map<string, SelectorMatcher>> = MapWrapper.create();
private _listContexts: List<SelectorListContext> = [];
@ -153,7 +153,7 @@ export class SelectorMatcher {
var listContext = null;
if (cssSelectors.length > 1) {
listContext = new SelectorListContext(cssSelectors);
ListWrapper.push(this._listContexts, listContext);
this._listContexts.push(listContext);
}
for (var i = 0; i < cssSelectors.length; i++) {
this._addSelectable(cssSelectors[i], callbackCtxt, listContext);
@ -220,13 +220,14 @@ export class SelectorMatcher {
}
}
private _addTerminal(map: Map<string, List<string>>, name: string, selectable: SelectorContext) {
private _addTerminal(map: Map<string, List<SelectorContext>>, name: string,
selectable: SelectorContext) {
var terminalList = MapWrapper.get(map, name);
if (isBlank(terminalList)) {
terminalList = ListWrapper.create();
terminalList = [];
MapWrapper.set(map, name, terminalList);
}
ListWrapper.push(terminalList, selectable);
terminalList.push(selectable);
}
private _addPartial(map: Map<string, SelectorMatcher>, name: string): SelectorMatcher {
@ -297,8 +298,8 @@ export class SelectorMatcher {
return result;
}
_matchTerminal(map: Map<string, List<string>>, name, cssSelector: CssSelector,
matchedCallback /*: (CssSelector, any) => void*/): boolean {
_matchTerminal(map: Map<string, List<SelectorContext>>, name, cssSelector: CssSelector,
matchedCallback: (CssSelector, any) => void): boolean {
if (isBlank(map) || isBlank(name)) {
return false;
}

View File

@ -151,7 +151,7 @@ export class DomRenderer extends Renderer {
}
// add global events
view.eventHandlerRemovers = ListWrapper.create();
view.eventHandlerRemovers = [];
var binders = view.proto.elementBinders;
for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) {
var binder = binders[binderIdx];
@ -160,7 +160,7 @@ export class DomRenderer extends Renderer {
var globalEvent = binder.globalEvents[i];
var remover = this._createGlobalEventListener(view, binderIdx, globalEvent.name,
globalEvent.target, globalEvent.fullName);
ListWrapper.push(view.eventHandlerRemovers, remover);
view.eventHandlerRemovers.push(remover);
}
}
}

View File

@ -55,7 +55,7 @@ export class LightDom {
for (var i = 0; i < els.length; i++) {
var el = els[i];
if (isPresent(el.contentTag)) {
ListWrapper.push(acc, el.contentTag);
acc.push(el.contentTag);
}
if (isPresent(el.viewContainer)) {
ListWrapper.forEach(el.viewContainer.contentTagContainers(),
@ -83,10 +83,10 @@ export class LightDom {
} else if (isPresent(content)) {
res = ListWrapper.concat(res, content.nodes());
} else {
ListWrapper.push(res, root.node);
res.push(root.node);
}
} else {
ListWrapper.push(res, root.node);
res.push(root.node);
}
}
return res;

View File

@ -303,7 +303,7 @@ export class ShadowCss {
var p = parts[i];
if (isBlank(p)) break;
p = p.trim();
ListWrapper.push(r, partReplacer(_polyfillHostNoCombinator, p, m[3]));
r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
}
return r.join(',');
} else {
@ -392,7 +392,7 @@ export class ShadowCss {
this._applyStrictSelectorScope(p, scopeSelector) :
this._applySelectorScope(p, scopeSelector, hostSelector);
}
ListWrapper.push(r, p);
r.push(p);
}
return r.join(', ');
}

View File

@ -31,7 +31,7 @@ export class ShadowDomCompileStep implements CompileStep {
var stylePromise = this._shadowDomStrategy.processStyleElement(
this._template.componentId, this._template.templateAbsUrl, current.element);
if (isPresent(stylePromise) && isPromise(stylePromise)) {
ListWrapper.push(this._subTaskPromises, stylePromise);
this._subTaskPromises.push(stylePromise);
}
// Style elements should not be further processed by the compiler, as they can not contain

View File

@ -73,7 +73,7 @@ export class StyleInliner {
// Importing again might cause a circular dependency
promise = PromiseWrapper.resolve(prefix);
} else {
ListWrapper.push(inlinedUrls, url);
inlinedUrls.push(url);
promise = PromiseWrapper.then(this._xhr.get(url), (rawCss) => {
// resolve nested @import rules
var inlinedCss = this._inlineImports(rawCss, url, inlinedUrls);
@ -88,7 +88,7 @@ export class StyleInliner {
}
}, (error) => `/* failed to import ${url} */\n`);
}
ListWrapper.push(promises, promise);
promises.push(promise);
partIndex += 2;
}

View File

@ -27,7 +27,7 @@ export class ProtoViewBuilder {
bindElement(element, description = null): ElementBinderBuilder {
var builder = new ElementBinderBuilder(this.elements.length, element, description);
ListWrapper.push(this.elements, builder);
this.elements.push(builder);
DOM.addClass(element, NG_BINDING_CLASS);
return builder;
@ -90,7 +90,7 @@ export class ProtoViewBuilder {
transitiveContentTagCount++;
}
var parentIndex = isPresent(ebb.parent) ? ebb.parent.index : -1;
ListWrapper.push(apiElementBinders, new api.ElementBinder({
apiElementBinders.push(new api.ElementBinder({
index: ebb.index,
parentIndex: parentIndex,
distanceToParent: ebb.distanceToParent,
@ -103,22 +103,21 @@ export class ProtoViewBuilder {
readAttributes: ebb.readAttributes
}));
var elementIsEmpty = this._isEmptyElement(ebb.element);
ListWrapper.push(renderElementBinders, new ElementBinder({
textNodeIndices: ebb.textBindingIndices,
contentTagSelector: ebb.contentTagSelector,
parentIndex: parentIndex,
distanceToParent: ebb.distanceToParent,
nestedProtoView: isPresent(nestedProtoView) ?
resolveInternalDomProtoView(nestedProtoView.render) :
null,
componentId: ebb.componentId,
eventLocals: new LiteralArray(ebb.eventBuilder.buildEventLocals()),
localEvents: ebb.eventBuilder.buildLocalEvents(),
globalEvents: ebb.eventBuilder.buildGlobalEvents(),
hostActions: hostActions,
propertySetters: propertySetters,
elementIsEmpty: elementIsEmpty
}));
renderElementBinders.push(new ElementBinder({
textNodeIndices: ebb.textBindingIndices,
contentTagSelector: ebb.contentTagSelector,
parentIndex: parentIndex,
distanceToParent: ebb.distanceToParent,
nestedProtoView:
isPresent(nestedProtoView) ? resolveInternalDomProtoView(nestedProtoView.render) : null,
componentId: ebb.componentId,
eventLocals: new LiteralArray(ebb.eventBuilder.buildEventLocals()),
localEvents: ebb.eventBuilder.buildLocalEvents(),
globalEvents: ebb.eventBuilder.buildGlobalEvents(),
hostActions: hostActions,
propertySetters: propertySetters,
elementIsEmpty: elementIsEmpty
}));
});
return new api.ProtoViewDto({
render: new DomProtoViewRef(new DomProtoView({
@ -178,7 +177,7 @@ export class ElementBinderBuilder {
bindDirective(directiveIndex: number): DirectiveBuilder {
var directive = new DirectiveBuilder(directiveIndex);
ListWrapper.push(this.directives, directive);
this.directives.push(directive);
return directive;
}
@ -211,12 +210,12 @@ export class ElementBinderBuilder {
}
bindEvent(name, expression, target = null) {
ListWrapper.push(this.eventBindings, this.eventBuilder.add(name, expression, target));
this.eventBindings.push(this.eventBuilder.add(name, expression, target));
}
bindText(index, expression) {
ListWrapper.push(this.textBindingIndices, index);
ListWrapper.push(this.textBindings, expression);
this.textBindingIndices.push(index);
this.textBindings.push(expression);
}
setContentTagSelector(value: string) { this.contentTagSelector = value; }
@ -240,11 +239,11 @@ export class DirectiveBuilder {
}
bindHostAction(actionName: string, actionExpression: string, expression: ASTWithSource) {
ListWrapper.push(this.hostActions, new HostAction(actionName, actionExpression, expression));
this.hostActions.push(new HostAction(actionName, actionExpression, expression));
}
bindEvent(name, expression, target = null) {
ListWrapper.push(this.eventBindings, this.eventBuilder.add(name, expression, target));
this.eventBindings.push(this.eventBuilder.add(name, expression, target));
}
}
@ -266,9 +265,9 @@ export class EventBuilder extends AstTransformer {
fullName, new ASTWithSource(adjustedAst, source.source, source.location));
var event = new Event(name, target, fullName);
if (isBlank(target)) {
ListWrapper.push(this.localEvents, event);
this.localEvents.push(event);
} else {
ListWrapper.push(this.globalEvents, event);
this.globalEvents.push(event);
}
return result;
}
@ -285,7 +284,7 @@ export class EventBuilder extends AstTransformer {
}
if (isEventAccess) {
ListWrapper.push(this.locals, ast);
this.locals.push(ast);
var index = this.locals.length - 1;
return new AccessMember(this._implicitReceiver, `${index}`, (arr) => arr[index], null);
} else {
@ -306,13 +305,13 @@ export class EventBuilder extends AstTransformer {
}
_merge(host: List<Event>, tobeAdded: List<Event>) {
var names = ListWrapper.create();
var names = [];
for (var i = 0; i < host.length; i++) {
ListWrapper.push(names, host[i].fullName);
names.push(host[i].fullName);
}
for (var j = 0; j < tobeAdded.length; j++) {
if (!ListWrapper.contains(names, tobeAdded[j].fullName)) {
ListWrapper.push(host, tobeAdded[j]);
host.push(tobeAdded[j]);
}
}
}

View File

@ -6,7 +6,7 @@ import {PromiseWrapper, Promise} from 'angular2/src/facade/async';
export class MockXHR extends XHR {
private _expectations: List<_Expectation>;
private _definitions: Map<string, string>;
private _requests: List<Promise<string>>;
private _requests: List<_PendingRequest>;
constructor() {
super();
@ -17,13 +17,13 @@ export class MockXHR extends XHR {
get(url: string): Promise<string> {
var request = new _PendingRequest(url);
ListWrapper.push(this._requests, request);
this._requests.push(request);
return request.getPromise();
}
expect(url: string, response: string) {
var expectation = new _Expectation(url, response);
ListWrapper.push(this._expectations, expectation);
this._expectations.push(expectation);
}
when(url: string, response: string) { MapWrapper.set(this._definitions, url, response); }
@ -47,7 +47,7 @@ export class MockXHR extends XHR {
var urls = [];
for (var i = 0; i < this._expectations.length; i++) {
var expectation = this._expectations[i];
ListWrapper.push(urls, expectation.url);
urls.push(expectation.url);
}
throw new BaseException(`Unsatisfied requests: ${ListWrapper.join(urls, ', ')}`);

View File

@ -76,7 +76,7 @@ function parsePathString(route: string) {
}
var segments = splitBySlash(route);
var results = ListWrapper.create();
var results = [];
var specificity = 0;
// The "specificity" of a path is used to determine which route is used when multiple routes match
@ -97,12 +97,12 @@ function parsePathString(route: string) {
var segment = segments[i], match;
if (isPresent(match = RegExpWrapper.firstMatch(paramMatcher, segment))) {
ListWrapper.push(results, new DynamicSegment(match[1]));
results.push(new DynamicSegment(match[1]));
specificity += (100 - i);
} else if (isPresent(match = RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
ListWrapper.push(results, new StarSegment(match[1]));
results.push(new StarSegment(match[1]));
} else if (segment.length > 0) {
ListWrapper.push(results, new StaticSegment(segment));
results.push(new StaticSegment(segment));
specificity += 100 * (100 - i);
}
}

View File

@ -54,7 +54,7 @@ export class RouteRecognizer {
*
*/
recognize(url: string): List<RouteMatch> {
var solutions = ListWrapper.create();
var solutions = [];
MapWrapper.forEach(this.redirects, (target, path) => {
// "/" redirect case
@ -77,13 +77,13 @@ export class RouteRecognizer {
matchedUrl = match[0];
unmatchedUrl = StringWrapper.substring(url, match[0].length);
}
ListWrapper.push(solutions, new RouteMatch({
specificity: pathRecognizer.specificity,
handler: pathRecognizer.handler,
params: pathRecognizer.parseParams(url),
matchedUrl: matchedUrl,
unmatchedUrl: unmatchedUrl
}));
solutions.push(new RouteMatch({
specificity: pathRecognizer.specificity,
handler: pathRecognizer.handler,
params: pathRecognizer.parseParams(url),
matchedUrl: matchedUrl,
unmatchedUrl: unmatchedUrl
}));
}
});

View File

@ -1,4 +1,4 @@
/// <reference path="../../typings/jasmine/jasmine"/>
/// <reference path="../../typings/jasmine/jasmine.d.ts"/>
import {BaseException, global} from 'angular2/src/facade/lang';
import {ListWrapper} from 'angular2/src/facade/collection';
@ -95,7 +95,7 @@ export function flushMicrotasks(): void {
function _setTimeout(fn: Function, delay: number, ... args): number {
var cb = _fnAndFlush(fn);
var id = _scheduler.scheduleFunction(cb, delay, args);
ListWrapper.push(_pendingTimers, id);
_pendingTimers.push(id);
_scheduler.scheduleFunction(_dequeueTimer(id), delay);
return id;
}
@ -124,7 +124,7 @@ function _fnAndFlush(fn: Function): Function {
}
function _scheduleMicrotask(microtask: Function): void {
ListWrapper.push(_microtasks, microtask);
_microtasks.push(microtask);
}
function _dequeueTimer(id: number): Function {

View File

@ -8,12 +8,10 @@ export class Log {
constructor() { this._result = []; }
add(value): void { ListWrapper.push(this._result, value); }
add(value): void { this._result.push(value); }
fn(value) {
return (a1 = null, a2 = null, a3 = null, a4 = null, a5 = null) => {
ListWrapper.push(this._result, value);
}
return (a1 = null, a2 = null, a3 = null, a4 = null, a5 = null) => { this._result.push(value); }
}
result(): string { return ListWrapper.join(this._result, "; "); }
@ -72,8 +70,8 @@ export function stringifyElement(el): string {
// Attributes in an ordered way
var attributeMap = DOM.attributeMap(el);
var keys = ListWrapper.create();
MapWrapper.forEach(attributeMap, (v, k) => { ListWrapper.push(keys, k); });
var keys = [];
MapWrapper.forEach(attributeMap, (v, k) => { keys.push(k); });
ListWrapper.sort(keys);
for (let i = 0; i < keys.length; i++) {
var key = keys[i];

View File

@ -35,7 +35,7 @@ function _convertLocalsToVariableBindings(locals: Locals): List<any> {
var variableBindings = [];
var loc = locals;
while (isPresent(loc) && isPresent(loc.current)) {
MapWrapper.forEach(loc.current, (v, k) => ListWrapper.push(variableBindings, k));
MapWrapper.forEach(loc.current, (v, k) => variableBindings.push(k));
loc = loc.parent;
}
return variableBindings;

View File

@ -455,9 +455,9 @@ export function main() {
var onChangesDoneCalls = [];
var td1;
td1 = new TestDirective(() => ListWrapper.push(onChangesDoneCalls, td1));
td1 = new TestDirective(() => onChangesDoneCalls.push(td1));
var td2;
td2 = new TestDirective(() => ListWrapper.push(onChangesDoneCalls, td2));
td2 = new TestDirective(() => onChangesDoneCalls.push(td2));
cd.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([td1, td2], []));
cd.detectChanges();
@ -473,11 +473,11 @@ export function main() {
var orderOfOperations = [];
var directiveInShadowDom = null;
directiveInShadowDom = new TestDirective(
() => { ListWrapper.push(orderOfOperations, directiveInShadowDom); });
directiveInShadowDom =
new TestDirective(() => { orderOfOperations.push(directiveInShadowDom); });
var parentDirective = null;
parentDirective = new TestDirective(
() => { ListWrapper.push(orderOfOperations, parentDirective); });
parentDirective =
new TestDirective(() => { orderOfOperations.push(parentDirective); });
parent.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([parentDirective], []));
child.hydrate(_DEFAULT_CONTEXT, null, new FakeDirectives([directiveInShadowDom], []));
@ -989,14 +989,14 @@ class TestDispatcher extends ChangeDispatcher {
}
clear() {
this.log = ListWrapper.create();
this.loggedValues = ListWrapper.create();
this.log = [];
this.loggedValues = [];
this.onAllChangesDoneCalled = true;
}
notifyOnBinding(binding, value) {
ListWrapper.push(this.log, `${binding.propertyName}=${this._asString(value)}`);
ListWrapper.push(this.loggedValues, value);
this.log.push(`${binding.propertyName}=${this._asString(value)}`);
this.loggedValues.push(value);
}
notifyOnAllChangesDone() { this.onAllChangesDoneCalled = true; }

View File

@ -63,7 +63,7 @@ export function main() {
var c = isBlank(passedInContext) ? td() : passedInContext;
var res = [];
for (var i = 0; i < asts.length; i++) {
ListWrapper.push(res, asts[i].eval(c, emptyLocals()));
res.push(asts[i].eval(c, emptyLocals()));
}
return res;
}

View File

@ -14,7 +14,6 @@ import {
IS_DARTIUM
} from 'angular2/test_lib';
import {Json, RegExp, NumberWrapper, StringWrapper} from 'angular2/src/facade/lang';
import {ListWrapper} from 'angular2/src/facade/collection';
import {JsonPipe} from 'angular2/src/change_detection/pipes/json_pipe';
@ -26,7 +25,7 @@ export function main() {
var inceptionObjString;
var catString;
var pipe;
var collection;
var collection: number[];
function normalize(obj: string): string { return StringWrapper.replace(obj, regNewLine, ''); }
@ -87,7 +86,7 @@ export function main() {
expect(pipe.transform(collection)).toEqual(stringCollection);
ListWrapper.push(collection, 1);
collection.push(1);
expect(pipe.transform(collection)).toEqual(stringCollectionWith1);
});

View File

@ -41,7 +41,8 @@ import {RenderCompiler} from 'angular2/src/render/api';
export function main() {
describe('compiler', function() {
var directiveResolver, tplResolver, renderCompiler, protoViewFactory, cmpUrlMapper,
renderCompileRequests, rootProtoView;
rootProtoView;
var renderCompileRequests: any[];
beforeEach(() => {
directiveResolver = new DirectiveResolver();
@ -61,7 +62,7 @@ export function main() {
var urlResolver = new FakeUrlResolver();
renderCompileRequests = [];
renderCompiler.spy('compile').andCallFake((template) => {
ListWrapper.push(renderCompileRequests, template);
renderCompileRequests.push(template);
return PromiseWrapper.resolve(ListWrapper.removeAt(renderCompileResults, 0));
});
@ -607,7 +608,7 @@ class FakeProtoViewFactory extends ProtoViewFactory {
createAppProtoViews(componentBinding: DirectiveBinding, renderProtoView: renderApi.ProtoViewDto,
directives: List<DirectiveBinding>): List<AppProtoView> {
ListWrapper.push(this.requests, [componentBinding, renderProtoView, directives]);
this.requests.push([componentBinding, renderProtoView, directives]);
return ListWrapper.removeAt(this.results, 0);
}
}

View File

@ -226,7 +226,7 @@ export function main() {
var dynamicBindings = [];
for (var i = 0; i < 20; i++) {
ListWrapper.push(dynamicBindings, bind(i).toValue(i));
dynamicBindings.push(bind(i).toValue(i));
}
function createPei(parent, index, bindings, distance = 1, hasShadowRoot = false) {
@ -1090,6 +1090,6 @@ class FakeRenderer extends Renderer {
this.log = [];
}
setElementProperty(viewRef, elementIndex, propertyName, value) {
ListWrapper.push(this.log, [viewRef, elementIndex, propertyName, value]);
this.log.push([viewRef, elementIndex, propertyName, value]);
}
}

View File

@ -42,8 +42,8 @@ export function main() {
var viewPool;
var manager;
var directiveResolver;
var createdViews;
var createdRenderViews;
var createdViews: any[];
var createdRenderViews: any[];
function wrapPv(protoView: AppProtoView): ProtoViewRef { return new ProtoViewRef(protoView); }
@ -124,7 +124,7 @@ export function main() {
utils.spy('createView')
.andCallFake((proto, renderViewRef, _a, _b) => {
var view = createView(proto, renderViewRef);
ListWrapper.push(createdViews, view);
createdViews.push(view);
return view;
});
utils.spy('attachComponentView')
@ -143,13 +143,13 @@ export function main() {
renderer.spy('createRootHostView')
.andCallFake((_b, _c) => {
var rv = new RenderViewRef();
ListWrapper.push(createdRenderViews, rv);
createdRenderViews.push(rv);
return rv;
});
renderer.spy('createView')
.andCallFake((_a) => {
var rv = new RenderViewRef();
ListWrapper.push(createdRenderViews, rv);
createdRenderViews.push(rv);
return rv;
});
viewPool.spy('returnView').andReturn(true);

View File

@ -74,13 +74,13 @@ class LifecycleDir {
constructor() { this.log = []; }
onChange(_) { ListWrapper.push(this.log, "onChange"); }
onChange(_) { this.log.push("onChange"); }
onInit() { ListWrapper.push(this.log, "onInit"); }
onInit() { this.log.push("onInit"); }
onCheck() { ListWrapper.push(this.log, "onCheck"); }
onCheck() { this.log.push("onCheck"); }
onAllChangesDone() { ListWrapper.push(this.log, "onAllChangesDone"); }
onAllChangesDone() { this.log.push("onAllChangesDone"); }
}
@Component({selector: 'my-comp'})

View File

@ -14,7 +14,6 @@ import {
} from 'angular2/test_lib';
import {PromiseWrapper, TimerWrapper} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection';
import {BaseException} from 'angular2/src/facade/lang';
import {DOM} from 'angular2/src/dom/dom_adapter';
@ -33,13 +32,13 @@ function microTask(fn: Function): void {
}
var _log;
var _errors;
var _traces;
var _errors: any[];
var _traces: any[];
var _zone;
function logError(error, stackTrace) {
ListWrapper.push(_errors, error);
ListWrapper.push(_traces, stackTrace);
_errors.push(error);
_traces.push(stackTrace);
}
export function main() {
@ -205,7 +204,8 @@ function commonTests() {
_zone.initCallbacks({
onTurnDone: () => {
_log.add('onTurnDone:started');
_zone.run(() => _log.add('nested run')) _log.add('onTurnDone:finished');
_zone.run(() => _log.add('nested run'));
_log.add('onTurnDone:finished');
}
});

View File

@ -36,9 +36,9 @@ import {NgFor} from 'angular2/src/directives/ng_for';
class Logger {
log: List<string>;
constructor() { this.log = ListWrapper.create(); }
constructor() { this.log = []; }
add(thing: string) { ListWrapper.push(this.log, thing); }
add(thing: string) { this.log.push(thing); }
}
@Directive({selector: '[message]', properties: ['message']})

View File

@ -43,7 +43,7 @@ export function main() {
.then((view) => {
view.detectChanges();
ListWrapper.push(view.context.items, 3);
(<number[]>view.context.items).push(3);
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('1;2;3;');
@ -72,7 +72,7 @@ export function main() {
view.detectChanges();
ListWrapper.removeAt(view.context.items, 0);
ListWrapper.push(view.context.items, 1);
(<number[]>view.context.items).push(1);
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('2;1;');
@ -108,7 +108,7 @@ export function main() {
expect(DOM.getText(view.rootNodes[0])).toEqual('misko;shyam;');
// GROW
ListWrapper.push(view.context.items, {'name': 'adam'});
(<any[]>view.context.items).push({'name': 'adam'});
view.detectChanges();
expect(DOM.getText(view.rootNodes[0])).toEqual('misko;shyam;adam;');

View File

@ -1,6 +1,4 @@
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/test_lib';
import {ListWrapper} from 'angular2/src/facade/collection';
import {
isPresent,
RegExpWrapper,
@ -18,7 +16,7 @@ export function main() {
var m;
while (isPresent(m = RegExpMatcherWrapper.next(matcher))) {
ListWrapper.push(indexes, m.index);
indexes.push(m.index);
expect(m[0]).toEqual('!');
expect(m[1]).toEqual('!');
expect(m.length).toBe(2);

View File

@ -15,7 +15,6 @@ import {
} from 'angular2/test_lib';
import {ControlGroup, Control, ControlArray, Validators} from 'angular2/forms';
import {ObservableWrapper} from 'angular2/src/facade/async';
import {ListWrapper} from 'angular2/src/facade/collection';
export function main() {
describe("Form Model", () => {
@ -312,7 +311,7 @@ export function main() {
var loggedValues = [];
ObservableWrapper.subscribe(g.valueChanges, (value) => {
ListWrapper.push(loggedValues, value);
loggedValues.push(value);
if (loggedValues.length == 2) {
expect(loggedValues)

View File

@ -30,7 +30,7 @@ import {resolveInternalDomProtoView} from 'angular2/src/render/dom/view/proto_vi
export function runCompilerCommonTests() {
describe('DomCompiler', function() {
var mockStepFactory;
var mockStepFactory: MockStepFactory;
function createCompiler(processClosure, urlData = null) {
if (isBlank(urlData)) {
@ -117,8 +117,8 @@ export function runCompilerCommonTests() {
var completer = PromiseWrapper.completer();
var compiler = createCompiler((parent, current, control) => {
ListWrapper.push(mockStepFactory.subTaskPromises,
completer.promise.then((_) => { subTasksCompleted = true; }));
mockStepFactory.subTaskPromises.push(
completer.promise.then((_) => { subTasksCompleted = true; }));
});
// It should always return a Promise because the subtask is async
@ -177,7 +177,7 @@ class MockStepFactory extends CompileStepFactory {
createSteps(viewDef, subTaskPromises) {
this.viewDef = viewDef;
this.subTaskPromises = subTaskPromises;
ListWrapper.forEach(this.subTaskPromises, (p) => ListWrapper.push(subTaskPromises, p));
ListWrapper.forEach(this.subTaskPromises, (p) => this.subTaskPromises.push(p));
return this.steps;
}
}

View File

@ -213,15 +213,15 @@ class IgnoreCurrentElementStep implements CompileStep {
}
}
function logEntry(log, parent, current) {
function logEntry(log: string[], parent, current) {
var parentId = '';
if (isPresent(parent)) {
parentId = DOM.getAttribute(parent.element, 'id') + '<';
}
ListWrapper.push(log, parentId + DOM.getAttribute(current.element, 'id'));
log.push(parentId + DOM.getAttribute(current.element, 'id'));
}
function createLoggerStep(log) {
function createLoggerStep(log: string[]) {
return new MockStep((parent, current, control) => { logEntry(log, parent, current); });
}

View File

@ -6,16 +6,17 @@ import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection';
export function main() {
describe('SelectorMatcher', () => {
var matcher, matched, selectableCollector, s1, s2, s3, s4;
var matcher, selectableCollector, s1, s2, s3, s4;
var matched: any[];
function reset() { matched = ListWrapper.create(); }
function reset() { matched = []; }
beforeEach(() => {
reset();
s1 = s2 = s3 = s4 = null;
selectableCollector = (selector, context) => {
ListWrapper.push(matched, selector);
ListWrapper.push(matched, context);
matched.push(selector);
matched.push(context);
};
matcher = new SelectorMatcher();
});

View File

@ -35,7 +35,7 @@ class LoggingEventDispatcher implements EventDispatcher {
constructor(log: List<List<any>>) { this.log = log; }
dispatchEvent(elementIndex: number, eventName: string, locals: Map<string, any>) {
ListWrapper.push(this.log, [elementIndex, eventName, locals]);
this.log.push([elementIndex, eventName, locals]);
return true;
}
}
@ -93,10 +93,10 @@ export class DomTestbed {
createRootViews(protoViews: List<ProtoViewDto>): List<TestView> {
var views = [];
var lastView = this.createRootView(protoViews[0]);
ListWrapper.push(views, lastView);
views.push(lastView);
for (var i = 1; i < protoViews.length; i++) {
lastView = this.createComponentView(lastView.viewRef, 0, protoViews[i]);
ListWrapper.push(views, lastView);
views.push(lastView);
}
return views;
}

View File

@ -31,7 +31,7 @@ class FakeProtoView extends SpyObject {
@proxy
@IMPLEMENTS(DomView)
class FakeView extends SpyObject {
boundElements;
boundElements: any[];
proto;
constructor(containers = null, transitiveContentTagCount: number = 1) {
@ -53,7 +53,7 @@ class FakeView extends SpyObject {
}
var boundElement = new DomElement(null, element, contentTag);
boundElement.viewContainer = vc;
ListWrapper.push(this.boundElements, boundElement);
this.boundElements.push(boundElement);
});
}
}

View File

@ -16,7 +16,6 @@ import {
proxy
} from 'angular2/test_lib';
import {isBlank} from 'angular2/src/facade/lang';
import {ListWrapper} from 'angular2/src/facade/collection';
import {DomProtoView} from 'angular2/src/render/dom/view/proto_view';
import {ElementBinder} from 'angular2/src/render/dom/view/element_binder';
@ -42,8 +41,7 @@ export function main() {
var root = el('<div><div></div></div>');
var boundElements = [];
for (var i = 0; i < boundElementCount; i++) {
ListWrapper.push(boundElements,
new DomElement(pv.elementBinders[i], el('<span></span'), null));
boundElements.push(new DomElement(pv.elementBinders[i], el('<span></span'), null));
}
return new DomView(pv, [DOM.childNodes(root)[0]], [], boundElements);
}

View File

@ -118,11 +118,11 @@ export class MdDialog {
});
}
alert(message: string, okMessage: string): Promise {
alert(message: string, okMessage: string): Promise<any> {
throw "Not implemented";
}
confirm(message: string, okMessage: string, cancelMessage: string): Promise {
confirm(message: string, okMessage: string, cancelMessage: string): Promise<any> {
throw "Not implemented";
}
}
@ -176,7 +176,7 @@ export class MdDialogRef {
/** Gets a promise that is resolved when the dialog is closed. */
get whenClosed(): Promise {
get whenClosed(): Promise<any> {
return this.whenClosedDeferred.promise;
}

View File

@ -51,7 +51,7 @@ export class MdGridList {
}
set cols(value) {
this._cols = isString(value) ? NumberWrapper.parseInt(value, 10) : value;
this._cols = isString(value) ? NumberWrapper.parseInt(value, 10) : <number>value;
}
get cols() {
@ -105,7 +105,7 @@ export class MdGridList {
* @param tile
*/
addTile(tile: MdGridTile) {
ListWrapper.push(this.tiles, tile);
this.tiles.push(tile);
}
/**
@ -253,7 +253,7 @@ export class MdGridTile {
}
set rowspan(value) {
this._rowspan = isString(value) ? NumberWrapper.parseInt(value, 10) : value;
this._rowspan = isString(value) ? NumberWrapper.parseInt(value, 10) : <number>value;
}
get rowspan() {
@ -261,7 +261,7 @@ export class MdGridTile {
}
set colspan(value) {
this._colspan = isString(value) ? NumberWrapper.parseInt(value, 10) : value;
this._colspan = isString(value) ? NumberWrapper.parseInt(value, 10) : <number>value;
}
get colspan() {

View File

@ -119,7 +119,7 @@ export class MdRadioGroup {
/** Registers a child radio button with this group. */
register(radio: MdRadioButton) {
ListWrapper.push(this.radios_, radio);
this.radios_.push(radio);
}
/** Handles up and down arrow key presses to change the selected child radio. */

View File

@ -19,6 +19,6 @@ export class MdRadioDispatcher {
/** Listen for future changes to radio button selection. */
listen(listener) {
ListWrapper.push(this.listeners_, listener);
this.listeners_.push(listener);
}
}

View File

@ -1,7 +1,6 @@
import {SelectorMatcher} from "angular2/src/render/dom/compiler/selector";
import {CssSelector} from "angular2/src/render/dom/compiler/selector";
import {StringWrapper, Math} from 'angular2/src/facade/lang';
import {ListWrapper} from 'angular2/src/facade/collection';
import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter';
@ -13,10 +12,10 @@ export function main() {
var fixedSelectorStrings = [];
var fixedSelectors = [];
for (var i = 0; i < count; i++) {
ListWrapper.push(fixedSelectorStrings, randomSelector());
fixedSelectorStrings.push(randomSelector());
}
for (var i = 0; i < count; i++) {
ListWrapper.push(fixedSelectors, CssSelector.parse(fixedSelectorStrings[i]));
fixedSelectors.push(CssSelector.parse(fixedSelectorStrings[i]));
}
fixedMatcher = new SelectorMatcher();
for (var i = 0; i < count; i++) {
@ -26,7 +25,7 @@ export function main() {
function parse() {
var result = [];
for (var i = 0; i < count; i++) {
ListWrapper.push(result, CssSelector.parse(fixedSelectorStrings[i]));
result.push(CssSelector.parse(fixedSelectorStrings[i]));
}
return result;
}

View File

@ -36,7 +36,7 @@ export class App {
appSize = appSize > 1 ? appSize - 1 : 0; // draw at least one table
this.scrollAreas = [];
for (var i = 0; i < appSize; i++) {
ListWrapper.push(this.scrollAreas, i);
this.scrollAreas.push(i);
}
bindAction('#run-btn', () => { this.runBenchmark(); });
bindAction('#reset-btn', () => {

View File

@ -13,7 +13,7 @@ import {
export function generateOfferings(count: int): List<Offering> {
var res = [];
for (var i = 0; i < count; i++) {
ListWrapper.push(res, generateOffering(i));
res.push(generateOffering(i));
}
return res;
}

View File

@ -156,10 +156,10 @@ export class PerflogMetric extends Metric {
startEvent['ph'] = 'B';
endEvent['ph'] = 'E';
endEvent['ts'] = startEvent['ts'] + startEvent['dur'];
ListWrapper.push(this._remainingEvents, startEvent);
ListWrapper.push(this._remainingEvents, endEvent);
this._remainingEvents.push(startEvent);
this._remainingEvents.push(endEvent);
} else {
ListWrapper.push(this._remainingEvents, event);
this._remainingEvents.push(event);
}
});
if (needSort) {
@ -239,10 +239,10 @@ export class PerflogMetric extends Metric {
if (StringWrapper.equals(ph, 'I') || StringWrapper.equals(ph, 'i')) {
if (isPresent(frameCaptureStartEvent) && isBlank(frameCaptureEndEvent) &&
StringWrapper.equals(name, 'frame')) {
ListWrapper.push(frameTimestamps, event['ts']);
frameTimestamps.push(event['ts']);
if (frameTimestamps.length >= 2) {
ListWrapper.push(frameTimes, frameTimestamps[frameTimestamps.length - 1] -
frameTimestamps[frameTimestamps.length - 2]);
frameTimes.push(frameTimestamps[frameTimestamps.length - 1] -
frameTimestamps[frameTimestamps.length - 2]);
}
}
}

View File

@ -33,7 +33,7 @@ export class ConsoleReporter extends Reporter {
static _sortedProps(obj) {
var props = [];
StringMapWrapper.forEach(obj, (value, prop) => ListWrapper.push(props, prop));
StringMapWrapper.forEach(obj, (value, prop) => props.push(prop));
props.sort();
return props;
}

View File

@ -41,13 +41,13 @@ export class Runner {
bind(Options.EXECUTE).toValue(execute)
];
if (isPresent(prepare)) {
ListWrapper.push(sampleBindings, bind(Options.PREPARE).toValue(prepare));
sampleBindings.push(bind(Options.PREPARE).toValue(prepare));
}
if (isPresent(microMetrics)) {
ListWrapper.push(sampleBindings, bind(Options.MICRO_METRICS).toValue(microMetrics));
sampleBindings.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
}
if (isPresent(bindings)) {
ListWrapper.push(sampleBindings, bindings);
sampleBindings.push(bindings);
}
return Injector.resolveAndCreate(sampleBindings)
.asyncGet(Sampler)

View File

@ -39,8 +39,8 @@ export class RegressionSlopeValidator extends Validator {
for (var i = 0; i < latestSample.length; i++) {
// For now, we only use the array index as x value.
// TODO(tbosch): think about whether we should use time here instead
ListWrapper.push(xValues, i);
ListWrapper.push(yValues, latestSample[i].values[this._metric]);
xValues.push(i);
yValues.push(latestSample[i].values[this._metric]);
}
var regressionSlope = Statistic.calculateRegressionSlope(
xValues, Statistic.calculateMean(xValues), yValues, Statistic.calculateMean(yValues));

View File

@ -53,7 +53,7 @@ export class ChromeDriverExtension extends WebDriverExtension {
ListWrapper.forEach(entries, function(entry) {
var message = Json.parse(entry['message'])['message'];
if (StringWrapper.equals(message['method'], 'Tracing.dataCollected')) {
ListWrapper.push(events, message['params']);
events.push(message['params']);
}
if (StringWrapper.equals(message['method'], 'Tracing.bufferUsage')) {
throw new BaseException('The DevTools trace buffer filled during the test!');
@ -79,14 +79,14 @@ export class ChromeDriverExtension extends WebDriverExtension {
if (StringWrapper.equals(name, 'FunctionCall') &&
(isBlank(args) || isBlank(args['data']) ||
!StringWrapper.equals(args['data']['scriptName'], 'InjectedScript'))) {
ListWrapper.push(normalizedEvents, normalizeEvent(event, {'name': 'script'}));
normalizedEvents.push(normalizeEvent(event, {'name': 'script'}));
} else if (StringWrapper.equals(name, 'RecalculateStyles') ||
StringWrapper.equals(name, 'Layout') ||
StringWrapper.equals(name, 'UpdateLayerTree') ||
StringWrapper.equals(name, 'Paint') || StringWrapper.equals(name, 'Rasterize') ||
StringWrapper.equals(name, 'CompositeLayers')) {
ListWrapper.push(normalizedEvents, normalizeEvent(event, {'name': 'render'}));
normalizedEvents.push(normalizeEvent(event, {'name': 'render'}));
} else if (StringWrapper.equals(name, 'GCEvent')) {
var normArgs = {
@ -97,12 +97,11 @@ export class ChromeDriverExtension extends WebDriverExtension {
normArgs['majorGc'] = isPresent(majorGCPids[pid]) && majorGCPids[pid];
}
majorGCPids[pid] = false;
ListWrapper.push(normalizedEvents,
normalizeEvent(event, {'name': 'gc', 'args': normArgs}));
normalizedEvents.push(normalizeEvent(event, {'name': 'gc', 'args': normArgs}));
}
} else if (StringWrapper.equals(cat, 'blink.console')) {
ListWrapper.push(normalizedEvents, normalizeEvent(event, {'name': name}));
normalizedEvents.push(normalizeEvent(event, {'name': name}));
} else if (StringWrapper.equals(cat, 'v8')) {
if (StringWrapper.equals(name, 'majorGC')) {
@ -118,7 +117,7 @@ export class ChromeDriverExtension extends WebDriverExtension {
throw new BaseException('multi-frame render stats not supported');
}
if (frameCount == 1) {
ListWrapper.push(normalizedEvents, normalizeEvent(event, {'name': 'frame'}));
normalizedEvents.push(normalizeEvent(event, {'name': 'frame'}));
}
} else if (StringWrapper.equals(name, 'BenchmarkInstrumentation::DisplayRenderingStats') ||
StringWrapper.equals(name, 'vsync_before')) {

View File

@ -44,14 +44,14 @@ export class IOsDriverExtension extends WebDriverExtension {
ListWrapper.forEach(entries, function(entry) {
var message = Json.parse(entry['message'])['message'];
if (StringWrapper.equals(message['method'], 'Timeline.eventRecorded')) {
ListWrapper.push(records, message['params']['record']);
records.push(message['params']['record']);
}
});
return this._convertPerfRecordsToEvents(records);
});
}
_convertPerfRecordsToEvents(records: any[], events = null) {
_convertPerfRecordsToEvents(records: any[], events: any[] = null) {
if (isBlank(events)) {
events = [];
}
@ -64,18 +64,18 @@ export class IOsDriverExtension extends WebDriverExtension {
if (StringWrapper.equals(type, 'FunctionCall') &&
(isBlank(data) || !StringWrapper.equals(data['scriptName'], 'InjectedScript'))) {
ListWrapper.push(events, createStartEvent('script', startTime));
events.push(createStartEvent('script', startTime));
endEvent = createEndEvent('script', endTime);
} else if (StringWrapper.equals(type, 'Time')) {
ListWrapper.push(events, createMarkStartEvent(data['message'], startTime));
events.push(createMarkStartEvent(data['message'], startTime));
} else if (StringWrapper.equals(type, 'TimeEnd')) {
ListWrapper.push(events, createMarkEndEvent(data['message'], startTime));
events.push(createMarkEndEvent(data['message'], startTime));
} else if (StringWrapper.equals(type, 'RecalculateStyles') ||
StringWrapper.equals(type, 'Layout') ||
StringWrapper.equals(type, 'UpdateLayerTree') ||
StringWrapper.equals(type, 'Paint') || StringWrapper.equals(type, 'Rasterize') ||
StringWrapper.equals(type, 'CompositeLayers')) {
ListWrapper.push(events, createStartEvent('render', startTime));
events.push(createStartEvent('render', startTime));
endEvent = createEndEvent('render', endTime);
}
// Note: ios used to support GCEvent up until iOS 6 :-(
@ -83,7 +83,7 @@ export class IOsDriverExtension extends WebDriverExtension {
this._convertPerfRecordsToEvents(record['children'], events);
}
if (isPresent(endEvent)) {
ListWrapper.push(events, endEvent);
events.push(endEvent);
}
});
return events;

View File

@ -28,7 +28,7 @@ import {
import {TraceEventFactory} from '../trace_event_factory';
export function main() {
var commandLog;
var commandLog: any[];
var eventFactory = new TraceEventFactory('timeline', 'pid0');
function createMetric(perfLogs, microMetrics = null, perfLogFeatures = null, forceGc = null,
@ -46,17 +46,17 @@ export function main() {
bind(Options.MICRO_METRICS).toValue(microMetrics),
bind(PerflogMetric.SET_TIMEOUT)
.toValue((fn, millis) => {
ListWrapper.push(commandLog, ['setTimeout', millis]);
commandLog.push(['setTimeout', millis]);
fn();
}),
bind(WebDriverExtension)
.toValue(new MockDriverExtension(perfLogs, commandLog, perfLogFeatures))
];
if (isPresent(forceGc)) {
ListWrapper.push(bindings, bind(Options.FORCE_GC).toValue(forceGc));
bindings.push(bind(Options.FORCE_GC).toValue(forceGc));
}
if (isPresent(captureFrames)) {
ListWrapper.push(bindings, bind(Options.CAPTURE_FRAMES).toValue(captureFrames));
bindings.push(bind(Options.CAPTURE_FRAMES).toValue(captureFrames));
}
return Injector.resolveAndCreate(bindings).get(PerflogMetric);
}
@ -65,7 +65,7 @@ export function main() {
function sortedKeys(stringMap) {
var res = [];
StringMapWrapper.forEach(stringMap, (_, key) => { ListWrapper.push(res, key); });
StringMapWrapper.forEach(stringMap, (_, key) => { res.push(key); });
res.sort();
return res;
}
@ -324,9 +324,9 @@ export function main() {
describe('aggregation', () => {
function aggregate(events, microMetrics = null, captureFrames = null) {
function aggregate(events: any[], microMetrics = null, captureFrames = null) {
ListWrapper.insert(events, 0, eventFactory.markStart('benchpress0', 0));
ListWrapper.push(events, eventFactory.markEnd('benchpress0', 10));
events.push(eventFactory.markEnd('benchpress0', 10));
var metric = createMetric([events], microMetrics, null, null, captureFrames);
return metric.beginMeasure().then((_) => metric.endMeasure(false));
}
@ -640,19 +640,19 @@ class MockDriverExtension extends WebDriverExtension {
}
timeBegin(name): Promise<any> {
ListWrapper.push(this._commandLog, ['timeBegin', name]);
this._commandLog.push(['timeBegin', name]);
return PromiseWrapper.resolve(null);
}
timeEnd(name, restartName): Promise<any> {
ListWrapper.push(this._commandLog, ['timeEnd', name, restartName]);
this._commandLog.push(['timeEnd', name, restartName]);
return PromiseWrapper.resolve(null);
}
perfLogFeatures(): PerfLogFeatures { return this._perfLogFeatures; }
readPerfLog(): Promise<any> {
ListWrapper.push(this._commandLog, 'readPerfLog');
this._commandLog.push('readPerfLog');
if (this._perfLogs.length > 0) {
var next = this._perfLogs[0];
ListWrapper.removeAt(this._perfLogs, 0);
@ -663,7 +663,7 @@ class MockDriverExtension extends WebDriverExtension {
}
gc(): Promise<any> {
ListWrapper.push(this._commandLog, ['gc']);
this._commandLog.push(['gc']);
return PromiseWrapper.resolve(null);
}
}

View File

@ -16,7 +16,7 @@ import {
export function main() {
describe('console reporter', () => {
var reporter;
var log;
var log: string[];
function createReporter({columnWidth = null, sampleId = null, descriptions = null,
metrics = null}: {columnWidth?, sampleId?, descriptions?, metrics?}) {
@ -30,10 +30,10 @@ export function main() {
var bindings = [
ConsoleReporter.BINDINGS,
bind(SampleDescription).toValue(new SampleDescription(sampleId, descriptions, metrics)),
bind(ConsoleReporter.PRINT).toValue((line) => ListWrapper.push(log, line))
bind(ConsoleReporter.PRINT).toValue((line) => log.push(line))
];
if (isPresent(columnWidth)) {
ListWrapper.push(bindings, bind(ConsoleReporter.COLUMN_WIDTH).toValue(columnWidth));
bindings.push(bind(ConsoleReporter.COLUMN_WIDTH).toValue(columnWidth));
}
reporter = Injector.resolveAndCreate(bindings).get(ConsoleReporter);
}

View File

@ -69,7 +69,7 @@ export function main() {
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(time++))
];
if (isPresent(prepare)) {
ListWrapper.push(bindings, bind(Options.PREPARE).toValue(prepare));
bindings.push(bind(Options.PREPARE).toValue(prepare));
}
sampler = Injector.resolveAndCreate(bindings).get(Sampler);
@ -81,7 +81,7 @@ export function main() {
var count = 0;
var driver = new MockDriverAdapter([], (callback) => {
var result = callback();
ListWrapper.push(log, result);
log.push(result);
return PromiseWrapper.resolve(result);
});
createSampler({
@ -105,8 +105,8 @@ export function main() {
createSampler({
metric: createCountingMetric(log),
validator: createCountingValidator(2),
prepare: () => { ListWrapper.push(log, `p${workCount++}`); },
execute: () => { ListWrapper.push(log, `w${workCount++}`); }
prepare: () => { log.push(`p${workCount++}`); },
execute: () => { log.push(`w${workCount++}`); }
});
sampler.sample().then((_) => {
expect(log).toEqual([
@ -130,7 +130,7 @@ export function main() {
createSampler({
metric: createCountingMetric(log),
validator: createCountingValidator(2),
execute: () => { ListWrapper.push(log, `w${workCount++}`); },
execute: () => { log.push(`w${workCount++}`); },
prepare: null
});
sampler.sample().then((_) => {
@ -282,7 +282,7 @@ class MockValidator extends Validator {
}
validate(completeSample: List<MeasureValues>): List<MeasureValues> {
var stableSample = isPresent(this._validate) ? this._validate(completeSample) : completeSample;
ListWrapper.push(this._log, ['validate', completeSample, stableSample]);
this._log.push(['validate', completeSample, stableSample]);
return stableSample;
}
}
@ -297,12 +297,12 @@ class MockMetric extends Metric {
this._log = log;
}
beginMeasure() {
ListWrapper.push(this._log, ['beginMeasure']);
this._log.push(['beginMeasure']);
return PromiseWrapper.resolve(null);
}
endMeasure(restart) {
var measureValues = isPresent(this._endMeasure) ? this._endMeasure() : {};
ListWrapper.push(this._log, ['endMeasure', restart, measureValues]);
this._log.push(['endMeasure', restart, measureValues]);
return PromiseWrapper.resolve(measureValues);
}
}
@ -317,11 +317,11 @@ class MockReporter extends Reporter {
this._log = log;
}
reportMeasureValues(values): Promise<any> {
ListWrapper.push(this._log, ['reportMeasureValues', values]);
this._log.push(['reportMeasureValues', values]);
return PromiseWrapper.resolve(null);
}
reportSample(completeSample, validSample): Promise<any> {
ListWrapper.push(this._log, ['reportSample', completeSample, validSample]);
this._log.push(['reportSample', completeSample, validSample]);
return PromiseWrapper.resolve(null);
}
}

View File

@ -11,7 +11,6 @@ import {
xit,
} from 'angular2/test_lib';
import {ListWrapper} from 'angular2/src/facade/collection';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {Json, isBlank} from 'angular2/src/facade/lang';
@ -307,12 +306,12 @@ class MockDriverAdapter extends WebDriverAdapter {
}
executeScript(script) {
ListWrapper.push(this._log, ['executeScript', script]);
this._log.push(['executeScript', script]);
return PromiseWrapper.resolve(null);
}
logs(type) {
ListWrapper.push(this._log, ['logs', type]);
this._log.push(['logs', type]);
if (type === 'performance') {
return PromiseWrapper.resolve(this._events.map((event) => {
return {

View File

@ -11,7 +11,6 @@ import {
xit,
} from 'angular2/test_lib';
import {ListWrapper} from 'angular2/src/facade/collection';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {Json, isBlank, isPresent} from 'angular2/src/facade/lang';
@ -196,12 +195,12 @@ class MockDriverAdapter extends WebDriverAdapter {
constructor(private _log: List<any>, private _perfRecords: List<any>) { super(); }
executeScript(script) {
ListWrapper.push(this._log, ['executeScript', script]);
this._log.push(['executeScript', script]);
return PromiseWrapper.resolve(null);
}
logs(type) {
ListWrapper.push(this._log, ['logs', type]);
this._log.push(['logs', type]);
if (type === 'performance') {
return PromiseWrapper.resolve(this._perfRecords.map(function(record) {
return {

View File

@ -26,7 +26,7 @@ export class TodoFactory {
export class Store {
list: List<KeyModel> = [];
add(record: KeyModel): void { ListWrapper.push(this.list, record); }
add(record: KeyModel): void { this.list.push(record); }
remove(record: KeyModel): void { this._spliceOut(record); }