chore: Make enum names consistent with TypeScript convention
BREAKING_CHANGE Ts2Dart issue: https://github.com/angular/ts2dart/issues/270 TypeScript convention: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines DartConvertion: https://www.dartlang.org/articles/style-guide/ Rename: - NumberFormatStyle.DECIMAL => NumberFormatStyle.Decimal - NumberFormatStyle.PERCENT => NumberFormatStyle.Percent - NumberFormatStyle.CURRENCY => NumberFormatStyle.Currency - RequestMethods.GET => RequestMethods.Get - RequestMethods.POST => RequestMethods.Post - RequestMethods.PUT => RequestMethods.Put - RequestMethods.DELETE => RequestMethods.Delete - RequestMethods.HEAD => RequestMethods.Head - RequestMethods.PATCH => RequestMethods.Patch - ReadyStates.UNSENT => ReadyStates.Unsent - ReadyStates.OPEN => ReadyStates.Open - ReadyStates.HEADERS_RECEIVED => ReadyStates.HeadersReceived - ReadyStates.LOADING => ReadyStates.Loading - ReadyStates.DONE => ReadyStates.Done - ReadyStates.CANCELLED => ReadyStates.Canceled
This commit is contained in:
@ -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<ProtoRecord>) {
|
||||
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));
|
||||
|
@ -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;
|
||||
|
||||
|
@ -252,42 +252,42 @@ export class DynamicChangeDetector extends AbstractChangeDetector<any> {
|
||||
|
||||
_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<any> {
|
||||
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:
|
||||
|
@ -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;
|
||||
|
@ -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'); }
|
||||
|
@ -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; }
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<any>): 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);
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user