DongChunHao opened a new issue, #7290:
URL: https://github.com/apache/netbeans/issues/7290

   ### Apache NetBeans version
   
   Apache NetBeans 21
   
   ### What happened
   
   When I select the code snippet "switch (value) { .... } return result;" and 
perform the extract method refactoring, the new method name is "newMethod" and 
I click "OK":
   
   class ExtractMethodTest {
       private final int value;
   
       public ExtractMethodTest(int value) {
           this.value = value;
       }
   
       public synchronized int calculate() {
           int result;
           switch (value) {
               case 1:
                   result = value * 2;
                   break;
               case 2:
                   result = value * 3;
                   break;
               default:
                   result = value * 4;
                   break;
           }
           return result;
       }
   }
   
   after refactoring result:
   
![image](https://github.com/apache/netbeans/assets/77560508/212e90db-b48e-409d-aaa8-5cf963af5947)
   
   In the refactored code, a new local variable named "result" was added, but 
when using the inline method again for refactoring, it may not be completely 
consistent with the original code。
   
   ### Language / Project Type / NetBeans Component
   
   _No response_
   
   ### How to reproduce
   
   Perform the following actions on the following code:
   
   selecet “switch (value) { .... } return result;”
   click “Refactor-Introduce-Method”
   new name "newMethod"
   click “ok”
   
   class ExtractMethodTest {
       private final int value;
   
       public ExtractMethodTest(int value) {
           this.value = value;
       }
   
       public synchronized int calculate() {
           int result;
          // extract method 
           switch (value) {
               case 1:
                   result = value * 2;
                   break;
               case 2:
                   result = value * 3;
                   break;
               default:
                   result = value * 4;
                   break;
           }
           return result;
       // end
       }
   }
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows11
   
   ### JDK
   
   20
   
   ### Apache NetBeans packaging
   
   Apache NetBeans platform
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to