Javafx: Allow fx:value attribute's value to start with $ character. Test added (IDEA-154239)

This commit is contained in:
Pavel Dolgov
2016-04-07 16:48:03 +03:00
parent b3d8b7f24c
commit ab14d9220f
5 changed files with 22 additions and 2 deletions
@@ -370,6 +370,10 @@ public class JavaFXHighlightingTest extends AbstractJavaFXTestCase {
doTest();
}
public void testLiteralValue() throws Exception {
doTest();
}
public void testFactoryMethod() throws Exception {
doTest();
}
@@ -147,7 +147,7 @@ public class JavaFxBuiltInAttributeDescriptor extends JavaFxPropertyAttributeDes
return "Unable to coerce '" + value + "' to " + tagClass.getQualifiedName() + ".";
}
}
return super.validateAttributeValue(xmlAttributeValue, value);
return validateLiteral(xmlAttributeValue, value);
}
}
@@ -188,7 +188,7 @@ public class JavaFxPropertyAttributeDescriptor extends BasicXmlAttributeDescript
}
@Nullable
private static String validateLiteral(@NotNull XmlAttributeValue xmlAttributeValue, @NotNull String value) {
protected static String validateLiteral(@NotNull XmlAttributeValue xmlAttributeValue, @NotNull String value) {
final PsiClass tagClass = JavaFxPsiUtil.getTagClass(xmlAttributeValue);
final PsiElement declaration = JavaFxPsiUtil.getAttributeDeclaration(xmlAttributeValue);
final String boxedQName;
@@ -26,6 +26,7 @@ import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
@@ -48,6 +49,10 @@ class JavaFxComponentIdReferenceProvider extends PsiReferenceProvider {
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) {
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute && FxmlConstants.FX_VALUE.equals(((XmlAttribute)parent).getName())) {
return PsiReference.EMPTY_ARRAY;
}
final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)element;
final String value = xmlAttributeValue.getValue();
if (JavaFxPsiUtil.isIncorrectExpressionBinding(value)) {
@@ -0,0 +1,11 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import java.lang.String?>
<VBox xmlns:fx="http://javafx.com/fxml">
<Label>
<String fx:value="$1000"/>
</Label>
<Label>
<String fx:value="${name"/>
</Label>
</VBox>