Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to all intellij products #18

Closed
jclx opened this issue Aug 28, 2015 · 91 comments
Closed

Add support to all intellij products #18

jclx opened this issue Aug 28, 2015 · 91 comments

Comments

@jclx
Copy link

jclx commented Aug 28, 2015

If you add
com.intellij.modules.lang

to the plugin.xml it will on all intellij products like webstorm.

Great plugin btw.

@dubreuia
Copy link
Owner

dubreuia commented Sep 1, 2015

Thanks, I'll add that, but I'll need to test it in all intellij products.

@dubreuia dubreuia added this to the 0.6 milestone Sep 7, 2015
@dubreuia dubreuia self-assigned this Dec 10, 2015
@dubreuia
Copy link
Owner

From twitter: "Hi there, I just installed Save Actions on phpstorm 9.0.2 but cannot find the settings as described in the documentation."

@dubreuia dubreuia removed this from the 0.6 milestone Feb 9, 2016
@dubreuia
Copy link
Owner

dubreuia commented Mar 2, 2016

@XXChester
Copy link

Guess the php webstorm support never made it in? Was really excited when I found this plugin and it installed fine, just cannot find the settings anywhere.

@dubreuia
Copy link
Owner

Hey @XXChester I'm working on bringing the plugin to all products right now, PhpStorm will soon be supported. I closed specific issues because they are duplicate with this one (I'll release it for all products at the same time).

@XXChester
Copy link

👍 Awesome. I thought it was abandoned date, glad to hear it is not.

@sgeier
Copy link

sgeier commented Jun 16, 2016

Glad to hear you are working on making it work on a variety of platforms. Is it possible to release a port as soon as its finished instead of waiting for release until all other platforms are done? This would help so much. I personally feel that my quality of codes degrades without SaveActions. I really want this on Android Studio.

@dubreuia
Copy link
Owner

Is Android Studio a JetBrains product? I'm testing for:

  • Intellij IDEA
  • PhpStorm
  • WebStorm
  • PyCharm
  • RubyMine
  • AppCode
  • CLion
  • DataGrip (maybe?)

@dubreuia
Copy link
Owner

The branch all-products works, I just haven't properly tested it yet

@sgeier
Copy link

sgeier commented Jun 16, 2016

Dubreuia, Android Studio is based on Intellij IDEA. So practically the IDEA extension/plugins should work but it doesn't - in fact, and this is where the troubles com in, it cant even be downloaded as a plugin from the Plugin repository browser inside Android Studio. Its just not listed. I just verified this. Appears in Idea (version 15) but doesnt in Android Studio (lastest) 2.1.1. As its entirely based on Idea I would assume its not too much effort to enable it for Android Studio. Anyway I keep waiting :) Keep up the good work!

@krasa
Copy link
Contributor

krasa commented Jun 17, 2016

You need to put <depends>com.intellij.modules.platform</depends> into plugin.xml .
edit: nevermind, you already did in that branch :)

@dubreuia
Copy link
Owner

@krasa Thanks already done! The problem is that I have Java specific elements, so I need to split the plugin in two parts so it doesn't crash on startup with PyCharm, etc.

@sgeier OK it is not a JetBrains product but it should work too, note to self : https://developer.android.com/studio/index.html

I should release the all-product version this weekend if all goes well

@rmgrimm
Copy link

rmgrimm commented Aug 1, 2016

@dubreuia Any update on the release of the all-product branch? We'd like to start using it across the dev team here as soon as it's ready

I'm happy to support in any testing as well, let me know. 👍

@dubreuia
Copy link
Owner

dubreuia commented Aug 4, 2016

Actually it's already ready, but I don't have time to test it so I didn't release it. I'll send you the jar so you can test if you want.

@dubreuia
Copy link
Owner

dubreuia commented Aug 4, 2016

save-actions.zip

Unzip, inside you have a .jar that you can import by hand in Intellij (Settings > Plugins > Import from jar). It is version 0.12-RC, it is based on 0.10 (not the latest available, you have probably on 0.11 right now).

@dubreuia dubreuia removed their assignment Aug 21, 2016
@Tuupertunut
Copy link

@dubreuia I can confirm that zipped version works on WebStorm 2016.2.3.

@manojvignesh
Copy link

The zip file works fine in WebStorm 2016.2.4. Thanks for this awesome plugin.

@dubreuia
Copy link
Owner

Thanks for your feedback, I'll make that available on the Jetbrains plugin repository.

@thiagotalma
Copy link

Ok with PHPStorm!

@F21
Copy link

F21 commented Dec 24, 2016

Doesn't work with Gogland 1.0 EAP (163.10615.6) for golang using 0.12. Would be awesome if it could be supported 😄

@spencero91
Copy link

Any way we could get this added to the Jetbrains' plugin repository for PhpStorm?

@dubreuia
Copy link
Owner

