Best way to provide different functionality based on platform type

Hello,


While working on adding support for non-IDEA IDEs for the golang I wanted to provide the functionality to create the project as a golang project when in PHPStorm from the new project dialog but then again, as a proper module from IDEA.
I've finally did it like this: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/master/src/META-INF/plugin.xml#L107 but I'm not sure if it's the best way to do it or not.
Is there a better way to do it?
Thanks.


Regards,
Florin

Message was edited by: Florin Patan. Updated plugin link.

7 comments
Comment actions Permalink

Also, it seems that if I use IDEA + PHP plugin installed I get this (see the two Go entries: Go Application and Go section):

snapshot60.png

0
Comment actions Permalink

Ping for this one. Anyone with some ideas about this? Thanks!

0
Comment actions Permalink

I've just discovered that in WebStorm the plugin doesn't display the Go Application option as I'm not importing: com.intellij.modules.xml
But if I import that then it will duplicate the entries in all the other IDEs.
And the problem in IDEA will still persist.

Is there no way to hide the "<directoryProjectGenerator />" implementation for IDEA?



Thank you.

0
Comment actions Permalink

I do believe the duplication happens because in IDEA both idea-features.xml and non-idea-features.xml files are loaded.
AFAIK there is no way at the moment to differentiate PhpStorm and IDEA with PHP plugin on the dependencies level.

0
Comment actions Permalink

Thanks for your answer.
I ended up doing something like this: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/pull/515/files but it's hacky.
The problem is that I still don't have a clue how to determine if the IDE is IDEA Ultimate or not, as it seems that 'WebModuleType' is not bundled with IDEA IC but it is with IDEA Ultimate.
That PR is actually a fix for the problem here: http://youtrack.jetbrains.com/issue/IDEA-119104

And I've noticed a new feature in RubyMine latest version, the posibility to open a new project in the same window (very cool) but will there be any post to see what changes that functionality brings?

Thanks.

0
Comment actions Permalink

Programmaticaly that's easy - PlatformUtils.isIdea() is true for Ultimate but not for Community.

Under the hood RubyMine attaches a second project as a module to a currently opened one (see ModuleAttachProcessor for reference).

0
Comment actions Permalink

Thank you very much! That's awesome.

0

Please sign in to leave a comment.