diff --git a/modules/angular2/src/core/change_detection/coalesce.ts b/modules/angular2/src/core/change_detection/coalesce.ts index 0ab84320dc..b22f1df9b9 100644 --- a/modules/angular2/src/core/change_detection/coalesce.ts +++ b/modules/angular2/src/core/change_detection/coalesce.ts @@ -43,14 +43,14 @@ export function coalesce(records: ProtoRecord[]): ProtoRecord[] { } function _selfRecord(r: ProtoRecord, contextIndex: number, selfIndex: number): ProtoRecord { - return new ProtoRecord(RecordType.SELF, "self", null, [], r.fixedArgs, contextIndex, + return new ProtoRecord(RecordType.Self, "self", null, [], r.fixedArgs, contextIndex, r.directiveIndex, selfIndex, r.bindingRecord, r.lastInBinding, r.lastInDirective, false, false, r.propertyBindingIndex); } function _findMatching(r: ProtoRecord, rs: List) { return ListWrapper.find( - rs, (rr) => rr.mode !== RecordType.DIRECTIVE_LIFECYCLE && _sameDirIndex(rr, r) && + rs, (rr) => rr.mode !== RecordType.DirectiveLifecycle && _sameDirIndex(rr, r) && rr.mode === r.mode && looseIdentical(rr.funcOrValue, r.funcOrValue) && rr.contextIndex === r.contextIndex && looseIdentical(rr.name, r.name) && ListWrapper.equals(rr.args, r.args)); diff --git a/modules/angular2/src/core/change_detection/codegen_logic_util.ts b/modules/angular2/src/core/change_detection/codegen_logic_util.ts index 6fdb6a58bc..dafed6dad0 100644 --- a/modules/angular2/src/core/change_detection/codegen_logic_util.ts +++ b/modules/angular2/src/core/change_detection/codegen_logic_util.ts @@ -47,67 +47,67 @@ export class CodegenLogicUtil { var rhs: string; switch (protoRec.mode) { - case RecordType.SELF: + case RecordType.Self: rhs = context; break; - case RecordType.CONST: + case RecordType.Const: rhs = codify(protoRec.funcOrValue); break; - case RecordType.PROPERTY_READ: + case RecordType.PropertyRead: rhs = this._observe(`${context}.${protoRec.name}`, protoRec); break; - case RecordType.SAFE_PROPERTY: + case RecordType.SafeProperty: var read = this._observe(`${context}.${protoRec.name}`, protoRec); rhs = `${this._utilName}.isValueBlank(${context}) ? null : ${this._observe(read, protoRec)}`; break; - case RecordType.PROPERTY_WRITE: + case RecordType.PropertyWrite: rhs = `${context}.${protoRec.name} = ${getLocalName(protoRec.args[0])}`; break; - case RecordType.LOCAL: + case RecordType.Local: rhs = this._observe(`${localsAccessor}.get(${rawString(protoRec.name)})`, protoRec); break; - case RecordType.INVOKE_METHOD: + case RecordType.InvokeMethod: rhs = this._observe(`${context}.${protoRec.name}(${argString})`, protoRec); break; - case RecordType.SAFE_INVOKE_METHOD: + case RecordType.SafeMethodInvoke: var invoke = `${context}.${protoRec.name}(${argString})`; rhs = `${this._utilName}.isValueBlank(${context}) ? null : ${this._observe(invoke, protoRec)}`; break; - case RecordType.INVOKE_CLOSURE: + case RecordType.InvokeClosure: rhs = `${context}(${argString})`; break; - case RecordType.PRIMITIVE_OP: + case RecordType.PrimitiveOp: rhs = `${this._utilName}.${protoRec.name}(${argString})`; break; - case RecordType.COLLECTION_LITERAL: + case RecordType.CollectionLiteral: rhs = `${this._utilName}.${protoRec.name}(${argString})`; break; - case RecordType.INTERPOLATE: + case RecordType.Interpolate: rhs = this._genInterpolation(protoRec); break; - case RecordType.KEYED_READ: + case RecordType.KeyedRead: rhs = this._observe(`${context}[${getLocalName(protoRec.args[0])}]`, protoRec); break; - case RecordType.KEYED_WRITE: + case RecordType.KeyedWrite: rhs = `${context}[${getLocalName(protoRec.args[0])}] = ${getLocalName(protoRec.args[1])}`; break; - case RecordType.CHAIN: + case RecordType.Chain: rhs = 'null'; break; diff --git a/modules/angular2/src/core/change_detection/dynamic_change_detector.ts b/modules/angular2/src/core/change_detection/dynamic_change_detector.ts index 1b0d882a96..c113bb8c56 100644 --- a/modules/angular2/src/core/change_detection/dynamic_change_detector.ts +++ b/modules/angular2/src/core/change_detection/dynamic_change_detector.ts @@ -252,42 +252,42 @@ export class DynamicChangeDetector extends AbstractChangeDetector { _calculateCurrValue(proto: ProtoRecord, values: any[], locals: Locals) { switch (proto.mode) { - case RecordType.SELF: + case RecordType.Self: return this._readContext(proto, values); - case RecordType.CONST: + case RecordType.Const: return proto.funcOrValue; - case RecordType.PROPERTY_READ: + case RecordType.PropertyRead: var context = this._readContext(proto, values); return proto.funcOrValue(context); - case RecordType.SAFE_PROPERTY: + case RecordType.SafeProperty: var context = this._readContext(proto, values); return isBlank(context) ? null : proto.funcOrValue(context); - case RecordType.PROPERTY_WRITE: + case RecordType.PropertyWrite: var context = this._readContext(proto, values); var value = this._readArgs(proto, values)[0]; proto.funcOrValue(context, value); return value; - case RecordType.KEYED_WRITE: + case RecordType.KeyedWrite: var context = this._readContext(proto, values); var key = this._readArgs(proto, values)[0]; var value = this._readArgs(proto, values)[1]; context[key] = value; return value; - case RecordType.LOCAL: + case RecordType.Local: return locals.get(proto.name); - case RecordType.INVOKE_METHOD: + case RecordType.InvokeMethod: var context = this._readContext(proto, values); var args = this._readArgs(proto, values); return proto.funcOrValue(context, args); - case RecordType.SAFE_INVOKE_METHOD: + case RecordType.SafeMethodInvoke: var context = this._readContext(proto, values); if (isBlank(context)) { return null; @@ -295,21 +295,21 @@ export class DynamicChangeDetector extends AbstractChangeDetector { var args = this._readArgs(proto, values); return proto.funcOrValue(context, args); - case RecordType.KEYED_READ: + case RecordType.KeyedRead: var arg = this._readArgs(proto, values)[0]; return this._readContext(proto, values)[arg]; - case RecordType.CHAIN: + case RecordType.Chain: var args = this._readArgs(proto, values); return args[args.length - 1]; - case RecordType.INVOKE_CLOSURE: + case RecordType.InvokeClosure: return FunctionWrapper.apply(this._readContext(proto, values), this._readArgs(proto, values)); - case RecordType.INTERPOLATE: - case RecordType.PRIMITIVE_OP: - case RecordType.COLLECTION_LITERAL: + case RecordType.Interpolate: + case RecordType.PrimitiveOp: + case RecordType.CollectionLiteral: return FunctionWrapper.apply(proto.funcOrValue, this._readArgs(proto, values)); default: diff --git a/modules/angular2/src/core/change_detection/parser/lexer.ts b/modules/angular2/src/core/change_detection/parser/lexer.ts index 2b54b45b33..3f56ac7f9b 100644 --- a/modules/angular2/src/core/change_detection/parser/lexer.ts +++ b/modules/angular2/src/core/change_detection/parser/lexer.ts @@ -9,12 +9,12 @@ import { } from "angular2/src/core/facade/lang"; export enum TokenType { - CHARACTER, - IDENTIFIER, - KEYWORD, - STRING, - OPERATOR, - NUMBER + Character, + Identifier, + Keyword, + String, + Operator, + Number } @Injectable() @@ -36,50 +36,50 @@ export class Token { public strValue: string) {} isCharacter(code: number): boolean { - return (this.type == TokenType.CHARACTER && this.numValue == code); + return (this.type == TokenType.Character && this.numValue == code); } - isNumber(): boolean { return (this.type == TokenType.NUMBER); } + isNumber(): boolean { return (this.type == TokenType.Number); } - isString(): boolean { return (this.type == TokenType.STRING); } + isString(): boolean { return (this.type == TokenType.String); } isOperator(operater: string): boolean { - return (this.type == TokenType.OPERATOR && this.strValue == operater); + return (this.type == TokenType.Operator && this.strValue == operater); } - isIdentifier(): boolean { return (this.type == TokenType.IDENTIFIER); } + isIdentifier(): boolean { return (this.type == TokenType.Identifier); } - isKeyword(): boolean { return (this.type == TokenType.KEYWORD); } + isKeyword(): boolean { return (this.type == TokenType.Keyword); } - isKeywordVar(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "var"); } + isKeywordVar(): boolean { return (this.type == TokenType.Keyword && this.strValue == "var"); } - isKeywordNull(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "null"); } + isKeywordNull(): boolean { return (this.type == TokenType.Keyword && this.strValue == "null"); } isKeywordUndefined(): boolean { - return (this.type == TokenType.KEYWORD && this.strValue == "undefined"); + return (this.type == TokenType.Keyword && this.strValue == "undefined"); } - isKeywordTrue(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "true"); } + isKeywordTrue(): boolean { return (this.type == TokenType.Keyword && this.strValue == "true"); } - isKeywordIf(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "if"); } + isKeywordIf(): boolean { return (this.type == TokenType.Keyword && this.strValue == "if"); } - isKeywordElse(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "else"); } + isKeywordElse(): boolean { return (this.type == TokenType.Keyword && this.strValue == "else"); } - isKeywordFalse(): boolean { return (this.type == TokenType.KEYWORD && this.strValue == "false"); } + isKeywordFalse(): boolean { return (this.type == TokenType.Keyword && this.strValue == "false"); } toNumber(): number { // -1 instead of NULL ok? - return (this.type == TokenType.NUMBER) ? this.numValue : -1; + return (this.type == TokenType.Number) ? this.numValue : -1; } toString(): string { switch (this.type) { - case TokenType.CHARACTER: - case TokenType.STRING: - case TokenType.IDENTIFIER: - case TokenType.KEYWORD: + case TokenType.Character: + case TokenType.String: + case TokenType.Identifier: + case TokenType.Keyword: return this.strValue; - case TokenType.NUMBER: + case TokenType.Number: return this.numValue.toString(); default: return null; @@ -88,31 +88,31 @@ export class Token { } function newCharacterToken(index: number, code: number): Token { - return new Token(index, TokenType.CHARACTER, code, StringWrapper.fromCharCode(code)); + return new Token(index, TokenType.Character, code, StringWrapper.fromCharCode(code)); } function newIdentifierToken(index: number, text: string): Token { - return new Token(index, TokenType.IDENTIFIER, 0, text); + return new Token(index, TokenType.Identifier, 0, text); } function newKeywordToken(index: number, text: string): Token { - return new Token(index, TokenType.KEYWORD, 0, text); + return new Token(index, TokenType.Keyword, 0, text); } function newOperatorToken(index: number, text: string): Token { - return new Token(index, TokenType.OPERATOR, 0, text); + return new Token(index, TokenType.Operator, 0, text); } function newStringToken(index: number, text: string): Token { - return new Token(index, TokenType.STRING, 0, text); + return new Token(index, TokenType.String, 0, text); } function newNumberToken(index: number, n: number): Token { - return new Token(index, TokenType.NUMBER, n, ""); + return new Token(index, TokenType.Number, n, ""); } -export var EOF: Token = new Token(-1, TokenType.CHARACTER, 0, ""); +export var EOF: Token = new Token(-1, TokenType.Character, 0, ""); export const $EOF = 0; export const $TAB = 9; diff --git a/modules/angular2/src/core/change_detection/proto_change_detector.ts b/modules/angular2/src/core/change_detection/proto_change_detector.ts index 59a8e096f4..6e5d4bafdb 100644 --- a/modules/angular2/src/core/change_detection/proto_change_detector.ts +++ b/modules/angular2/src/core/change_detection/proto_change_detector.ts @@ -107,7 +107,7 @@ export class ProtoRecordBuilder { _appendRecords(b: BindingRecord, variableNames: string[], bindingIndex: number) { if (b.isDirectiveLifecycle()) { - this.records.push(new ProtoRecord(RecordType.DIRECTIVE_LIFECYCLE, b.lifecycleEvent, null, [], + this.records.push(new ProtoRecord(RecordType.DirectiveLifecycle, b.lifecycleEvent, null, [], [], -1, null, this.records.length + 1, b, false, false, false, false, null)); } else { @@ -137,21 +137,21 @@ class _ConvertAstIntoProtoRecords implements AstVisitor { visitInterpolation(ast: Interpolation): number { var args = this._visitAll(ast.expressions); - return this._addRecord(RecordType.INTERPOLATE, "interpolate", _interpolationFn(ast.strings), + return this._addRecord(RecordType.Interpolate, "interpolate", _interpolationFn(ast.strings), args, ast.strings, 0); } visitLiteralPrimitive(ast: LiteralPrimitive): number { - return this._addRecord(RecordType.CONST, "literal", ast.value, [], null, 0); + return this._addRecord(RecordType.Const, "literal", ast.value, [], null, 0); } visitPropertyRead(ast: PropertyRead): number { var receiver = ast.receiver.visit(this); if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name) && ast.receiver instanceof ImplicitReceiver) { - return this._addRecord(RecordType.LOCAL, ast.name, ast.name, [], null, receiver); + return this._addRecord(RecordType.Local, ast.name, ast.name, [], null, receiver); } else { - return this._addRecord(RecordType.PROPERTY_READ, ast.name, ast.getter, [], null, receiver); + return this._addRecord(RecordType.PropertyRead, ast.name, ast.getter, [], null, receiver); } } @@ -162,7 +162,7 @@ class _ConvertAstIntoProtoRecords implements AstVisitor { } else { var receiver = ast.receiver.visit(this); var value = ast.value.visit(this); - return this._addRecord(RecordType.PROPERTY_WRITE, ast.name, ast.setter, [value], null, + return this._addRecord(RecordType.PropertyWrite, ast.name, ast.setter, [value], null, receiver); } } @@ -171,46 +171,46 @@ class _ConvertAstIntoProtoRecords implements AstVisitor { var obj = ast.obj.visit(this); var key = ast.key.visit(this); var value = ast.value.visit(this); - return this._addRecord(RecordType.KEYED_WRITE, null, null, [key, value], null, obj); + return this._addRecord(RecordType.KeyedWrite, null, null, [key, value], null, obj); } visitSafePropertyRead(ast: SafePropertyRead): number { var receiver = ast.receiver.visit(this); - return this._addRecord(RecordType.SAFE_PROPERTY, ast.name, ast.getter, [], null, receiver); + return this._addRecord(RecordType.SafeProperty, ast.name, ast.getter, [], null, receiver); } visitMethodCall(ast: MethodCall): number { var receiver = ast.receiver.visit(this); var args = this._visitAll(ast.args); if (isPresent(this._variableNames) && ListWrapper.contains(this._variableNames, ast.name)) { - var target = this._addRecord(RecordType.LOCAL, ast.name, ast.name, [], null, receiver); - return this._addRecord(RecordType.INVOKE_CLOSURE, "closure", null, args, null, target); + var target = this._addRecord(RecordType.Local, ast.name, ast.name, [], null, receiver); + return this._addRecord(RecordType.InvokeClosure, "closure", null, args, null, target); } else { - return this._addRecord(RecordType.INVOKE_METHOD, ast.name, ast.fn, args, null, receiver); + return this._addRecord(RecordType.InvokeMethod, ast.name, ast.fn, args, null, receiver); } } visitSafeMethodCall(ast: SafeMethodCall): number { var receiver = ast.receiver.visit(this); var args = this._visitAll(ast.args); - return this._addRecord(RecordType.SAFE_INVOKE_METHOD, ast.name, ast.fn, args, null, receiver); + return this._addRecord(RecordType.SafeMethodInvoke, ast.name, ast.fn, args, null, receiver); } visitFunctionCall(ast: FunctionCall): number { var target = ast.target.visit(this); var args = this._visitAll(ast.args); - return this._addRecord(RecordType.INVOKE_CLOSURE, "closure", null, args, null, target); + return this._addRecord(RecordType.InvokeClosure, "closure", null, args, null, target); } visitLiteralArray(ast: LiteralArray): number { var primitiveName = `arrayFn${ast.expressions.length}`; - return this._addRecord(RecordType.COLLECTION_LITERAL, primitiveName, + return this._addRecord(RecordType.CollectionLiteral, primitiveName, _arrayFn(ast.expressions.length), this._visitAll(ast.expressions), null, 0); } visitLiteralMap(ast: LiteralMap): number { - return this._addRecord(RecordType.COLLECTION_LITERAL, _mapPrimitiveName(ast.keys), + return this._addRecord(RecordType.CollectionLiteral, _mapPrimitiveName(ast.keys), ChangeDetectionUtil.mapFn(ast.keys), this._visitAll(ast.values), null, 0); } @@ -218,13 +218,13 @@ class _ConvertAstIntoProtoRecords implements AstVisitor { visitBinary(ast: Binary): number { var left = ast.left.visit(this); var right = ast.right.visit(this); - return this._addRecord(RecordType.PRIMITIVE_OP, _operationToPrimitiveName(ast.operation), + return this._addRecord(RecordType.PrimitiveOp, _operationToPrimitiveName(ast.operation), _operationToFunction(ast.operation), [left, right], null, 0); } visitPrefixNot(ast: PrefixNot): number { var exp = ast.expression.visit(this); - return this._addRecord(RecordType.PRIMITIVE_OP, "operation_negate", + return this._addRecord(RecordType.PrimitiveOp, "operation_negate", ChangeDetectionUtil.operation_negate, [exp], null, 0); } @@ -232,26 +232,26 @@ class _ConvertAstIntoProtoRecords implements AstVisitor { var c = ast.condition.visit(this); var t = ast.trueExp.visit(this); var f = ast.falseExp.visit(this); - return this._addRecord(RecordType.PRIMITIVE_OP, "cond", ChangeDetectionUtil.cond, [c, t, f], + return this._addRecord(RecordType.PrimitiveOp, "cond", ChangeDetectionUtil.cond, [c, t, f], null, 0); } visitPipe(ast: BindingPipe): number { var value = ast.exp.visit(this); var args = this._visitAll(ast.args); - return this._addRecord(RecordType.PIPE, ast.name, ast.name, args, null, value); + return this._addRecord(RecordType.Pipe, ast.name, ast.name, args, null, value); } visitKeyedRead(ast: KeyedRead): number { var obj = ast.obj.visit(this); var key = ast.key.visit(this); - return this._addRecord(RecordType.KEYED_READ, "keyedAccess", ChangeDetectionUtil.keyedAccess, + return this._addRecord(RecordType.KeyedRead, "keyedAccess", ChangeDetectionUtil.keyedAccess, [key], null, obj); } visitChain(ast: Chain): number { var args = ast.expressions.map(e => e.visit(this)); - return this._addRecord(RecordType.CHAIN, "chain", null, args, null, 0); + return this._addRecord(RecordType.Chain, "chain", null, args, null, 0); } visitIf(ast: If) { throw new BaseException('Not supported'); } diff --git a/modules/angular2/src/core/change_detection/proto_record.ts b/modules/angular2/src/core/change_detection/proto_record.ts index f22d46423a..f58df466ad 100644 --- a/modules/angular2/src/core/change_detection/proto_record.ts +++ b/modules/angular2/src/core/change_detection/proto_record.ts @@ -3,23 +3,23 @@ import {BindingRecord} from './binding_record'; import {DirectiveIndex} from './directive_record'; export enum RecordType { - SELF, - CONST, - PRIMITIVE_OP, - PROPERTY_READ, - PROPERTY_WRITE, - LOCAL, - INVOKE_METHOD, - INVOKE_CLOSURE, - KEYED_READ, - KEYED_WRITE, - PIPE, - INTERPOLATE, - SAFE_PROPERTY, - COLLECTION_LITERAL, - SAFE_INVOKE_METHOD, - DIRECTIVE_LIFECYCLE, - CHAIN + Self, + Const, + PrimitiveOp, + PropertyRead, + PropertyWrite, + Local, + InvokeMethod, + InvokeClosure, + KeyedRead, + KeyedWrite, + Pipe, + Interpolate, + SafeProperty, + CollectionLiteral, + SafeMethodInvoke, + DirectiveLifecycle, + Chain } export class ProtoRecord { @@ -31,7 +31,7 @@ export class ProtoRecord { public referencedBySelf: boolean, public propertyBindingIndex: number) {} isPureFunction(): boolean { - return this.mode === RecordType.INTERPOLATE || this.mode === RecordType.COLLECTION_LITERAL; + return this.mode === RecordType.Interpolate || this.mode === RecordType.CollectionLiteral; } isUsedByOtherRecord(): boolean { return !this.lastInBinding || this.referencedBySelf; } @@ -40,7 +40,7 @@ export class ProtoRecord { return this.argumentToPureFunction || this.lastInBinding || this.isPureFunction(); } - isPipeRecord(): boolean { return this.mode === RecordType.PIPE; } + isPipeRecord(): boolean { return this.mode === RecordType.Pipe; } - isLifeCycleRecord(): boolean { return this.mode === RecordType.DIRECTIVE_LIFECYCLE; } + isLifeCycleRecord(): boolean { return this.mode === RecordType.DirectiveLifecycle; } } diff --git a/modules/angular2/src/core/facade/intl.dart b/modules/angular2/src/core/facade/intl.dart index 46fd827b88..c94b66be5b 100644 --- a/modules/angular2/src/core/facade/intl.dart +++ b/modules/angular2/src/core/facade/intl.dart @@ -4,7 +4,7 @@ import 'package:intl/intl.dart'; String _normalizeLocale(String locale) => locale.replaceAll('-', '_'); -enum NumberFormatStyle { DECIMAL, PERCENT, CURRENCY } +enum NumberFormatStyle { Decimal, Percent, Currency } class NumberFormatter { static String format(num number, String locale, NumberFormatStyle style, @@ -16,13 +16,13 @@ class NumberFormatter { locale = _normalizeLocale(locale); NumberFormat formatter; switch (style) { - case NumberFormatStyle.DECIMAL: + case NumberFormatStyle.Decimal: formatter = new NumberFormat.decimalPattern(locale); break; - case NumberFormatStyle.PERCENT: + case NumberFormatStyle.Percent: formatter = new NumberFormat.percentPattern(locale); break; - case NumberFormatStyle.CURRENCY: + case NumberFormatStyle.Currency: if (currencyAsSymbol) { // See https://github.com/dart-lang/intl/issues/59. throw new Exception( diff --git a/modules/angular2/src/core/facade/intl.ts b/modules/angular2/src/core/facade/intl.ts index 3a8c983a5f..02a4605489 100644 --- a/modules/angular2/src/core/facade/intl.ts +++ b/modules/angular2/src/core/facade/intl.ts @@ -42,9 +42,9 @@ declare module Intl { } export enum NumberFormatStyle { - DECIMAL, - PERCENT, - CURRENCY + Decimal, + Percent, + Currency } export class NumberFormatter { @@ -63,7 +63,7 @@ export class NumberFormatter { maximumFractionDigits: maximumFractionDigits }; intlOptions.style = NumberFormatStyle[style].toLowerCase(); - if (style == NumberFormatStyle.CURRENCY) { + if (style == NumberFormatStyle.Currency) { intlOptions.currency = currency; intlOptions.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code'; } diff --git a/modules/angular2/src/core/pipes/number_pipe.ts b/modules/angular2/src/core/pipes/number_pipe.ts index e6151dd9c9..5c447fa2b9 100644 --- a/modules/angular2/src/core/pipes/number_pipe.ts +++ b/modules/angular2/src/core/pipes/number_pipe.ts @@ -90,7 +90,7 @@ export class NumberPipe { export class DecimalPipe extends NumberPipe implements PipeTransform { transform(value: any, args: any[]): string { var digits: string = ListWrapper.first(args); - return NumberPipe._format(value, NumberFormatStyle.DECIMAL, digits); + return NumberPipe._format(value, NumberFormatStyle.Decimal, digits); } } @@ -112,7 +112,7 @@ export class DecimalPipe extends NumberPipe implements PipeTransform { export class PercentPipe extends NumberPipe implements PipeTransform { transform(value: any, args: any[]): string { var digits: string = ListWrapper.first(args); - return NumberPipe._format(value, NumberFormatStyle.PERCENT, digits); + return NumberPipe._format(value, NumberFormatStyle.Percent, digits); } } @@ -140,7 +140,7 @@ export class CurrencyPipe extends NumberPipe implements PipeTransform { var currencyCode: string = isPresent(args) && args.length > 0 ? args[0] : 'USD'; var symbolDisplay: boolean = isPresent(args) && args.length > 1 ? args[1] : false; var digits: string = isPresent(args) && args.length > 2 ? args[2] : null; - return NumberPipe._format(value, NumberFormatStyle.CURRENCY, digits, currencyCode, + return NumberPipe._format(value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay); } } diff --git a/modules/angular2/src/core/services/url_resolver.ts b/modules/angular2/src/core/services/url_resolver.ts index c355ac40b7..7af5dcb7be 100644 --- a/modules/angular2/src/core/services/url_resolver.ts +++ b/modules/angular2/src/core/services/url_resolver.ts @@ -176,13 +176,13 @@ var _splitRe = * @enum {number} */ enum _ComponentIndex { - SCHEME = 1, - USER_INFO, - DOMAIN, - PORT, - PATH, - QUERY_DATA, - FRAGMENT + Scheme = 1, + UserInfo, + Domain, + Port, + Path, + QueryData, + Fragment } /** @@ -256,13 +256,13 @@ function _removeDotSegments(path: string): string { * @return {string} */ function _joinAndCanonicalizePath(parts: List): string { - var path = parts[_ComponentIndex.PATH]; + var path = parts[_ComponentIndex.Path]; path = isBlank(path) ? '' : _removeDotSegments(path); - parts[_ComponentIndex.PATH] = path; + parts[_ComponentIndex.Path] = path; - return _buildFromEncodedParts(parts[_ComponentIndex.SCHEME], parts[_ComponentIndex.USER_INFO], - parts[_ComponentIndex.DOMAIN], parts[_ComponentIndex.PORT], path, - parts[_ComponentIndex.QUERY_DATA], parts[_ComponentIndex.FRAGMENT]); + return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], + parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, + parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]); } /** @@ -275,26 +275,26 @@ function _resolveUrl(base: string, url: string): string { var parts = _split(encodeURI(url)); var baseParts = _split(base); - if (isPresent(parts[_ComponentIndex.SCHEME])) { + if (isPresent(parts[_ComponentIndex.Scheme])) { return _joinAndCanonicalizePath(parts); } else { - parts[_ComponentIndex.SCHEME] = baseParts[_ComponentIndex.SCHEME]; + parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme]; } - for (var i = _ComponentIndex.SCHEME; i <= _ComponentIndex.PORT; i++) { + for (var i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) { if (isBlank(parts[i])) { parts[i] = baseParts[i]; } } - if (parts[_ComponentIndex.PATH][0] == '/') { + if (parts[_ComponentIndex.Path][0] == '/') { return _joinAndCanonicalizePath(parts); } - var path = baseParts[_ComponentIndex.PATH]; + var path = baseParts[_ComponentIndex.Path]; if (isBlank(path)) path = '/'; var index = path.lastIndexOf('/'); - path = path.substring(0, index + 1) + parts[_ComponentIndex.PATH]; - parts[_ComponentIndex.PATH] = path; + path = path.substring(0, index + 1) + parts[_ComponentIndex.Path]; + parts[_ComponentIndex.Path] = path; return _joinAndCanonicalizePath(parts); } diff --git a/modules/angular2/src/http/backends/jsonp_backend.ts b/modules/angular2/src/http/backends/jsonp_backend.ts index aa7e657327..70934a62df 100644 --- a/modules/angular2/src/http/backends/jsonp_backend.ts +++ b/modules/angular2/src/http/backends/jsonp_backend.ts @@ -19,12 +19,12 @@ export class JSONPConnection implements Connection { constructor(req: Request, private _dom: BrowserJsonp, private baseResponseOptions?: ResponseOptions) { - if (req.method !== RequestMethods.GET) { + if (req.method !== RequestMethods.Get) { throw makeTypeError("JSONP requests must use GET request method."); } this.request = req; this.response = new EventEmitter(); - this.readyState = ReadyStates.LOADING; + this.readyState = ReadyStates.Loading; this._id = _dom.nextRequestID(); _dom.exposeConnection(this._id, this); @@ -42,8 +42,8 @@ export class JSONPConnection implements Connection { let script = this._script = _dom.build(url); script.addEventListener('load', (event) => { - if (this.readyState === ReadyStates.CANCELLED) return; - this.readyState = ReadyStates.DONE; + if (this.readyState === ReadyStates.Cancelled) return; + this.readyState = ReadyStates.Done; _dom.cleanup(script); if (!this._finished) { ObservableWrapper.callThrow( @@ -60,8 +60,8 @@ export class JSONPConnection implements Connection { }); script.addEventListener('error', (error) => { - if (this.readyState === ReadyStates.CANCELLED) return; - this.readyState = ReadyStates.DONE; + if (this.readyState === ReadyStates.Cancelled) return; + this.readyState = ReadyStates.Done; _dom.cleanup(script); ObservableWrapper.callThrow(this.response, error); }); @@ -73,12 +73,12 @@ export class JSONPConnection implements Connection { // Don't leak connections this._finished = true; this._dom.removeConnection(this._id); - if (this.readyState === ReadyStates.CANCELLED) return; + if (this.readyState === ReadyStates.Cancelled) return; this._responseData = data; } dispose(): void { - this.readyState = ReadyStates.CANCELLED; + this.readyState = ReadyStates.Cancelled; let script = this._script; this._script = null; if (isPresent(script)) { diff --git a/modules/angular2/src/http/backends/mock_backend.ts b/modules/angular2/src/http/backends/mock_backend.ts index bd9f8432be..6a155f9f98 100644 --- a/modules/angular2/src/http/backends/mock_backend.ts +++ b/modules/angular2/src/http/backends/mock_backend.ts @@ -34,7 +34,7 @@ export class MockConnection implements Connection { constructor(req: Request) { this.response = new EventEmitter(); - this.readyState = ReadyStates.OPEN; + this.readyState = ReadyStates.Open; this.request = req; } @@ -42,8 +42,8 @@ export class MockConnection implements Connection { * Changes the `readyState` of the connection to a custom state of 5 (cancelled). */ dispose() { - if (this.readyState !== ReadyStates.DONE) { - this.readyState = ReadyStates.CANCELLED; + if (this.readyState !== ReadyStates.Done) { + this.readyState = ReadyStates.Cancelled; } } @@ -62,10 +62,10 @@ export class MockConnection implements Connection { * */ mockRespond(res: Response) { - if (this.readyState === ReadyStates.DONE || this.readyState === ReadyStates.CANCELLED) { + if (this.readyState === ReadyStates.Done || this.readyState === ReadyStates.Cancelled) { throw new BaseException('Connection has already been resolved'); } - this.readyState = ReadyStates.DONE; + this.readyState = ReadyStates.Done; ObservableWrapper.callNext(this.response, res); ObservableWrapper.callReturn(this.response); } @@ -91,7 +91,7 @@ export class MockConnection implements Connection { */ mockError(err?: Error) { // Matches XHR semantics - this.readyState = ReadyStates.DONE; + this.readyState = ReadyStates.Done; ObservableWrapper.callThrow(this.response, err); ObservableWrapper.callReturn(this.response); } diff --git a/modules/angular2/src/http/backends/xhr_backend.ts b/modules/angular2/src/http/backends/xhr_backend.ts index 70128e76c3..75f8ade07e 100644 --- a/modules/angular2/src/http/backends/xhr_backend.ts +++ b/modules/angular2/src/http/backends/xhr_backend.ts @@ -31,7 +31,7 @@ export class XHRConnection implements Connection { this.response = new EventEmitter(); this._xhr = browserXHR.build(); // TODO(jeffbcross): implement error listening/propagation - this._xhr.open(RequestMethods[req.method], req.url); + this._xhr.open(RequestMethods[req.method].toUpperCase(), req.url); this._xhr.addEventListener('load', (_) => { // responseText is the old-school way of retrieving response (supported by IE8 & 9) // response/responseType properties were introduced in XHR Level2 spec (supported by IE10) diff --git a/modules/angular2/src/http/base_request_options.ts b/modules/angular2/src/http/base_request_options.ts index 53fb803a4a..5547a43fcb 100644 --- a/modules/angular2/src/http/base_request_options.ts +++ b/modules/angular2/src/http/base_request_options.ts @@ -92,6 +92,6 @@ export class RequestOptions { @Injectable() export class BaseRequestOptions extends RequestOptions { constructor() { - super({method: RequestMethods.GET, headers: new Headers(), mode: RequestModesOpts.Cors}); + super({method: RequestMethods.Get, headers: new Headers(), mode: RequestModesOpts.Cors}); } } diff --git a/modules/angular2/src/http/enums.ts b/modules/angular2/src/http/enums.ts index 1e0183ba66..b6ef3da811 100644 --- a/modules/angular2/src/http/enums.ts +++ b/modules/angular2/src/http/enums.ts @@ -37,13 +37,13 @@ export enum RequestCredentialsOpts { * Supported http methods. */ export enum RequestMethods { - GET, - POST, - PUT, - DELETE, - OPTIONS, - HEAD, - PATCH + Get, + Post, + Put, + Delete, + Options, + Head, + Patch } /** @@ -52,12 +52,12 @@ export enum RequestMethods { * additional "CANCELLED" state. */ export enum ReadyStates { - UNSENT, - OPEN, - HEADERS_RECEIVED, - LOADING, - DONE, - CANCELLED + Unsent, + Open, + HeadersReceived, + Loading, + Done, + Cancelled } /** diff --git a/modules/angular2/src/http/http.ts b/modules/angular2/src/http/http.ts index ee010d71ba..f54c73ba5d 100644 --- a/modules/angular2/src/http/http.ts +++ b/modules/angular2/src/http/http.ts @@ -116,7 +116,7 @@ export class Http { if (isString(url)) { responseObservable = httpRequest( this._backend, - new Request(mergeOptions(this._defaultOptions, options, RequestMethods.GET, url))); + new Request(mergeOptions(this._defaultOptions, options, RequestMethods.Get, url))); } else if (url instanceof Request) { responseObservable = httpRequest(this._backend, url); } @@ -128,7 +128,7 @@ export class Http { */ get(url: string, options?: RequestOptionsArgs): EventEmitter { return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, - RequestMethods.GET, url))); + RequestMethods.Get, url))); } /** @@ -138,7 +138,7 @@ export class Http { return httpRequest( this._backend, new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})), - options, RequestMethods.POST, url))); + options, RequestMethods.Post, url))); } /** @@ -148,7 +148,7 @@ export class Http { return httpRequest( this._backend, new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})), - options, RequestMethods.PUT, url))); + options, RequestMethods.Put, url))); } /** @@ -156,7 +156,7 @@ export class Http { */ delete (url: string, options?: RequestOptionsArgs): EventEmitter { return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, - RequestMethods.DELETE, url))); + RequestMethods.Delete, url))); } /** @@ -166,7 +166,7 @@ export class Http { return httpRequest( this._backend, new Request(mergeOptions(this._defaultOptions.merge(new RequestOptions({body: body})), - options, RequestMethods.PATCH, url))); + options, RequestMethods.Patch, url))); } /** @@ -174,7 +174,7 @@ export class Http { */ head(url: string, options?: RequestOptionsArgs): EventEmitter { return httpRequest(this._backend, new Request(mergeOptions(this._defaultOptions, options, - RequestMethods.HEAD, url))); + RequestMethods.Head, url))); } } @@ -193,10 +193,10 @@ export class Jsonp extends Http { request(url: string | Request, options?: RequestOptionsArgs): EventEmitter { var responseObservable: EventEmitter; if (isString(url)) { - url = new Request(mergeOptions(this._defaultOptions, options, RequestMethods.GET, url)); + url = new Request(mergeOptions(this._defaultOptions, options, RequestMethods.Get, url)); } if (url instanceof Request) { - if (url.method !== RequestMethods.GET) { + if (url.method !== RequestMethods.Get) { makeTypeError('JSONP requests must use GET request method.'); } responseObservable = httpRequest(this._backend, url); diff --git a/modules/angular2/test/core/change_detection/coalesce_spec.ts b/modules/angular2/test/core/change_detection/coalesce_spec.ts index 58f5ab474a..b3f2f3c4c4 100644 --- a/modules/angular2/test/core/change_detection/coalesce_spec.ts +++ b/modules/angular2/test/core/change_detection/coalesce_spec.ts @@ -15,7 +15,7 @@ export function main() { argumentToPureFunction?: boolean } = {}) { if (isBlank(lastInBinding)) lastInBinding = false; - if (isBlank(mode)) mode = RecordType.PROPERTY_READ; + if (isBlank(mode)) mode = RecordType.PropertyRead; if (isBlank(name)) name = "name"; if (isBlank(directiveIndex)) directiveIndex = null; if (isBlank(argumentToPureFunction)) argumentToPureFunction = false; @@ -62,7 +62,7 @@ export function main() { var rs = coalesce( [r("user", [], 0, 1, {lastInBinding: true}), r("user", [], 0, 2, {lastInBinding: true})]); - expect(rs[1]).toEqual(new ProtoRecord(RecordType.SELF, "self", null, [], null, 1, null, 2, + expect(rs[1]).toEqual(new ProtoRecord(RecordType.Self, "self", null, [], null, 1, null, 2, null, true, false, false, false, 0)); }); @@ -75,8 +75,8 @@ export function main() { it("should not coalesce directive lifecycle records", () => { var rs = coalesce([ - r("onCheck", [], 0, 1, {mode: RecordType.DIRECTIVE_LIFECYCLE}), - r("onCheck", [], 0, 1, {mode: RecordType.DIRECTIVE_LIFECYCLE}) + r("onCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle}), + r("onCheck", [], 0, 1, {mode: RecordType.DirectiveLifecycle}) ]); expect(rs.length).toEqual(2); diff --git a/modules/angular2/test/core/change_detection/proto_record_spec.ts b/modules/angular2/test/core/change_detection/proto_record_spec.ts index 51e931e595..cfda653774 100644 --- a/modules/angular2/test/core/change_detection/proto_record_spec.ts +++ b/modules/angular2/test/core/change_detection/proto_record_spec.ts @@ -14,7 +14,7 @@ export function main() { referencedBySelf?: boolean } = {}) { if (isBlank(lastInBinding)) lastInBinding = false; - if (isBlank(mode)) mode = RecordType.PROPERTY_READ; + if (isBlank(mode)) mode = RecordType.PropertyRead; if (isBlank(name)) name = "name"; if (isBlank(directiveIndex)) directiveIndex = null; if (isBlank(argumentToPureFunction)) argumentToPureFunction = false; @@ -26,21 +26,20 @@ export function main() { describe("ProtoRecord", () => { describe('shouldBeChecked', () => { - it('should be true for pure functions', () => { - expect(r({mode: RecordType.COLLECTION_LITERAL}).shouldBeChecked()).toBeTruthy(); - }); + it('should be true for pure functions', + () => { expect(r({mode: RecordType.CollectionLiteral}).shouldBeChecked()).toBeTruthy(); }); it('should be true for args of pure functions', () => { - expect(r({mode: RecordType.CONST, argumentToPureFunction: true}).shouldBeChecked()) + expect(r({mode: RecordType.Const, argumentToPureFunction: true}).shouldBeChecked()) .toBeTruthy(); }); it('should be true for last in binding records', () => { - expect(r({mode: RecordType.CONST, lastInBinding: true}).shouldBeChecked()).toBeTruthy(); + expect(r({mode: RecordType.Const, lastInBinding: true}).shouldBeChecked()).toBeTruthy(); }); it('should be false otherwise', - () => { expect(r({mode: RecordType.CONST}).shouldBeChecked()).toBeFalsy(); }); + () => { expect(r({mode: RecordType.Const}).shouldBeChecked()).toBeFalsy(); }); }); describe('isUsedByOtherRecord', () => { diff --git a/modules/angular2/test/http/backends/jsonp_backend_spec.ts b/modules/angular2/test/http/backends/jsonp_backend_spec.ts index 603bb74235..ba6f397047 100644 --- a/modules/angular2/test/http/backends/jsonp_backend_spec.ts +++ b/modules/angular2/test/http/backends/jsonp_backend_spec.ts @@ -106,7 +106,7 @@ export function main() { ObservableWrapper.subscribe(connection.response, loadSpy, errorSpy, returnSpy); connection.dispose(); - expect(connection.readyState).toBe(ReadyStates.CANCELLED); + expect(connection.readyState).toBe(ReadyStates.Cancelled); connection.finished('Fake data'); existingScripts[0].dispatchEvent('load'); @@ -153,8 +153,8 @@ export function main() { })); it('should throw if request method is not GET', () => { - [RequestMethods.POST, RequestMethods.PUT, RequestMethods.DELETE, RequestMethods.OPTIONS, - RequestMethods.HEAD, RequestMethods.PATCH] + [RequestMethods.Post, RequestMethods.Put, RequestMethods.Delete, RequestMethods.Options, + RequestMethods.Head, RequestMethods.Patch] .forEach(method => { let base = new BaseRequestOptions(); let req = new Request( diff --git a/modules/angular2/test/http/base_request_options_spec.ts b/modules/angular2/test/http/base_request_options_spec.ts index 5ef109579f..13144695bb 100644 --- a/modules/angular2/test/http/base_request_options_spec.ts +++ b/modules/angular2/test/http/base_request_options_spec.ts @@ -16,17 +16,17 @@ export function main() { describe('BaseRequestOptions', () => { it('should create a new object when calling merge', () => { var options1 = new BaseRequestOptions(); - var options2 = options1.merge(new RequestOptions({method: RequestMethods.DELETE})); + var options2 = options1.merge(new RequestOptions({method: RequestMethods.Delete})); expect(options2).not.toBe(options1); - expect(options2.method).toBe(RequestMethods.DELETE); + expect(options2.method).toBe(RequestMethods.Delete); }); it('should retain previously merged values when merging again', () => { var options1 = new BaseRequestOptions(); - var options2 = options1.merge(new RequestOptions({method: RequestMethods.DELETE})); + var options2 = options1.merge(new RequestOptions({method: RequestMethods.Delete})); var options3 = options2.merge(new RequestOptions({mode: RequestModesOpts.NoCors})); expect(options3.mode).toBe(RequestModesOpts.NoCors); - expect(options3.method).toBe(RequestMethods.DELETE); + expect(options3.method).toBe(RequestMethods.Delete); }); }); } diff --git a/modules/angular2/test/http/http_spec.ts b/modules/angular2/test/http/http_spec.ts index 21274f6a83..9b1484d4f5 100644 --- a/modules/angular2/test/http/http_spec.ts +++ b/modules/angular2/test/http/http_spec.ts @@ -166,7 +166,7 @@ export function main() { describe('.get()', () => { it('should perform a get request for given url', inject([AsyncTestCompleter], async => { ObservableWrapper.subscribe(backend.connections, c => { - expect(c.request.method).toBe(RequestMethods.GET); + expect(c.request.method).toBe(RequestMethods.Get); backend.resolveAllConnections(); async.done(); }); @@ -178,7 +178,7 @@ export function main() { describe('.post()', () => { it('should perform a post request for given url', inject([AsyncTestCompleter], async => { ObservableWrapper.subscribe(backend.connections, c => { - expect(c.request.method).toBe(RequestMethods.POST); + expect(c.request.method).toBe(RequestMethods.Post); backend.resolveAllConnections(); async.done(); }); @@ -201,7 +201,7 @@ export function main() { describe('.put()', () => { it('should perform a put request for given url', inject([AsyncTestCompleter], async => { ObservableWrapper.subscribe(backend.connections, c => { - expect(c.request.method).toBe(RequestMethods.PUT); + expect(c.request.method).toBe(RequestMethods.Put); backend.resolveAllConnections(); async.done(); }); @@ -223,7 +223,7 @@ export function main() { describe('.delete()', () => { it('should perform a delete request for given url', inject([AsyncTestCompleter], async => { ObservableWrapper.subscribe(backend.connections, c => { - expect(c.request.method).toBe(RequestMethods.DELETE); + expect(c.request.method).toBe(RequestMethods.Delete); backend.resolveAllConnections(); async.done(); }); @@ -235,7 +235,7 @@ export function main() { describe('.patch()', () => { it('should perform a patch request for given url', inject([AsyncTestCompleter], async => { ObservableWrapper.subscribe(backend.connections, c => { - expect(c.request.method).toBe(RequestMethods.PATCH); + expect(c.request.method).toBe(RequestMethods.Patch); backend.resolveAllConnections(); async.done(); }); @@ -257,7 +257,7 @@ export function main() { describe('.head()', () => { it('should perform a head request for given url', inject([AsyncTestCompleter], async => { ObservableWrapper.subscribe(backend.connections, c => { - expect(c.request.method).toBe(RequestMethods.HEAD); + expect(c.request.method).toBe(RequestMethods.Head); backend.resolveAllConnections(); async.done(); }); diff --git a/protractor-shared.js b/protractor-shared.js index 490c7ddf16..0868529772 100644 --- a/protractor-shared.js +++ b/protractor-shared.js @@ -225,10 +225,8 @@ exports.createBenchpressRunner = function(options) { var bindings = [ benchpress.SeleniumWebDriverAdapter.PROTRACTOR_BINDINGS, benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']), - benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({ - 'lang': options.lang, - 'runId': runId - }), + benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION) + .toValue({'lang': options.lang, 'runId': runId}), benchpress.JsonFileReporter.BINDINGS, benchpress.bind(benchpress.JsonFileReporter.PATH).toValue(resultsFolder) ]; diff --git a/tools/broccoli/tree-differ.ts b/tools/broccoli/tree-differ.ts index 8e47162b9b..af3000670f 100644 --- a/tools/broccoli/tree-differ.ts +++ b/tools/broccoli/tree-differ.ts @@ -69,10 +69,10 @@ export class TreeDiffer { let relativeFilePath = path.relative(this.rootPath, absolutePath); switch (this.isFileDirty(absolutePath, pathStat)) { - case FileStatus.ADDED: + case FileStatus.Added: result.addedPaths.push(relativeFilePath); break; - case FileStatus.CHANGED: + case FileStatus.Changed: result.changedPaths.push(relativeFilePath); } } @@ -94,13 +94,13 @@ export class TreeDiffer { if (oldFingerprint === newFingerprint) { // nothing changed - return FileStatus.UNCHANGED; + return FileStatus.Unchanged; } - return FileStatus.CHANGED; + return FileStatus.Changed; } - return FileStatus.ADDED; + return FileStatus.Added; } @@ -170,7 +170,7 @@ function pad(value, length) { enum FileStatus { - ADDED, - UNCHANGED, - CHANGED + Added, + Unchanged, + Changed }