mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace rename: prefer reference to be primary rename variable (DEA-100018)
(cherry picked from commit 56fafe3ecec9c3504e23b976633b7d05f83f53c9)
This commit is contained in:
+7
-2
@@ -268,11 +268,16 @@ public abstract class InplaceRefactoring {
|
||||
int offset = myEditor.getCaretModel().getOffset();
|
||||
PsiElement selectedElement = getSelectedInEditorElement(nameIdentifier, refs, stringUsages, offset);
|
||||
|
||||
if (nameIdentifier != null) addVariable(nameIdentifier, selectedElement, builder);
|
||||
boolean subrefOnPrimaryElement = false;
|
||||
for (PsiReference ref : refs) {
|
||||
if (nameIdentifier != null && ref.getElement() == nameIdentifier.getParent()) continue;
|
||||
if (nameIdentifier != null && ref.getElement() == nameIdentifier.getParent()) {
|
||||
builder.replaceElement(ref, PRIMARY_VARIABLE_NAME, createLookupExpression(), true);
|
||||
subrefOnPrimaryElement = true;
|
||||
continue;
|
||||
}
|
||||
addVariable(ref, selectedElement, builder, offset);
|
||||
}
|
||||
if (nameIdentifier != null && !subrefOnPrimaryElement) addVariable(nameIdentifier, selectedElement, builder);
|
||||
for (Pair<PsiElement, TextRange> usage : stringUsages) {
|
||||
addVariable(usage.first, usage.second, selectedElement, builder);
|
||||
}
|
||||
|
||||
+4
@@ -38,6 +38,10 @@ public class JavaFXRenameTest extends DaemonAnalyzerTestCase {
|
||||
doTest("newFieldName");
|
||||
}
|
||||
|
||||
public void testHandler() throws Exception {
|
||||
doTest("newHandlerName");
|
||||
}
|
||||
|
||||
public void testCustomComponentTag() throws Exception {
|
||||
doTest("Foo");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane id="AnchorPane" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="Handler">
|
||||
<Button onAction="#fo<caret>o"
|
||||
</AnchorPane>
|
||||
@@ -0,0 +1,3 @@
|
||||
public class Handler {
|
||||
public void foo() {}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane id="AnchorPane" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="Handler">
|
||||
<Button onAction="#newHandlerName"
|
||||
</AnchorPane>
|
||||
Reference in New Issue
Block a user