plugin.xml extension DOM: remove duplicate xincluded descriptor walking

GitOrigin-RevId: 14d21eb7c193c40f7fc566cb5061ae940633a61b
This commit is contained in:
peter
2019-08-22 18:12:39 +02:00
committed by intellij-monorepo-bot
parent 765c3b87ea
commit 8a4809eac8
3 changed files with 19 additions and 19 deletions

View File

@@ -22,10 +22,7 @@ import org.jetbrains.idea.devkit.dom.*;
import org.jetbrains.idea.devkit.dom.index.PluginIdModuleIndex;
import org.jetbrains.idea.devkit.util.DescriptorUtil;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
public class ExtensionsDomExtender extends DomExtender<Extensions> {
@@ -37,22 +34,23 @@ public class ExtensionsDomExtender extends DomExtender<Extensions> {
if (ideaPlugin == null) return;
String epPrefix = extensions.getEpPrefix();
for (IdeaPlugin plugin : getVisiblePlugins(ideaPlugin)) {
AbstractCollectionChildDescription collectionChildDescription =
(AbstractCollectionChildDescription)plugin.getGenericInfo().getCollectionChildDescription("extensionPoints");
DomInvocationHandler handler = DomManagerImpl.getDomInvocationHandler(plugin);
assert handler != null;
List<? extends DomElement> children = handler.getCollectionChildren(collectionChildDescription, false);
if (!children.isEmpty()) {
for (DomElement points : children) {
for (ExtensionPoint point : ((ExtensionPoints)points).getExtensionPoints()) {
registerExtensionPoint(registrar, point, epPrefix);
}
Set<IdeaPlugin> visiblePlugins = getVisiblePlugins(ideaPlugin);
for (IdeaPlugin plugin : visiblePlugins) {
for (DomElement points : getChildrenWithoutIncludes(plugin, "extensionPoints")) {
for (DomElement point : getChildrenWithoutIncludes(points, "extensionPoint")) {
registerExtensionPoint(registrar, (ExtensionPoint)point, epPrefix);
}
}
}
}
private static List<? extends DomElement> getChildrenWithoutIncludes(DomElement parent, String tagName) {
AbstractCollectionChildDescription collectionChildDescription =
(AbstractCollectionChildDescription)parent.getGenericInfo().getCollectionChildDescription(tagName);
DomInvocationHandler handler = Objects.requireNonNull(DomManagerImpl.getDomInvocationHandler(parent));
return handler.getCollectionChildren(collectionChildDescription, false);
}
@Override
public boolean supportsStubs() {
return false;

View File

@@ -1,3 +1,5 @@
<extensionPoints>
<extensionPoint name="extensionX" beanClass="foo.Bar"/>
</extensionPoints>
<idea-plugin>
<extensionPoints>
<extensionPoint name="extensionX" beanClass="foo.Bar"/>
</extensionPoints>
</idea-plugin>

View File

@@ -7,7 +7,7 @@
<xi:include href="/pluginWithXInclude-extensionPointsWithModule.xml" xpointer="xpointer(/idea-plugin/*)"/>
<extensionPoints>
<extensionPoint name="bar" interface="java.util.List"/>
<xi:include href="/pluginWithXInclude-extensionPoints.xml" xpointer="xpointer(/extensionPoints/*)"/>
<xi:include href="/pluginWithXInclude-extensionPoints.xml" xpointer="xpointer(/idea-plugin/extensionPoints/*)"/>
</extensionPoints>
<extensions defaultExtensionNs="foo">