Search in sources :

Example 1 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.

the class MavenPluginParamInfo method getParamInfoList.

public static ParamInfoList getParamInfoList(@NotNull XmlTag paramTag) {
    XmlTag configurationTag = paramTag;
    DomElement domElement;
    Map m = getMap().get(paramTag.getName());
    while (true) {
        if (m == null)
            return ParamInfoList.EMPTY;
        configurationTag = configurationTag.getParentTag();
        if (configurationTag == null)
            return ParamInfoList.EMPTY;
        String tagName = configurationTag.getName();
        if ("configuration".equals(tagName)) {
            domElement = DomManager.getDomManager(configurationTag.getProject()).getDomElement(configurationTag);
            if (domElement instanceof MavenDomConfiguration) {
                break;
            }
            if (domElement != null)
                return ParamInfoList.EMPTY;
        }
        m = (Map) m.get(tagName);
    }
    Map<Pair<String, String>, Map<String, ParamInfo>> pluginsMap = m;
    MavenDomConfiguration domCfg = (MavenDomConfiguration) domElement;
    MavenDomPlugin domPlugin = domCfg.getParentOfType(MavenDomPlugin.class, true);
    if (domPlugin == null)
        return ParamInfoList.EMPTY;
    String pluginGroupId = domPlugin.getGroupId().getStringValue();
    String pluginArtifactId = domPlugin.getArtifactId().getStringValue();
    Map<String, ParamInfo> goalsMap;
    if (pluginGroupId == null) {
        goalsMap = pluginsMap.get(Pair.create("org.apache.maven.plugins", pluginArtifactId));
        if (goalsMap == null) {
            goalsMap = pluginsMap.get(Pair.create("org.codehaus.mojo", pluginArtifactId));
        }
    } else {
        goalsMap = pluginsMap.get(Pair.create(pluginGroupId, pluginArtifactId));
    }
    if (goalsMap == null)
        return ParamInfoList.EMPTY;
    DomElement parent = domCfg.getParent();
    if (parent instanceof MavenDomPluginExecution) {
        SmartList<ParamInfo> infos = null;
        MavenDomGoals goals = ((MavenDomPluginExecution) parent).getGoals();
        for (MavenDomGoal goal : goals.getGoals()) {
            ParamInfo info = goalsMap.get(goal.getStringValue());
            if (info != null) {
                if (infos == null) {
                    infos = new SmartList<>();
                }
                infos.add(info);
            }
        }
        if (infos != null) {
            ParamInfo defaultInfo = goalsMap.get(null);
            if (defaultInfo != null) {
                infos.add(defaultInfo);
            }
            return new ParamInfoList(domCfg, infos);
        }
    }
    ParamInfo defaultInfo = goalsMap.get(null);
    if (defaultInfo != null) {
        return new ParamInfoList(domCfg, Collections.singletonList(defaultInfo));
    }
    return ParamInfoList.EMPTY;
}
Also used : DomElement(com.intellij.util.xml.DomElement) XmlTag(com.intellij.psi.xml.XmlTag) Pair(com.intellij.openapi.util.Pair)

Example 2 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.

the class GetCompositeCollectionInvocation method invoke.

@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
    Map<XmlTag, DomElement> map = new THashMap<>();
    for (final CollectionChildDescriptionImpl qname : myQnames) {
        for (DomElement element : handler.getCollectionChildren(qname)) {
            map.put(element.getXmlTag(), element);
        }
    }
    final XmlTag tag = handler.getXmlTag();
    if (tag == null)
        return Collections.emptyList();
    final List<DomElement> list = new ArrayList<>();
    for (final XmlTag subTag : tag.getSubTags()) {
        ContainerUtil.addIfNotNull(list, map.get(subTag));
    }
    return list;
}
Also used : DomElement(com.intellij.util.xml.DomElement) THashMap(gnu.trove.THashMap) XmlTag(com.intellij.psi.xml.XmlTag)

Example 3 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.

the class AddElementInCollectionAction method createAddingAction.

