mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javafx: check coercing according to resolved refs (IDEA-140244)
This commit is contained in:
+4
@@ -47,6 +47,10 @@ public class JavaFxCoercingTest extends AbstractJavaFXTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPrimitiveCoercing() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
myFixture.testHighlighting(false, false, false, getTestName(true) + ".fxml");
|
||||
}
|
||||
|
||||
+20
-2
@@ -3,6 +3,7 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.psi.xml.*;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.xml.XmlAttributeDescriptor;
|
||||
@@ -151,7 +152,14 @@ public class JavaFxPropertyAttributeDescriptor extends BasicXmlAttributeDescript
|
||||
final XmlAttributeDescriptor attributeDescriptor = ((XmlAttribute)parent).getDescriptor();
|
||||
if (attributeDescriptor != null) {
|
||||
final PsiElement declaration = attributeDescriptor.getDeclaration();
|
||||
final String boxedQName = getBoxedPropertyType(declaration);
|
||||
final String boxedQName;
|
||||
if (declaration != null) {
|
||||
boxedQName = getBoxedPropertyType(declaration);
|
||||
}
|
||||
else {
|
||||
final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context);
|
||||
boxedQName = tagClass != null ? tagClass.getQualifiedName() : null;
|
||||
}
|
||||
if (boxedQName != null) {
|
||||
try {
|
||||
final Class<?> aClass = Class.forName(boxedQName);
|
||||
@@ -161,10 +169,20 @@ public class JavaFxPropertyAttributeDescriptor extends BasicXmlAttributeDescript
|
||||
catch (InvocationTargetException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
if (cause instanceof NumberFormatException) {
|
||||
final PsiReference reference = context.getReference();
|
||||
if (reference != null) {
|
||||
final PsiElement resolve = reference.resolve();
|
||||
if (resolve instanceof XmlAttributeValue) {
|
||||
final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)resolve);
|
||||
if (tagClass != null && boxedQName.equals(tagClass.getQualifiedName())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "Invalid value: unable to coerce to " + boxedQName;
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
catch (Throwable ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import java.lang.Double?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml" alignment="center" spacing="20">
|
||||
<fx:define>
|
||||
<Double fx:id="CONTENT_SPACING" fx:value=<error descr="Invalid value: unable to coerce to java.lang.Double">"200p"</error>/>
|
||||
</fx:define>
|
||||
<VBox fx:id="content" spacing="$CONTENT_SPACING"/>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user