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.
Replace with StringBuilder hint removes user inline comment Steps to reproduce: 1) have a code: StringBuffer s = new StringBuffer(x); //Hint: Replace with StringBuilder 2) apply hint StringBuilder s = new StringBuilder(x); -> comment is removed Product Version: NetBeans IDE Dev (Build 201308042300) Java: 1.8.0-ea; Java HotSpot(TM) 64-Bit Server VM 25.0-b40 Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b98 System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb) User directory: C:\Users\jprox\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\jprox\AppData\Local\NetBeans\Cache\dev
Uses RewriteFix. Fixed in http://hg.netbeans.org/jet-main/rev/c6f518969ecb
Unfortunately I can still reproduce this problem. But now it happens only sometimes (about 50%). I guess it happens after another change in editor (e.g. user types and the quickly invokes the hint), but I have no reliable steps. Product Version: NetBeans IDE Dev (Build 20131202-95d36d354e99) Updates: Updates available Java: 1.8.0-ea; Java HotSpot(TM) 64-Bit Server VM 25.0-b49 Runtime: Java(TM) SE Runtime Environment 1.8.0-ea-b107 System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb) User directory: C:\Users\jprox\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\jprox\AppData\Local\NetBeans\Cache\dev
The reason for randomness of the defect is that Trees to be rewritten are put into IdentityHashMap; the Map is then iterated and in each iteration one place is rewritten with the replacement. The Fix implementation records a replacement of the matched Tree with the template, then records replacements of individual placeholders in the template. When iterating and doing actual replace AND copying comments, the original order of incremental rewrites is not preserved, so it may be possible that a comment is copied out of a newly created Tree 'x' earlier than the x rewrites original Tree absorbing its comments. The iteration order depends on object identity (assuming memory location) and is unpredictable. This potentially affects more refactorings that use JavaFixUtilities.rewriteFix, so the priority should be increased - but only comments are affected. As all the rewrites are collected and processed at the end, code output should be always the same. Should be fixed by http://hg.netbeans.org/jet-main/rev/8c4e76914f62
verified in trunk
Integrated into 'main-silver', will be available in build *201312080002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/8c4e76914f62 User: Svata Dedic <sdedic@netbeans.org> Log: #234134: rewrites are ordered so that comment propagate to the surviving Trees
Grafted into 7.4 as #a074fb70b808
Integrated into 'releases/release74', will be available in build *201403261440* or newer. Wait for official and publicly available build. Changeset: http://hg.netbeans.org/releases/rev/4d90f068f418 User: Svata Dedic <sdedic@netbeans.org> Log: #237313, #234134: rewrite fix preserves comments for (only!) the replaced nodes