X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions modules/angular2/src/core/change_detection/parser/ast.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {isBlank, isPresent, FunctionWrapper} from "angular2/src/core/facade/lang";
import {Map, ListWrapper, StringMapWrapper} from "angular2/src/core/facade/collection";
import {ListWrapper} from "angular2/src/core/facade/collection";

export class AST {
visit(visitor: AstVisitor): any { return null; }
Expand Down Expand Up @@ -29,11 +28,6 @@ export class Conditional extends AST {
visit(visitor: AstVisitor): any { return visitor.visitConditional(this); }
}

export class If extends AST {
constructor(public condition: AST, public trueExp: AST, public falseExp?: AST) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitIf(this); }
}

export class PropertyRead extends AST {
constructor(public receiver: AST, public name: string, public getter: Function) { super(); }
visit(visitor: AstVisitor): any { return visitor.visitPropertyRead(this); }
Expand Down Expand Up @@ -133,7 +127,6 @@ export interface AstVisitor {
visitChain(ast: Chain): any;
visitConditional(ast: Conditional): any;
visitFunctionCall(ast: FunctionCall): any;
visitIf(ast: If): any;
visitImplicitReceiver(ast: ImplicitReceiver): any;
visitInterpolation(ast: Interpolation): any;
visitKeyedRead(ast: KeyedRead): any;
Expand Down Expand Up @@ -163,12 +156,6 @@ export class RecursiveAstVisitor implements AstVisitor {
ast.falseExp.visit(this);
return null;
}
visitIf(ast: If): any {
ast.condition.visit(this);
ast.trueExp.visit(this);
ast.falseExp.visit(this);
return null;
}
visitPipe(ast: BindingPipe): any {
ast.exp.visit(this);
this.visitAll(ast.args);
Expand Down Expand Up @@ -301,9 +288,4 @@ export class AstTransformer implements AstVisitor {
}

visitChain(ast: Chain): Chain { return new Chain(this.visitAll(ast.expressions)); }

visitIf(ast: If): If {
let falseExp = isPresent(ast.falseExp) ? ast.falseExp.visit(this) : null;
return new If(ast.condition.visit(this), ast.trueExp.visit(this), falseExp);
}
}
4 changes: 0 additions & 4 deletions modules/angular2/src/core/change_detection/parser/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export class Token {

isKeywordTrue(): boolean { return (this.type == TokenType.Keyword && this.strValue == "true"); }

isKeywordIf(): boolean { return (this.type == TokenType.Keyword && this.strValue == "if"); }

isKeywordElse(): boolean { return (this.type == TokenType.Keyword && this.strValue == "else"); }

isKeywordFalse(): boolean { return (this.type == TokenType.Keyword && this.strValue == "false"); }

toNumber(): number {
Expand Down
26 changes: 0 additions & 26 deletions modules/angular2/src/core/change_detection/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
Binary,
PrefixNot,
Conditional,
If,
BindingPipe,
Chain,
KeyedRead,
Expand Down Expand Up @@ -429,19 +428,6 @@ export class _ParseAST {
this.advance();
return new LiteralPrimitive(false);

} else if (this.parseAction && this.next.isKeywordIf()) {
this.advance();
this.expectCharacter($LPAREN);
let condition = this.parseExpression();
this.expectCharacter($RPAREN);
let ifExp = this.parseExpressionOrBlock();
let elseExp;
if (this.next.isKeywordElse()) {
this.advance();
elseExp = this.parseExpressionOrBlock();
}
return new If(condition, ifExp, elseExp);

} else if (this.optionalCharacter($LBRACKET)) {
var elements = this.parseExpressionList($RBRACKET);
this.expectCharacter($RBRACKET);
Expand Down Expand Up @@ -542,16 +528,6 @@ export class _ParseAST {
return positionals;
}

parseExpressionOrBlock(): AST {
if (this.optionalCharacter($LBRACE)) {
let block = this.parseBlockContent();
this.expectCharacter($RBRACE);
return block;
}

return this.parseExpression();
}

parseBlockContent(): AST {
if (!this.parseAction) {
this.error("Binding expression cannot contain chained expression");
Expand Down Expand Up @@ -688,6 +664,4 @@ class SimpleExpressionChecker implements AstVisitor {
}

visitChain(ast: Chain) { this.simple = false; }

visitIf(ast: If) { this.simple = false; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Binary,
Chain,
Conditional,
If,
BindingPipe,
FunctionCall,
ImplicitReceiver,
Expand Down Expand Up @@ -266,8 +265,6 @@ class _ConvertAstIntoProtoRecords implements AstVisitor {
return this._addRecord(RecordType.Chain, "chain", null, args, null, 0);
}

visitIf(ast: If) { throw new BaseException('Not supported'); }

_visitAll(asts: any[]) {
var res = ListWrapper.createFixedSize(asts.length);
for (var i = 0; i < asts.length; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,6 @@ export function main() {
});
});

describe("if", () => {
it('should parse if statements', () => {
checkAction("if (true) a = 0");
checkAction("if (true) {a = 0;}", "if (true) a = 0");
});
});

describe("assignment", () => {
it("should support field assignments", () => {
checkAction("a = 12");
Expand Down
19 changes: 0 additions & 19 deletions modules/angular2/test/core/change_detection/parser/unparser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Chain,
Conditional,
EmptyExpr,
If,
BindingPipe,
FunctionCall,
ImplicitReceiver,
Expand Down Expand Up @@ -70,17 +69,6 @@ export class Unparser implements AstVisitor {
this._visit(ast.falseExp);
}

visitIf(ast: If) {
this._expression += 'if (';
this._visit(ast.condition);
this._expression += ') ';
this._visitExpOrBlock(ast.trueExp);
if (isPresent(ast.falseExp)) {
this._expression += ' else ';
this._visitExpOrBlock(ast.falseExp);
}
}

visitPipe(ast: BindingPipe) {
this._expression += '(';
this._visit(ast.exp);
Expand Down Expand Up @@ -200,11 +188,4 @@ export class Unparser implements AstVisitor {
}

private _visit(ast: AST) { ast.visit(this); }

private _visitExpOrBlock(ast: AST) {
var isBlock = ast instanceof Chain || ast instanceof EmptyExpr;
if (isBlock) this._expression += '{ ';
this._visit(ast);
if (isBlock) this._expression += ' }';
}
}
X Tutup