Skip to content

Commit

Permalink
Fix increment serialization #71
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Jan 26, 2014
1 parent 8a08e40 commit 1995173
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scalagen/src/main/scala/com/mysema/scalagen/ScalaDumpVisitor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -856,12 +856,26 @@ class ScalaDumpVisitor(settings: ConversionSettings) extends VoidVisitor[ScalaDu
// case Op.preDecrement => "-= 1"
case _ => ""
})
if (n.getOperator == Op.posIncrement || n.getOperator == Op.posDecrement) {
printer.print("{")
}
n.getExpr.accept(this, arg)
printer.print(n.getOperator match {
case Op.posIncrement => " += 1"
case Op.posDecrement => " -= 1"
case _ => ""
})
if (n.getOperator == Op.posIncrement || n.getOperator == Op.posDecrement) {
printer.print("; ")
n.getExpr.accept(this, arg)
printer.print(n.getOperator match {
case Op.posIncrement => " - 1"
case Op.posDecrement => " + 1"
case _ => ""
})
printer.print("}")
}

}

def visit(n: ConstructorDeclaration, arg: Context) {
Expand Down
13 changes: 13 additions & 0 deletions scalagen/src/test/scala/com/mysema/examples/Increment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mysema.examples;

public class Increment {

public void doSomething() {
int i = 0;
int[] ints = new int[10];
while (i < 10) {
System.out.println(ints[i++]);
}
}

}

0 comments on commit 1995173

Please sign in to comment.