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:
Misko Hevery
2015-08-26 13:40:12 -07:00
parent 465f7c95b0
commit 37b042b361
23 changed files with 206 additions and 209 deletions

View File

@ -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));

View File

@ -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;

View File

@ -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:

View File

@ -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;

View File

@ -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'); }

View File

@ -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; }
}