PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly, @NotNull LocalInspectionToolSession session) { if (!JavaFxFileTypeFactory.isFxml(session.getFile())) return PsiElementVisitor.EMPTY_VISITOR; return new XmlElementVisitor() { @Override public void visitXmlAttribute(@NotNull XmlAttribute attribute) { super.visitXmlAttribute(attribute); final String attributeValue = attribute.getValue(); if (attributeValue == null) return; final XmlAttributeDescriptor descriptor = attribute.getDescriptor(); if (descriptor instanceof JavaFxPropertyAttributeDescriptor) { final PsiClass psiClass = ((JavaFxPropertyAttributeDescriptor)descriptor).getPsiClass(); if (psiClass != null && JavaFxCommonNames.JAVAFX_SCENE_COLOR.equals(psiClass.getQualifiedName())) { final XmlAttributeValue valueElement = attribute.getValueElement(); final PsiElement location = valueElement != null ? valueElement : attribute; validateColorComponent(psiClass, attribute.getName(), attributeValue, location); } } } @Override public void visitXmlTag(@NotNull XmlTag tag) { super.visitXmlTag(tag); if (tag.getSubTags().length != 0) return; final XmlElementDescriptor descriptor = tag.getDescriptor(); if (descriptor instanceof JavaFxPropertyTagDescriptor) { final PsiClass psiClass = ((JavaFxPropertyTagDescriptor)descriptor).getPsiClass(); if (psiClass != null && JavaFxCommonNames.JAVAFX_SCENE_COLOR.equals(psiClass.getQualifiedName())) { final XmlTagValue valueElement = tag.getValue(); final XmlText[] textElements = valueElement.getTextElements(); final PsiElement location = textElements.length == 1 ? textElements[0] : tag; validateColorComponent(psiClass, tag.getName(), valueElement.getTrimmedText(), location); } } } private void validateColorComponent(@NotNull PsiClass psiClass, @NotNull String propertyName, @NotNull String propertyValue, @NotNull PsiElement location) { final PsiMember declaration = JavaFxPsiUtil.getWritableProperties(psiClass).get(propertyName); final String boxedQName = JavaFxPsiUtil.getBoxedPropertyType(psiClass, declaration); if (CommonClassNames.JAVA_LANG_FLOAT.equals(boxedQName) || CommonClassNames.JAVA_LANG_DOUBLE.equals(boxedQName)) { try { double value = Double.parseDouble(propertyValue); if (value < 0.0 || value > 1.0) { holder.registerProblem(location, JavaFXBundle.message("inspection.javafx.color.component.out.of.range.problem")); } } catch (NumberFormatException ignored) { } } } }; }