Search in sources :

Example 1 with JavaFxClassTagDescriptor

use of org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptor in project intellij-community by JetBrains.

the class JavaFxNamespaceDescriptor method getElementDescriptor.

@Nullable
@Override
public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) {
    final XmlTag parentTag = tag.getParentTag();
    if (parentTag != null) {
        final XmlElementDescriptor descriptor = parentTag.getDescriptor();
        return descriptor != null ? descriptor.getElementDescriptor(tag, parentTag) : null;
    }
    final String name = tag.getName();
    if (FxmlConstants.FX_ROOT.equals(name)) {
        return new JavaFxRootTagDescriptor(tag);
    }
    return new JavaFxClassTagDescriptor(name, tag);
}
Also used : JavaFxRootTagDescriptor(org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxRootTagDescriptor) JavaFxClassTagDescriptor(org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) XmlTag(com.intellij.psi.xml.XmlTag) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JavaFxClassTagDescriptor

use of org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptor in project intellij-community by JetBrains.

the class JavaFxNamespaceDescriptor method getRootElementsDescriptors.

@NotNull
@Override
public XmlElementDescriptor[] getRootElementsDescriptors(@Nullable XmlDocument document) {
    if (document != null) {
        final Project project = document.getProject();
        final PsiClass paneClass = JavaPsiFacade.getInstance(project).findClass(JavaFxCommonNames.JAVAFX_SCENE_LAYOUT_PANE, GlobalSearchScope.allScope(project));
        if (paneClass != null) {
            final ArrayList<XmlElementDescriptor> result = new ArrayList<>();
            ClassInheritorsSearch.search(paneClass, paneClass.getUseScope(), true, true, false).forEach(psiClass -> {
                result.add(new JavaFxClassTagDescriptor(psiClass.getName(), psiClass));
                return true;
            });
            return result.toArray(new XmlElementDescriptor[result.size()]);
        }
    }
    return XmlElementDescriptor.EMPTY_ARRAY;
}
Also used : Project(com.intellij.openapi.project.Project) PsiClass(com.intellij.psi.PsiClass) ArrayList(java.util.ArrayList) JavaFxClassTagDescriptor(org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptor) XmlElementDescriptor(com.intellij.xml.XmlElementDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

XmlElementDescriptor (com.intellij.xml.XmlElementDescriptor)2 JavaFxClassTagDescriptor (org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassTagDescriptor)2 Project (com.intellij.openapi.project.Project)1 PsiClass (com.intellij.psi.PsiClass)1 XmlTag (com.intellij.psi.xml.XmlTag)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 JavaFxRootTagDescriptor (org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxRootTagDescriptor)1