Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

#40 Fix super invocation in initializer

  • Loading branch information...
commit 3ca0d80fcb5e7f31e50a89dd87e79f87144112c9 1 parent 3c8eea4
@timowest timowest authored
View
16 scalagen/src/main/scala/com/mysema/scalagen/Constructors.scala
@@ -58,12 +58,24 @@ class Constructors extends UnitTransformerBase {
processStatements(cu, t, c)
- if (!c.getBlock.isEmpty &&
+ if (!c.getBlock.isEmpty &&
!(c.getBlock.size == 1 && c.getBlock()(0).isInstanceOf[ConstructorInvocation] &&
!c.getBlock()(0).asInstanceOf[ConstructorInvocation].isThis())) {
val initializer = new Initializer(false, c.getBlock)
- t.getMembers.add(t.getMembers.indexOf(c), initializer)
+ t.getMembers.add(t.getMembers.indexOf(c), initializer)
+ }
+
+ /*val block = c.getBlock.copy()
+
+ if (!block.isEmpty
+ && block(0).isInstanceOf[ConstructorInvocation]
+ && !block(0).asInstanceOf[ConstructorInvocation].isThis) {
+ block.remove(block(0))
}
+ if (!block.isEmpty) {
+ val initializer = new Initializer(false, block)
+ t.getMembers.add(t.getMembers.indexOf(c), initializer)
+ }*/
}
// add missing delegations
View
9 scalagen/src/main/scala/com/mysema/scalagen/Helpers.scala
@@ -17,6 +17,7 @@ import java.lang.reflect.Modifier
import japa.parser.ast.body.ModifierSet
import _root_.scala.collection.JavaConversions
import _root_.scala.collection.Set
+import java.util.ArrayList
/**
* Common helper methods for transformers and ScalaDumpVisitor
@@ -85,6 +86,14 @@ trait Helpers {
def removeAll(s: List[Statement]) {
b.setStmts(b.getStmts -- s)
}
+ def copy(): Block = {
+ def block = new Block()
+ def stmts = new ArrayList[Statement]()
+ stmts.addAll(b.getStmts)
+ block.setStmts(stmts)
+ block
+ }
+
def size = if (b.getStmts != null) b.getStmts.size else 0
}
View
13 scalagen/src/main/scala/com/mysema/scalagen/ScalaDumpVisitor.scala
@@ -1166,11 +1166,14 @@ class ScalaDumpVisitor extends VoidVisitor[ScalaDumpVisitor.Context] with Helper
if (n.getBlock.getStmts != null) {
val i = n.getBlock.getStmts.iterator
while (i.hasNext) {
- i.next.accept(this, arg)
- if (i.hasNext) {
- printer.printLn()
- printer.printLn()
- }
+ val stmt = i.next()
+ if (!stmt.isInstanceOf[ExplicitConstructorInvocationStmt]) {
+ stmt.accept(this, arg)
+ if (i.hasNext) {
+ printer.printLn()
+ printer.printLn()
+ }
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.