diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java index 702f0aa0fbd5..0c4fd962cab7 100644 --- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java +++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java @@ -53,6 +53,10 @@ public class JavaFXRenameTest extends DaemonAnalyzerTestCase { doTest("Foo", true); } + public void testCustomComponentPropertyTag() throws Exception { + doTest("Foo", true); + } + public void testFromReference() throws Exception { final String newName = "lbl1"; doTest(newName); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java index 887c93040373..d3b6a973614a 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java @@ -24,6 +24,7 @@ import com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassRe import com.intellij.psi.xml.XmlProcessingInstruction; import com.intellij.psi.xml.XmlTag; import com.intellij.util.IncorrectOperationException; +import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; @@ -156,7 +157,28 @@ public class FxmlReferencesContributor extends PsiReferenceContributor { @Nullable @Override public PsiElement resolve() { - return myReference.resolve(); + final PsiElement resolve = myReference.resolve(); + if (resolve != null) { + return resolve; + } + return getReferencedClass(); + } + + private PsiElement getReferencedClass() { + if (myPosition instanceof XmlTag) { + final XmlElementDescriptor descriptor = ((XmlTag)myPosition).getDescriptor(); + if (descriptor != null) { + final PsiElement declaration = descriptor.getDeclaration(); + if (declaration instanceof PsiMethod && + ((PsiMethod)declaration).hasModifierProperty(PsiModifier.STATIC)) { + final PsiClass containingClass = ((PsiMethod)declaration).getContainingClass(); + if (containingClass != null && myReference.getCanonicalText().equals(containingClass.getName())) { + return containingClass; + } + } + } + } + return null; } @NotNull @@ -176,13 +198,13 @@ public class FxmlReferencesContributor extends PsiReferenceContributor { throws IncorrectOperationException { String oldText = ((XmlTag)myPosition).getName(); final TextRange range = getRangeInElement(); - final String newText = ((PsiPackage)element).getQualifiedName() + + final String newText = (element instanceof PsiPackage ? ((PsiPackage)element).getQualifiedName() : ((PsiClass)element).getName()) + oldText.substring(range.getEndOffset() - 1); return ((XmlTag)myPosition).setName(newText); } public boolean isReferenceTo(PsiElement element) { - return myReference.isReferenceTo(element); + return myReference.isReferenceTo(element) || getReferencedClass() == element; } @NotNull diff --git a/plugins/javaFX/testData/rename/CustomComponentPropertyTag.java b/plugins/javaFX/testData/rename/CustomComponentPropertyTag.java new file mode 100644 index 000000000000..dc5f48006ae3 --- /dev/null +++ b/plugins/javaFX/testData/rename/CustomComponentPropertyTag.java @@ -0,0 +1,14 @@ +package p; + +import javafx.scene.layout.VBox; +import javafx.scene.Node; + +public class CustomVBox extends VBox { + public static Integer getFoo(Node pane) { + return 0; + } + + public static void setFoo(Node pane, Integer foo) { + + } +} \ No newline at end of file diff --git a/plugins/javaFX/testData/rename/customComponentPropertyTag.fxml b/plugins/javaFX/testData/rename/customComponentPropertyTag.fxml new file mode 100644 index 000000000000..7647b6e46e51 --- /dev/null +++ b/plugins/javaFX/testData/rename/customComponentPropertyTag.fxml @@ -0,0 +1,4 @@ + +