Skip to content

Commit

Permalink
!= -> !==
Browse files Browse the repository at this point in the history
  • Loading branch information
rzymek committed May 21, 2013
1 parent 8709c7c commit 09ac42e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/org/eclipse/xtend/java2xtend/ConvertingVisitor.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,10 @@ class ConvertingVisitor extends ASTVisitor {

override visit(InfixExpression exp) {
switch exp.operator {
case InfixExpression$Operator::EQUALS: {
val op = '==='
val newInfix = new CustomInfixExpression(exp.AST, op)
newInfix.leftOperand = exp.leftOperand.copy
newInfix.rightOperand = exp.rightOperand.copy
replaceNode(exp, newInfix)
}
case InfixExpression$Operator::EQUALS:
replaceOp(exp, '===')
case InfixExpression$Operator::NOT_EQUALS:
replaceOp(exp, '!==')
case InfixExpression$Operator::AND:
replaceOpWithMethod(exp, 'bitwiseAnd')
case InfixExpression$Operator::OR:
Expand All @@ -143,6 +140,13 @@ class ConvertingVisitor extends ASTVisitor {
true
}

private def replaceOp(InfixExpression exp, String op) {
val newInfix = new CustomInfixExpression(exp.AST, op)
newInfix.leftOperand = exp.leftOperand.copy
newInfix.rightOperand = exp.rightOperand.copy
replaceNode(exp, newInfix)
}

private def replaceOpWithMethod(InfixExpression exp, String name) {
val newNode = exp.AST.newMethodInvocation => [m|
m.expression = exp.leftOperand.copy
Expand Down

0 comments on commit 09ac42e

Please sign in to comment.