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.
Created attachment 152461 [details] wrong refactor invocation Product Version: NetBeans IDE Dev (Build 201503060001) Java: 1.8.0_40; Java HotSpot(TM) 64-Bit Server VM 25.40-b25 Runtime: Java(TM) SE Runtime Environment 1.8.0_40-b25 System: Linux version 3.16.0-31-generic running on amd64; UTF-8; en_US (nb) Given (rest assured library) new RequestSpecBuilder().setContentType("application/json").build(); new ResponseSpecBuilder().expectContentType("application/json").build(); <CURSOR> When invocing alt-enter, 'assign return value to new variable' the 'build()' method name in the line above is tried to be refactored. See attached video for details.
This does not happen when using the hint in the upper line. When the upper line has already a return variable and trying on the lower line the error happens as well.
The culprit is the auto-import feature during code generation; imports are processed after the rewritten trees are processed and their positions stored. But imports textually precede the rewritten text, so positions should be shifted (they are not). Similar situations may occur when replacing strings in comments. Reordering the processing will not help: diffs of rewritten trees are computed against original source, NOT source after import mods. positions read from tree tags were not correct in such situations - and in the case of assign return value hint led to (attempt of) selection of an incorrect identifier (build() method name instead of build variable) cc:ing refactoring owner - implied defects may be reported against refactoring module. will be fixed as jet-main#9465ab93e9cc
Integrated into 'main-silver', will be available in build *201508110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/9465ab93e9cc User: Svata Dedic <sdedic@netbeans.org> Log: #250989: tagged tree offsets adjusted to respect autoimports and textual changes