Index: NaiveASTFlattener.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/dom/NaiveASTFlattener.java,v retrieving revision 1.11 diff -u -r1.11 NaiveASTFlattener.java --- NaiveASTFlattener.java 30 Apr 2008 21:32:15 -0000 1.11 +++ NaiveASTFlattener.java 6 May 2008 15:16:01 -0000 @@ -285,7 +285,8 @@ this.buffer.append("{\n");//$NON-NLS-1$ this.indent++; for (Iterator it = node.statements().iterator(); it.hasNext(); ) { - Statement s = (Statement) it.next(); + // fix for inner function handling, Etienne Pfister + ASTNode s = (ASTNode) it.next(); s.accept(this); } this.indent--; Index: ASTNode.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/dom/ASTNode.java,v retrieving revision 1.10 diff -u -r1.10 ASTNode.java --- ASTNode.java 30 Apr 2008 21:32:16 -0000 1.10 +++ ASTNode.java 6 May 2008 15:16:00 -0000 @@ -1902,7 +1902,11 @@ Class childClass = newChild.getClass(); if (nodeType != null && !nodeType.isAssignableFrom(childClass)) { // new child is not of the right type - throw new ClassCastException(); + + // fix for inner function handling, Etienne Pfister + if(!(newChild instanceof org.eclipse.wst.jsdt.core.dom.FunctionDeclaration)) { + throw new ClassCastException(); + } } if ((newChild.typeAndFlags & PROTECT) != 0) { // new child node is protected => cannot be parented Index: ASTConverter.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/core/dom/ASTConverter.java,v retrieving revision 1.18 diff -u -r1.18 ASTConverter.java --- ASTConverter.java 30 Apr 2008 21:32:15 -0000 1.18 +++ ASTConverter.java 6 May 2008 15:16:00 -0000 @@ -518,7 +518,11 @@ for (int i = 0; i < statementsLength; i++) { if (statements[i] instanceof org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration) { checkAndAddMultipleLocalDeclaration(statements, i, block.statements()); - } else { + } else if (statements[i] instanceof org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration) { // fix for inner function handling, Etienne Pfister + org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration method = (org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration) statements[i]; + block.statements().add(convert(method)); + } + else { final Statement statement = convert(statements[i]); if (statement != null) { block.statements().add(statement);