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.

Bug 239592

Summary: [Add return statement] hint should return appropriate variable if it exists
Product: java Reporter: ssazonov
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal CC: markiewb
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description ssazonov 2013-12-18 09:09:31 UTC
1. create simple java class:

package test;

import java.awt.Color;
import javax.swing.JButton;

public class ClassA {

    public JButton getInstance(String text) {
        JButton button = new JButton();
        button.setText(text);
        button.setBackground(Color.ORANGE);
    }
}

2. Click the "Add return statement" hint in front of "public JButton getInstance(String text){...}"

>> return statement "return null;" has been added

I think it may be useful to retur appropriate variable if it exists, in this case it is "return button;"

Product Version: NetBeans IDE Dev (Build 201312110002)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 1 Svata Dedic 2015-10-02 16:34:09 UTC
Could be useful. There are two possibilities:
1/ implement support similar to in-place rename, but oferring a dropdown with choices; offer the neutral value and then possible variables.
2/ offer two fix variants for applicable variables.
Comment 2 markiewb 2015-10-02 18:48:02 UTC
(In reply to Svata Dedic from comment #1)
> Could be useful. There are two possibilities:
> 1/ implement support similar to in-place rename, but oferring a dropdown

+1 IMHO That would be better. Such a dropdown could also be used for code templates, where you can define a static set of possible entries. Or for other inplace code completions.