This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
consider the following use case. I created a data object from template with default constructor, then generated test methods, based on the test methods generated i generated one more method required by the testing framework and attempted to modify the constructor body to reflect the number of test methods generated (also required by the framework), this messed up all of the code previously generated. The code that causes this String consBody="{\nsuper("+nTests+",\"clsTree.getSimpleName()+"\n);\n}\n"; BlockTree oldBlock=constructorMethod.getBody(); TreeUtilities treeUtils=workingCopy.getTreeUtilities(); Tree newBlock=treeUtils.parseStatement(consBody, new SourcePositions[1]); assert Tree.Kind.BLOCK == newBlock.getKind(); workingCopy.rewrite(oldBlock,newBlock); I have tracked this down to WorkingCopy.rewrite(old,new) and at that point everything was ok, not sure where after that it got jumbled. Stack trace is attched.
Created attachment 39487 [details] stack trace
Created attachment 39582 [details] Patch
Please, check if it is reproducible with provided patch. Thanks.
Test case added. -- The test modifies constructor body and adds new method to the end of a class in one modification task. Recently I have made changes which causes that issue is no longer reproducible (considering that my testcase follows your use case). Please, check that it works for you. If not, provide your modification scenario. Thanks. Checking in unit/src/org/netbeans/api/java/source/gen/ClassMemberTest.java; /cvs/java/source/test/unit/src/org/netbeans/api/java/source/gen/ClassMemberTest.java,v <-- ClassMemberTest.java new revision: 1.17; previous revision: 1.16 done
that fixed it