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;
}
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;
}
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);
}
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);
}
}
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());
}
Aggregations