Search in sources :

Example 11 with StrutsManager

use of com.intellij.struts2.dom.struts.model.StrutsManager in project intellij-plugins by JetBrains.

the class StrutsModelFactory method computeAllModels.

protected List<StrutsModel> computeAllModels(@NotNull final Module module) {
    final PsiManager psiManager = PsiManager.getInstance(module.getProject());
    final StrutsManager strutsManager = StrutsManager.getInstance(module.getProject());
    final Set<StrutsFileSet> fileSets = strutsManager.getAllConfigFileSets(module);
    final List<StrutsModel> models = new ArrayList<>(fileSets.size());
    for (final StrutsFileSet set : fileSets) {
        if (set.isRemoved()) {
            continue;
        }
        final Set<XmlFile> files = new LinkedHashSet<>(set.getFiles().size());
        for (final VirtualFilePointer filePointer : set.getFiles()) {
            if (!filePointer.isValid())
                continue;
            final VirtualFile file = filePointer.getFile();
            if (file == null) {
                continue;
            }
            final PsiFile psiFile = psiManager.findFile(file);
            if (psiFile instanceof XmlFile) {
                final StrutsRoot strutsRootDom = getDom((XmlFile) psiFile);
                if (strutsRootDom != null) {
                    files.add((XmlFile) psiFile);
                // TODO           addIncludes(files, strutsRootDom);
                }
            }
        }
        if (!files.isEmpty()) {
            final DomFileElement<StrutsRoot> element = createMergedModelRoot(files);
            final StrutsModel model;
            if (element != null) {
                model = new StrutsModelImpl(element, files);
                models.add(model);
            }
        }
    }
    return models;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) ArrayList(java.util.ArrayList) PsiManager(com.intellij.psi.PsiManager) StrutsFileSet(com.intellij.struts2.facet.ui.StrutsFileSet) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) PsiFile(com.intellij.psi.PsiFile) StrutsRoot(com.intellij.struts2.dom.struts.StrutsRoot)

Aggregations

StrutsManager (com.intellij.struts2.dom.struts.model.StrutsManager)10 StrutsModel (com.intellij.struts2.dom.struts.model.StrutsModel)7 PsiFile (com.intellij.psi.PsiFile)5 XmlFile (com.intellij.psi.xml.XmlFile)5 NotNull (org.jetbrains.annotations.NotNull)5 Module (com.intellij.openapi.module.Module)4 Action (com.intellij.struts2.dom.struts.action.Action)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 PsiElement (com.intellij.psi.PsiElement)2 PsiManager (com.intellij.psi.PsiManager)2 StrutsFileSet (com.intellij.struts2.facet.ui.StrutsFileSet)2 Nullable (org.jetbrains.annotations.Nullable)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 BaseIntentionAction (com.intellij.codeInsight.intention.impl.BaseIntentionAction)1 DomGotoRelatedItem (com.intellij.codeInsight.navigation.DomGotoRelatedItem)1 Annotation (com.intellij.lang.annotation.Annotation)1 GotoRelatedItem (com.intellij.navigation.GotoRelatedItem)1 Editor (com.intellij.openapi.editor.Editor)1 PathReference (com.intellij.openapi.paths.PathReference)1 Project (com.intellij.openapi.project.Project)1