Duplicate New Project Wizard entries in WebStorm with Python Community Edition plugin installed

My plugin adds new project wizards for both IntelliJ IDEA via moduleConfigurationEditorProvider and lightweight IDEs via directoryProjectGenerator. It does the latter via the following optional dependencies in plugin.xml:

<!-- PhpStorm support -->
<depends optional="true" config-file="plugin-lightweight.xml">com.jetbrains.php</depends>
<!-- PyCharm support -->
<depends optional="true" config-file="plugin-lightweight.xml">com.intellij.modules.python</depends>
<!-- RubyMine support -->
<depends optional="true" config-file="plugin-lightweight.xml">com.intellij.modules.ruby</depends>
<!-- WebStorm support -->
<depends optional="true" config-file="plugin-lightweight.xml">com.intellij.modules.webstorm</depends>

I know that adding the same file dependency multiple times is an anti-pattern, but I’ve discussed this specific use case with JetBrains folks in the past and they’ve agreed that this is the best way to address it.

So having said that, one of my users noticed duplicate entries from my plugin in the File | New | Project dialog:

I’m able to reproduce that by installing the Python Community Edition plugin into WebStorm. Obviously two of the optional dependencies above are executing.

Note that all of the directoryProjectGenerator EP registrations specify id values, e.g.:

<directoryProjectGenerator
    id="IlluminatedCloudDirectoryProjectGenerator"
    implementation="com.illuminatedcloud.intellij.plugin.project.wizard.lightweight.IlluminatedCloudDirectoryProjectGenerator"
    order="first"/>

so I’m a bit surprised that these aren’t being reconciled as being the same thing and merged.

Any thoughts on how I can avoid this situation? And if it’s not really possible give that I need to be able to support both PyCharm and WebStorm – into which PyCharm can effectively be installed – is it safe to assume it’s benign even if not ideal? Everything seems to work just fine.

As a workaround, could you implement HideableProjectGenerator, then hide duplicates?

That’s an interesting thought. Yes, adding this does in fact help:

public class IlluminatedCloudDirectoryProjectGenerator
    extends WebProjectTemplate<IlluminatedCloudDirectoryProjectData>
    implements HideableProjectGenerator {

    private static int instanceCount = 0;

    private final int instanceIndex = ++instanceCount;

    @Override
    public boolean isHidden() {
        return instanceIndex > 1;
    }

    ...

I guess I’ll add that to my heap of dirty hacks. Thanks for the recommendation!