Skip to content

Commit

Permalink
chore: Make enum names consistent with TypeScript convention
Browse files Browse the repository at this point in the history
BREAKING_CHANGE

Ts2Dart issue: dart-archive/ts2dart#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
  • Loading branch information
mhevery committed Aug 26, 2015
1 parent 6f040cd commit e434f94
Show file tree
Hide file tree
Showing 22 changed files with 205 additions and 208 deletions.
4 changes: 2 additions & 2 deletions modules/angular2/src/core/change_detection/coalesce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
30 changes: 15 additions & 15 deletions modules/angular2/src/core/change_detection/codegen_logic_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,64 +252,64 @@ 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;
}
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:
Expand Down
64 changes: 32 additions & 32 deletions modules/angular2/src/core/change_detection/parser/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit e434f94

Please sign in to comment.