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.
When I rewrite a CaseTree using the following statements, I will get a wrong result. CaseTree original = (CaseTree) node; List<StatementTree> st = new ArrayList<StatementTree>(); st.addAll(original.getStatements()); st.add(make.Break(null)); modified = make.Case(original.getExpression(), st); System.out.println("original: " + node); System.out.println("modified: " + modified); wc.rewrite(node, modified); Input: void m(int p) { switch (p) { case 0: } } Wrong output: void m(int p) { switch (p) { case 0break ; : } } The problem is probably in the rewrite method because the trees are right before the rewriting. Log: original: case 0: modified: case 0: break ;
.
I'd like to NetFIX [1] this bug. Is it possible? [1] http://wiki.netbeans.org/NetFIX
Notes from @jlahoda ============== Having a reproducible test case, this should not be very hard to fix. Most likely a bug in the code generator. Bugs in code generator are typically fixed as follows: - add one or more tests into the generator test suite (package org.netbeans.api.java.source.gen in java.source's tests). - fix the problem, so that the test passes. - run whole codegen test suite by executing "ant -Dtest.config=generator test" inside java.source module. All tests must pass (this test suite is being run during the jet-main continuous build, so all tests should be passing).
@jlahoda... worth pointing out to others that TutorialTest has a lot of examples in it. I just stumbled across it!
Created attachment 81596 [details] failing test case
This is a pesky one! Lots of code that needs to be understood. I'm pretty sure the bug is in (or called from) CasualDiff.diff(Context, WorkingCopy, TreePath, JCTree, Map, Map, Map)
Created attachment 81830 [details] proposed bugfix and test case
@moonko I'm not 100% happy with this bug fix. It comprises:- - test case (now passes) - add empty do {} to while statements (to make it explicit that this is not a typo!) - the fix: add a tokenSequence.moveNext() to diffCase following the iteration to COLON The reason I am not happy is that the whitespace is not coming out right. I expect a space to be entered between the "case:break;" and no newline afterward. Please amend the testcase if you wish to also test this.
Patch accepted. jet-main #c77f10c5666e
Integrated into 'main-golden', will be available in build *200905120201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/c77f10c5666e User: Rastislav Komara <moonko@netbeans.org> Log: #158129: Error in rewriting of CaseTree
Adding NETFIX keyword.