You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "mrj760 (via GitHub)" <gi...@apache.org> on 2025/05/07 19:17:06 UTC

[I] Refactoring class/record name duplicates switch "when" cases if the class/record is instantiated in those cases [netbeans]

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

   ### Apache NetBeans version
   
   Apache NetBeans 25
   
   ### What happened
   
   Pretty difficult to title this one or succinctly describe it. Easier to just look at the before/after...
   
   ...But basically if you have a switch case that uses "when" and there is an instantiation within it -- if you were to refactor the class name (of the thing being instantiated) the "when" clauses get duplicated.
   
   ### Language / Project Type / NetBeans Component
   
   Maven Application
   
   ### How to reproduce
   
   Example 1. Going to refactor A->B.
   
   Before:
   ```
   public class Test {
       record A() {
       }
   
       void method(Object o) {
           switch(o) {
               case Integer i when i == 0 -> {
                   var r = new A();
               }
               default -> {
               }
           }
       }
   }
   ```
   
   After:
   ```
   public class Test {
       record B() {
       }
   
       void method(Object o) {
           switch(o) {
               case Integer i when i == 0 when i == 0 -> {
                   var r = new B();
               }
               default -> {
               }
           }
       }
   }
   ```
   
   
   Example 2 _(Same process, but with some more conditions in the `when`)_:
   
   Before:
   ```
   public class Test {
       record A() {
       }
   
       void method(Object o) {
           switch(o) {
               case Integer i when i == 0 || i == 0
                                   || i == 0 -> {
                   var r = new A();
               }
               default -> {
               }
           }
       }
   }
   ```
   
   After:
   ```
   public class Test {
       record B() {
       }
   
       void method(Object o) {
           switch(o) {
               case Integer i when i == 0 || i == 0
                                   || i == 0 when i == 0 || i == 0
                                   || i == 0 -> {
                   var r = new B();
               }
               default -> {
               }
           }
       }
   }
   
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Win10
   
   ### JDK
   
   OpenJDK21
   
   ### Apache NetBeans packaging
   
   Apache NetBeans provided installer
   
   ### Anything else
   
   Just some lines from the IDE log that seemed relevant.
   Saw these after doing Undo for the refactor. 
   I deleted lines that seemed irrelevant.
   ```
   WARNING [null]: Last record repeated 2 more times.
   INFO [org.netbeans.modules.parsing.impl.TaskProcessor]: Task: org.netbeans.modules.java.editor.semantic.SemanticHighlighter@65fd803a : class org.netbeans.modules.java.editor.semantic.SemanticHighlighter ignored cancel for 102 ms.
   INFO [org.netbeans.modules.websvc.editor.hints.WebServicesRulesEngine]: Unknown element type: RECORD.
   INFO [org.netbeans.modules.refactoring.spi.impl.ParametersPanel]: org.netbeans.modules.refactoring.api.AbstractRefactoring$ProgressL@625e1119 called start multiple times
   INFO [null]: Last record repeated again.
   WARNING [null]: Last record repeated again.
   INFO [org.netbeans.modules.refactoring.spi.impl.ParametersPanel]: org.netbeans.modules.refactoring.api.RefactoringSession@424ae5ef called start multiple times
   INFO [org.netbeans.modules.websvc.editor.hints.WebServicesRulesEngine]: Unknown element type: RECORD.
   WARNING [null]: Last record repeated again.
   INFO [org.netbeans.modules.websvc.editor.hints.WebServicesRulesEngine]: Unknown element type: RECORD.
   WARNING [null]: Last record repeated again.
   INFO [org.netbeans.modules.websvc.editor.hints.WebServicesRulesEngine]: Unknown element type: RECORD.
   INFO [org.netbeans.modules.websvc.editor.hints.WebServicesRulesEngine]: Unknown element type: RECORD.
   ```
   
   ### 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: notifications-unsubscribe@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


Re: [I] Refactoring class/record name duplicates switch "when" cases if the class/record is instantiated in those cases [netbeans]

Posted by "homberghp (via GitHub)" <gi...@apache.org>.
homberghp commented on issue #8495:
URL: https://github.com/apache/netbeans/issues/8495#issuecomment-2970690393

   Most likely the issue is in CausalDiff.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


Re: [I] Refactoring class/record name duplicates switch "when" cases if the class/record is instantiated in those cases [netbeans]

Posted by "homberghp (via GitHub)" <gi...@apache.org>.
homberghp commented on issue #8495:
URL: https://github.com/apache/netbeans/issues/8495#issuecomment-2969876956

   I would like to pick this one up. It may be related to similar things as in #7044 


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


Re: [I] Refactoring class/record name duplicates switch "when" cases if the class/record is instantiated in those cases [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien closed issue #8495: Refactoring class/record name duplicates switch "when" cases if the class/record is instantiated in those cases
URL: https://github.com/apache/netbeans/issues/8495


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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