Bug 200222

Summary: Provide Refactoring if return statement changes
Product: java Reporter: nigjo_iqn
Component: HintsAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED FIXED QA Contact: issues <issues.netbeans.org>
Priority: P3    
Version: 7.0   
Target Milestone: 7.1   
Hardware: PC   
OS: Windows XP   
Issue Type: ENHANCEMENT Exception Report:

Description nigjo_iqn 2011-07-19 07:55:23 UTC
When I (accidentally) create a method like this:

  public void getValue(){
    // do some stuff

I realize that I missed the return type and statement. If I add this return statement, 
  public void getValue(){
    // do some stuff
    return 42;
NetBeans only shows an error "cannot return a value from method whose result type is void".

It would be nice to provide a refactoring hint: "You typed a return statement which doesn't match the current return type. Should I
a) remove this return statement, or
b) change the return type"
Comment 1 Jan Lahoda 2011-07-26 19:20:09 UTC
Comment 2 Quality Engineering 2011-07-27 14:10:28 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/11e0fa752767
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #200222: Provide Refactoring if return statement changes
Comment 3 doubleCortado 2011-11-08 12:35:04 UTC
Hi. Great new feature.
A couple of suggestion. How about having the option to modify the return type to void of no returns are specified?

Also, when implementing a method which overrides a superclass og implements an interface, how about getting the option to modify the signature of the overridden method?
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo