carymrobbins / intellij-haskforce

Haskell plugin for IntelliJ IDEA
http://carymrobbins.github.io/intellij-haskforce/
Apache License 2.0
486 stars 39 forks source link

Integration with other JetBrains Products #65

Open lykahb opened 9 years ago

lykahb commented 9 years ago

After I installed the plugin, there is only syntax highlighting and the plugin settings are not available. I use WebStorm 9.0.

carymrobbins commented 9 years ago

Let me take a look. I don't use WebStorm, so I'll need to download it and test it out.

carymrobbins commented 9 years ago

Technical notes:

To debug this issue, we can change the SDK when building HaskForce to use a different product.

Project Structure > SDKs

From there we can add an SDK for another product by pointing to where it is installed.

I've discovered when testing this with PyCharm that many modules and classes are not available. This seems to be primarily centered around building. We'll need to refactor existing code to not depend on the IDEA-specific classes and use possibly more general ones.

We should also add PyCharm Community Edition to the Travis CI job to ensure that builds are successful for both IDEA and other products.

lykahb commented 9 years ago

The file plugin.xml makes the plugin compatible only with Idea. If we are lucky this line will fix the issue.

<!-- please see http://confluence.jetbrains.net/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
   on how to target different products -->
<!-- uncomment to enable plugin in all products
<depends>com.intellij.modules.lang</depends>
-->
carymrobbins commented 9 years ago

Thanks for keeping up on this @lykahb. Unfortunately, I was unable to build HaskForce against the PyCharm SDK -

I've discovered when testing this with PyCharm that many modules and classes are not available. This seems to be primarily centered around building. We'll need to refactor existing code to not depend on the IDEA-specific classes and use possibly more general ones.

For instance, when targeting PyCharm CE SDK (139.781), I get the error Cannot resolve symbol 'builders' for the following imports in com.haskforce.jps.HaskellTargetType -

import org.jetbrains.jps.builders.BuildTargetLoader;
import org.jetbrains.jps.builders.ModuleBasedBuildTargetType;

The link you provide explains that -

If a plugin does not include any module dependency tags in its plugin.xml, it's assumed to be a legacy plugin and it's loaded only in IntelliJ IDEA.

If the plugin.xml includes one or more of such tags, the plugin is loaded if the product contains all of the modules on which the plugin depends.

The following modules are currently available in all products based on the IntelliJ platform:

  • com.intellij.modules.platform
  • com.intellij.modules.lang
  • ...

Also -

Before marking a plugin as compatible with all products, you need to verify that it doesn't use any APIs which are specific to IntelliJ IDEA. In order to do that, you can create an IntelliJ Platform SDK pointing to an installation of RubyMine/PyCharm/..., compile your plugin against that SDK and verify that everything compiles.

Basically, we have to use com.intellij.modules.lang as a dependency. In order for it to work properly with other products, we have to decouple HaskForce from the existing IDEA APIs which aren't available with the other products. Unfortunately, I'm not exactly sure how to accomplish that just yet.

lykahb commented 9 years ago

Oh, I see. I thought that other products may not expose the modules because they are not listed as dependency in plugin.xml. I could not test it - haskforce.zip built on my machine even without the changes was rejected by WebStorm.

Part of JPS is available in openapi.jar that is shipped with all distributions. It seems that all missing staff is in jps-server.jar and jps-model.jar. The calls to them are localized at JpsHaskellBuildOptionsSerializer and JpsHaskellModelSerializerExtension.

lykahb commented 9 years ago

Scala plugin uses JPS too and it is compatible only with Idea. I also don't see other ways to have incremental compilation. Maybe it is worth opening an issue on Jetbrains tracker to ship jps-server.jar and jps-model.jar with other products...

lykahb commented 9 years ago

I looked at the CLion which works with a compilable language too and it did not have those packages. There should be another mechanism for managing builds.