mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javafx: custom component static properties in tags rename
This commit is contained in:
+4
@@ -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);
|
||||
|
||||
+25
-3
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?import p.CustomVBox?>
|
||||
<p.CustomVBox xmlns:fx="http://javafx.com/fxml" >
|
||||
<Custom<caret>VBox.foo>1</CustomVBox.foo>
|
||||
</p.CustomVBox>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?import p.Foo?>
|
||||
<p.Foo xmlns:fx="http://javafx.com/fxml" >
|
||||
<Foo.foo>1</Foo.foo>
|
||||
</p.Foo>
|
||||
Reference in New Issue
Block a user