Hey @spencero91, try the save-actions zip I uploaded in this issue, you can import it directly in PhpStorm.

I don't want to upload it to the plugin repository just now, I haven't tested it in all products, and I don't have time to correct all the issues that are opened only for intellij...

The code is on branch master-all-product.

Keep me posted if that works for you

@bobvandevijver
Copy link

It seems that the plugin is doing it's job in Rider as you should expect, as it calls the run method of com.intellij.codeInsight.actions.ReformatCodeProcessor. The call itself simply doesn't do the formatting (it doesn't throw anything either), and I do not see anything weird during it's execution, so I'm stuck 😞

@dubreuia
Copy link
Owner

dubreuia commented Oct 1, 2018

@bobvandevijver Thank you for the debug. I'm pretty sure the reformat in Rider and PyCharm (maybe others) is not done by ReformatCodeProcessor. We'll need to provide specific implementation for those products (like META-INF/plugin-java.xml for Java), and call the proper formatter on save.

@bobvandevijver
Copy link

bobvandevijver commented Oct 1, 2018

I tried some more with the plugin, and it seems that the whole CodeStyleManager simply doesn't work in Rider. It has probably something to do with the backend connection with ReSharper, which is responsible for the formatting/optimizations.

I can trigger the reformat with the following, ugly hack:

ActionManager.getInstance().getAction("ReformatCode")
    .actionPerformed(new AnActionEvent(null, DataManager.getInstance().getDataContext(),
        ActionPlaces.UNKNOWN, new Presentation(), ActionManager.getInstance(), 0));

This triggers the following logging in the frontend, which is the same when triggered from the menu/shortcut:

23:05:45.647 | INFO  | RiderActionOverride            | Executing ReSharper action 'RiderReformatCode'
23:05:45.647 | INFO  | RiderActionHandlers            | >> Begin backend 'RiderReformatCode' action session
23:05:45.649 | INFO  | RiderActionHandlers            | << End backend 'RiderReformatCode' action session

It does not play nice with any other action being executed simultaneously (such as "OptimizeImports"), so it is in no way an suitable solution.

So, it looks like the ReSharper action is simply not triggered/created when the CodeStyleManager is used. Do we really need to create a ReSharper plugin, which communicates with the frontend? (see https://www.jetbrains.com/help/resharper/sdk/Products/Rider.html). I cannot find really relevant documentation on this issue.

There are also some other issues when compiling the plugin with the Rider SDK, mostly missing classes, so I'm not sure if it's even possible to compile the current plugin for Rider. See bobvandevijver@0a1d0af for the classes I needed to remove in order to being able to build for Rider.

Edit: I also created a ticket at JetBrains: https://youtrack.jetbrains.com/issue/RIDER-20225

(btw, if you want to open an another issue for this discussion just let me know)

@van800
Copy link

van800 commented Oct 2, 2018

@bobvandevijver
I guess it should be something like:
val actionId = ActionManager.getInstance().getAction(IdeActions.ACTION_EDITOR_REFORMAT)

var component  =  project.getComponent<EditorImpl>().component
var dataContext = DataManager.getInstance().getDataContext(component)
fun executeAction(actionId: String, dataContext: DataContext) {
    frameworkLogger.info("Execute action: '$actionId'")
    val actionManager = ActionManagerEx.getInstanceEx()
    val action = actionManager.getAction(actionId)
    //requireNotNull(action) { "action is null" }

    val event = AnActionEvent.createFromAnAction(action, null, "", dataContext)
    action.beforeActionPerformedUpdate(event)

    //require(event.presentation.isEnabled) { "presentation.isEnabled is false for $actionId" }

    actionManager.fireBeforeActionPerformed(action, event.dataContext, event)
    action.actionPerformed(event)
    actionManager.fireAfterActionPerformed(action, event.dataContext, event)
}

I will ask colleagues about calling reformat and OptimizeImports simultaneously.
I assume you are calling OptimizeImports with similar code above.
Surprisingly "OptimizeImports" is not listed in IdeActions, so just hardcode it.

@bobvandevijver
Copy link

Yes, I used the same structure for "OptimizeImports".

I just used your examples (needed to retrieve the editor component with JComponent component = FileEditorManager.getInstance(myProject).getSelectedTextEditor().getComponent(); though), the result is the same: only one action is executed, which is the once that is called later.

Another thing noteworthy is the fact that your example triggers the save action handlers twice, while the version I posted earlier didn't... not sure what causes that though.

Another question I have with this solution: it probably doesn't support VCS changed code either... I really hope that JetBrains will just implement the CodeStyleManager in Rider 😅

@van800
Copy link

van800 commented Oct 3, 2018

@bobvandevijver I have asked about multiple commands but no workaround for now.
Not sure, what do you mean about vcs changed code. If you want to reformat everything in solution, you need to put solutionNode of SolutionExplorer to context like:

        val viewPane = SolutionExplorerViewPane.getInstance(project)
        val solutionNode = viewPane.model.root.children.filterIsInstance<SolutionExplorerModelNode>().single()

        val contextData = mapOf(
            Pair(PlatformDataKeys.SELECTED_ITEM.name, solutionNode),
            Pair(PlatformDataKeys.PROJECT.name, project),
            Pair(ProjectModelDataKeys.SOLUTION_VIEW.name, viewPane))

        var dataContext= SimpleDataContext.getSimpleContext(contextData, null)

@bobvandevijver
Copy link

Not sure, what do you mean about vcs changed code.

@van800 To reformat only changed lines according to your VCS (eg. git) (which is one of the options of the ReformatCodeProcessor, which uses the CodeStyleManager internally)

@dubreuia
Copy link
Owner

dubreuia commented Oct 3, 2018

@van800 @bobvandevijver If you have an almost-working solution (or various possible solutions), could you post a PR with "WIP" prefix so we keep that code somewhere.

Also I'm creating an issue for Rider (see #198)

@hwangjr
Copy link

hwangjr commented Oct 16, 2018

Any plan to support GoLand IDE? It would be awesome to support GoLand IDE.

@dubreuia
Copy link
Owner

Hey @hwangjr, would you mind downloading the latest jar in the release section (https://github.com/dubreuia/intellij-plugin-save-actions/releases/tag/v1.2.0) and test it in GoLang IDE. It might actually work. Can you report back on that? Thanks.

  • IntelliJ IDEA (OK)
  • PhpStorm (OK)
  • PyCharm (OK)
  • AndroidStudio (OK)
  • WebStorm (OK)
  • RubyMine (OK)
  • Rider (settings OK - reformat KO)
  • AppCode (todo)
  • CLion (todo)
  • DataGrip (todo)
  • GoLand IDE (todo)

@hwangjr
Copy link

hwangjr commented Nov 16, 2018

@dubreuia yes, it works. Can you add to jetbrains plugin center? we can download from repositories directly.

@dubreuia
Copy link
Owner

Ok @hwangjr I've added GoLand IDE to the list of compatible IDEs. You should uninstall the local plugin and reinstall it from the plugin repository so you get updates. Thanks!

  • IntelliJ IDEA (OK)
  • PhpStorm (OK)
  • PyCharm (OK)
  • AndroidStudio (OK)
  • WebStorm (OK)
  • RubyMine (OK)
  • GoLand IDE (OK)
  • Rider (settings OK - reformat KO)
  • AppCode (todo)
  • CLion (todo)
  • DataGrip (todo)

@hwangjr
Copy link

hwangjr commented Nov 20, 2018

OK, Thanks.

@denys-meloshyn
Copy link

is it possible to vote for AppCode? 😄 I would be also happy to test it

@hwangjr
Copy link

hwangjr commented Apr 29, 2019

is it possible to vote for AppCode? 😄 I would be also happy to test it

you can test it then tell @dubreuia the test result.

@denys-meloshyn
Copy link

@hwangjr @dubreuia looks like it works fine in AppCode 2019.1, tomorrow will test it more

@denys-meloshyn
Copy link

Found that some options are not available, I especially miss "No action if compile errors".
Screenshot 2019-05-16 at 10 36 49

@bbakermmc
Copy link

I looked for Save Actions in the marketplace and it doesnt exist? Does this support rider?

image

@bobvandevijver
Copy link

@bbakermmc I've created a plugin which "works" (is sometimes errors, only has the basic capabilities), which you can find here: https://github.com/dubreuia/intellij-plugin-save-actions/files/2449110/Save.Actions-0.0.1.zip. See #198 for more information.

@dubreuia
Copy link
Owner

dubreuia commented Jun 3, 2019

@ned1988 Thanks for testing. The option "No action if compile errors" requires a compiler, and since it is platform specific (java, python, etc.) I haven't coded this already outside the Java ecosystem. There's a "core" plugin, used everywhere, and a "java" plugin, used for java products. We'll need "language" plugin for each product we want to fully support, Rider included. If it woks fine I'll mark it as supported then.

@dubreuia
Copy link
Owner

I'm thinking of splitting this issue for each products, this issue is 4 years old...

@keyvchan
Copy link

keyvchan commented Apr 6, 2020

Any update?

@dubreuia
Copy link
Owner

dubreuia commented Apr 6, 2020

Hello @keyvchan ! I don't have time to work on this, but PRs are welcomed. Which product do you use?

@dubreuia
Copy link
Owner

dubreuia commented Apr 6, 2020

I've created 3 issues for each of Rider, AppCode and CLion. Can you guys go vote and post in the issues to see which is needed?

I'm closing this issue. Thanks

@dubreuia dubreuia closed this as completed Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests