mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javaFX: unresolved fx:id in fx:include supported (IDEA-114920)
This commit is contained in:
+7
@@ -43,6 +43,13 @@ public class JavaFXUnresolvedFxIdReferenceInspectionTest extends AbstractJavaFXQ
|
||||
assertEmpty(intentionActions);
|
||||
}
|
||||
|
||||
public void testIncludeBtnWithController() throws Exception {
|
||||
myFixture.addFileToProject("btn.fxml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<?import javafx.scene.control.*?>\n" +
|
||||
"<Button/>");
|
||||
doTest("MyController");
|
||||
}
|
||||
|
||||
public void testFieldsFromControllerSuper() throws Exception {
|
||||
myFixture.addClass("import javafx.scene.control.RadioButton;\n" +
|
||||
"public class SuperController {\n" +
|
||||
|
||||
+18
-8
@@ -39,6 +39,7 @@ import org.jetbrains.plugins.javaFX.fxml.FxmlConstants;
|
||||
import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory;
|
||||
import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
|
||||
import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassBackedElementDescriptor;
|
||||
import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxDefaultPropertyElementDescriptor;
|
||||
import org.jetbrains.plugins.javaFX.fxml.refs.JavaFxFieldIdReferenceProvider;
|
||||
|
||||
/**
|
||||
@@ -87,14 +88,23 @@ public class JavaFxUnresolvedFxIdReferenceInspection extends XmlSuppressableInsp
|
||||
if (attributeValue == null) return null;
|
||||
final PsiElement parent = attributeValue.getParent();
|
||||
if (parent instanceof XmlAttribute) {
|
||||
final XmlTag tag = ((XmlAttribute)parent).getParent();
|
||||
if (tag != null) {
|
||||
final XmlElementDescriptor descriptor = tag.getDescriptor();
|
||||
if (descriptor instanceof JavaFxClassBackedElementDescriptor) {
|
||||
final PsiElement declaration = descriptor.getDeclaration();
|
||||
if (declaration instanceof PsiClass) {
|
||||
return (PsiClass)declaration;
|
||||
}
|
||||
return checkClass(((XmlAttribute)parent).getParent());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PsiClass checkClass(XmlTag tag) {
|
||||
if (tag != null) {
|
||||
final XmlElementDescriptor descriptor = tag.getDescriptor();
|
||||
if (descriptor instanceof JavaFxClassBackedElementDescriptor) {
|
||||
final PsiElement declaration = descriptor.getDeclaration();
|
||||
if (declaration instanceof PsiClass) {
|
||||
return (PsiClass)declaration;
|
||||
}
|
||||
} else if (descriptor instanceof JavaFxDefaultPropertyElementDescriptor) {
|
||||
final XmlTag includedRoot = JavaFxDefaultPropertyElementDescriptor.getIncludedRoot(tag);
|
||||
if (includedRoot != null && !includedRoot.equals(tag)) {
|
||||
return checkClass(includedRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip
|
||||
return null;
|
||||
}
|
||||
|
||||
private static XmlTag getIncludedRoot(XmlTag context) {
|
||||
public static XmlTag getIncludedRoot(XmlTag context) {
|
||||
if (context == null) return null;
|
||||
final XmlAttribute xmlAttribute = context.getAttribute(FxmlConstants.FX_ELEMENT_SOURCE);
|
||||
if (xmlAttribute != null) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
public class MyController {}
|
||||
@@ -0,0 +1,5 @@
|
||||
import javafx.scene.control.Button;
|
||||
|
||||
public class MyController {
|
||||
public Button unknown;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml" fx:controller="MyController">
|
||||
<children>
|
||||
<fx:include source="btn.fxml" fx:id="<caret>unknown"/>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
Reference in New Issue
Block a user