use of org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptorBase in project intellij-community by JetBrains.
the class JavaFxPsiUtil method isClassAcceptable.
public static boolean isClassAcceptable(@Nullable XmlTag targetTag, @Nullable final PsiClass fromClass, @NotNull BiConsumer<String, Validator.ValidationHost.ErrorType> messageConsumer) {
if (targetTag == null || fromClass == null || !fromClass.isValid()) {
return true;
}
final XmlElementDescriptor tagDescriptor = targetTag.getDescriptor();
if (tagDescriptor instanceof JavaFxPropertyTagDescriptor) {
final PsiClass containingClass = ((JavaFxPropertyTagDescriptor) tagDescriptor).getPsiClass();
final PsiType targetType = getWritablePropertyType(containingClass, tagDescriptor.getDeclaration());
return canCoerce(targetType, fromClass, targetTag, messageConsumer);
} else if (tagDescriptor instanceof JavaFxClassTagDescriptorBase) {
final PsiElement tagDeclaration = tagDescriptor.getDeclaration();
if (tagDeclaration instanceof PsiClass) {
PsiClass defaultPropertyOwnerClass = (PsiClass) tagDeclaration;
final XmlAttribute factoryAttr = targetTag.getAttribute(FxmlConstants.FX_FACTORY);
if (factoryAttr != null) {
defaultPropertyOwnerClass = getFactoryProducedClass((PsiClass) tagDeclaration, factoryAttr.getValue());
}
final PsiType targetType = getDefaultPropertyExpectedType(defaultPropertyOwnerClass);
if (targetType != null) {
return canCoerce(targetType, fromClass, targetTag, messageConsumer);
}
if (!isObservableCollection(defaultPropertyOwnerClass)) {
return noDefaultPropertyError(messageConsumer);
}
}
}
return true;
}
use of org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptorBase in project intellij-community by JetBrains.
the class JavaFxCollapseSubTagToAttributeIntention method isAvailable.
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (element instanceof XmlToken && ((XmlToken) element).getTokenType() == XmlTokenType.XML_NAME && element.getParent() instanceof XmlTag) {
final XmlTag tag = (XmlTag) element.getParent();
for (XmlTag xmlTag : tag.getSubTags()) {
if (xmlTag.getAttribute(FxmlConstants.FX_VALUE) == null)
return false;
}
final XmlTag parentTag = tag.getParentTag();
if (parentTag != null && tag.getDescriptor() instanceof JavaFxPropertyTagDescriptor && parentTag.getDescriptor() instanceof JavaFxClassTagDescriptorBase) {
setText("Collapse tag '" + tag.getName() + "' to attribute");
return true;
}
}
return false;
}
Aggregations