use of org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxBuiltInAttributeDescriptor in project intellij-community by JetBrains.
the class JavaFxExpandAttributeIntention method isAvailable.
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (element instanceof XmlToken && ((XmlToken) element).getTokenType() == XmlTokenType.XML_NAME) {
final PsiElement parent = element.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttributeDescriptor descriptor = ((XmlAttribute) parent).getDescriptor();
if (descriptor instanceof JavaFxPropertyAttributeDescriptor && !(descriptor instanceof JavaFxBuiltInAttributeDescriptor)) {
PsiType tagType = null;
final PsiElement declaration = descriptor.getDeclaration();
if (declaration instanceof PsiMember) {
tagType = PropertyUtil.getPropertyType((PsiMember) declaration);
}
PsiClass tagClass = PsiUtil.resolveClassInType(tagType instanceof PsiPrimitiveType ? ((PsiPrimitiveType) tagType).getBoxedType(parent) : tagType);
if ((tagClass != null && JavaFxPsiUtil.isAbleToInstantiate(tagClass)) || descriptor instanceof JavaFxStaticSetterAttributeDescriptor) {
setText("Expand '" + ((XmlAttribute) parent).getName() + "' to tag");
return true;
}
}
}
}
return false;
}
Aggregations