@Override
protected AnAction createAddingAction(final AnActionEvent e, final String name, final Icon icon, final Type type, final DomCollectionChildDescription description) {
    final DomElement parentDomElement = getParentDomElement(e);
    if (parentDomElement instanceof MergedObject) {
        final List<DomElement> implementations = (List<DomElement>) ((MergedObject) parentDomElement).getImplementations();
        final DefaultActionGroup actionGroup = new DefaultActionGroup(name, true);
        for (DomElement implementation : implementations) {
            final XmlFile xmlFile = DomUtil.getFile(implementation);
            actionGroup.add(new MyDefaultAddAction(implementation, xmlFile.getName(), xmlFile.getIcon(0), e, type, description));
        }
        return actionGroup;
    }
    return new MyDefaultAddAction(parentDomElement, name, icon, e, type, description);
}
Also used : DomElement(com.intellij.util.xml.DomElement) XmlFile(com.intellij.psi.xml.XmlFile) MergedObject(com.intellij.util.xml.MergedObject) List(java.util.List) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 4 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.

the class GotoDomElementDeclarationAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e, DomModelTreeView treeView) {
    final SimpleNode simpleNode = treeView.getTree().getSelectedNode();
    if (simpleNode instanceof BaseDomElementNode) {
        final DomElement domElement = ((BaseDomElementNode) simpleNode).getDomElement();
        final DomElementNavigationProvider provider = DomElementsNavigationManager.getManager(domElement.getManager().getProject()).getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME);
        provider.navigate(domElement, true);
    }
}
Also used : BaseDomElementNode(com.intellij.util.xml.tree.BaseDomElementNode) DomElement(com.intellij.util.xml.DomElement) DomElementNavigationProvider(com.intellij.util.xml.DomElementNavigationProvider) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 5 with DomElement

use of com.intellij.util.xml.DomElement in project intellij-community by JetBrains.

the class DomUIFactoryImpl method setupErrorOutdatingUserActivityWatcher.

@Override
public void setupErrorOutdatingUserActivityWatcher(final CommittablePanel panel, final DomElement... elements) {
    final UserActivityWatcher userActivityWatcher = createEditorAwareUserActivityWatcher();
    userActivityWatcher.addUserActivityListener(new UserActivityListener() {

        private boolean isProcessingChange;

        @Override
        public void stateChanged() {
            if (isProcessingChange)
                return;
            isProcessingChange = true;
            try {
                for (final DomElement element : elements) {
                    DomElementAnnotationsManagerImpl.outdateProblemHolder(element);
                }
                CommittableUtil.updateHighlighting(panel);
            } finally {
                isProcessingChange = false;
            }
        }
    }, panel);
    userActivityWatcher.register(panel.getComponent());
}
Also used : DomElement(com.intellij.util.xml.DomElement) UserActivityWatcher(com.intellij.ui.UserActivityWatcher) UserActivityListener(com.intellij.ui.UserActivityListener)

Aggregations

DomElement (com.intellij.util.xml.DomElement)97 XmlTag (com.intellij.psi.xml.XmlTag)34 PsiElement (com.intellij.psi.PsiElement)19 Nullable (org.jetbrains.annotations.Nullable)19 NotNull (org.jetbrains.annotations.NotNull)15 Project (com.intellij.openapi.project.Project)11 PsiFile (com.intellij.psi.PsiFile)11 XmlFile (com.intellij.psi.xml.XmlFile)11 XmlAttribute (com.intellij.psi.xml.XmlAttribute)10 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)9 ArrayList (java.util.ArrayList)8 LayoutViewElement (org.jetbrains.android.dom.layout.LayoutViewElement)7 ResourceElement (org.jetbrains.android.dom.resources.ResourceElement)6 DomManager (com.intellij.util.xml.DomManager)5 Style (org.jetbrains.android.dom.resources.Style)5 AntDomTarget (com.intellij.lang.ant.dom.AntDomTarget)4 XmlElement (com.intellij.psi.xml.XmlElement)4 DomElementProblemDescriptor (com.intellij.util.xml.highlighting.DomElementProblemDescriptor)4 LookupElement (com.intellij.codeInsight.lookup.LookupElement)3 TextRange (com.intellij.openapi.util.TextRange)3