mbien commented on code in PR #7670:
URL: https://github.com/apache/netbeans/pull/7670#discussion_r1720570335


##########
java/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java:
##########
@@ -450,6 +450,10 @@ private static boolean allowInstantRename(CompilationInfo 
info, Element e, Eleme
             if(isProperty) {
                 return false;
             }
+            boolean isRecordComponent = e.getEnclosingElement().getKind() == 
ElementKind.RECORD;
+            if (isRecordComponent) {
+                return false;
+            }
         }

Review Comment:
   this is for component accessor methods (L457):
   ```java
           } else if (e.getKind() == ElementKind.METHOD) {
               Element ee = e.getEnclosingElement();
               if (ee.getKind() == ElementKind.RECORD) {
                   for (RecordComponentElement rc : ((TypeElement) 
ee).getRecordComponents()) {
                       if (e.getSimpleName().equals(rc.getSimpleName())) {
                           return false;
                       }
                   }
               }
           }
   ```



##########
java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java:
##########
@@ -433,6 +438,27 @@ public void run(CompilationController info) throws 
Exception {
                                     //add all references of overriding methods
                                     
allMethods.add(ElementHandle.create((ExecutableElement)el));
                                 }
+                                if (kind == ElementKind.FIELD && 
el.getEnclosingElement().getKind() == ElementKind.RECORD) {
+                                    for (ExecutableElement m : 
ElementFilter.methodsIn(el.getEnclosingElement().getEnclosedElements())) {
+                                        if 
(m.getSimpleName().equals(el.getSimpleName()) && m.getParameters().isEmpty()) {
+                                            //accessor:
+//                                            addMethods(m, set, info, idx);
+                                            
recordLinkedDeclarations.add(TreePathHandle.create(m, info));
+                                            addUsesOfMethod(m, set, info, idx);
+                                        }
+                                    }
+                                    for (ExecutableElement c : 
ElementFilter.constructorsIn(el.getEnclosingElement().getEnclosedElements())) {
+                                        if 
(!info.getElements().isCanonicalConstructor(c)) {
+                                            continue;
+                                        }
+                                        for (VariableElement param : 
c.getParameters()) {
+                                            if 
(param.getSimpleName().equals(el.getSimpleName())) {
+                                                //the parameter for the 
canonical constructor:
+                                                
recordLinkedDeclarations.add(TreePathHandle.create(param, info));
+                                            }
+                                        }
+                                    }
+                                }

Review Comment:
   L467 below would need the reverse case for renaming a record accessor which 
would have to be linked to the comonents i believe.



-- 
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