intellij-plugin-save-actions
intellij-plugin-save-actions copied to clipboard
Add support for Rider
See #18 : Rider (settings OK - reformat KO)
This would be amazing. The only issue I've had with Rider is that I can't use a plugin like this.
@van800 any chance you could issue a PR with that workaround you mentioned in the other issue so this will work on Rider? It's definitely a huge missing gap that we don't have format on save on Rider. Thanks!
I've just tested in Rider, the plugin is called, the reformat is called, but nothing happens.
1328 2020-06-01 13:33:40,851 | INFO | SaveActionManager | [+] Start SaveActionManager#beforeAllDocumentsSaving
1329 2020-06-01 13:33:40,851 | INFO | SaveActionManager | Locating psi files for 1 documents: [DocumentImpl[file:///home/alex/Projects/rider-test/rider-test/ClassLibrary1/Class1.cs]]
1330 2020-06-01 13:33:40,851 | INFO | SaveActionManager | Processing Project (name=rider-test, containerState=ACTIVE, componentStore=/home/alex/Projects/rider-test/rider-test) files [CSharpFile] mode saveAll
1331 2020-06-01 13:33:40,851 | INFO | SaveActionManager | Valid files [CSharpFile]
1332 2020-06-01 13:33:40,851 | INFO | SaveActionManager | Start processors (7)
1333 2020-06-01 13:33:40,851 | INFO | SaveActionManager | Filtered processors [reformat]
1334 2020-06-01 13:33:40,851 | INFO | SaveActionManager | Execute command reformat on 1 files
1335 2020-06-01 13:33:40,852 | INFO | SaveActionManager | Exit engine with results [reformat:OK]
1336 2020-06-01 13:33:40,853 | INFO | SaveActionManager | End SaveActionManager#beforeAllDocumentsSaving
That would probably be due to the research I did earlier... See https://github.com/dubreuia/intellij-plugin-save-actions/issues/18#issuecomment-426065888.
I completely forgot about that discussion we had. There is also #198
Wow, it is working using "Build Actions". But I'd need to detect if the IDE is Rider, disable the "Reformat" action or something, else the users will get confused as I don't expect them to read the docs for Rider specificities.
Wow, it is working using "Build Actions". But I'd need to detect if the IDE is Rider, disable the "Reformat" action or something, else the users will get confused as I don't expect them to read the docs for Rider specificities.
I just tried that but it seems to only actually format the currently focused file
Oh no
I was almost ready to push the fix. I've disabled the reformat buttons for Rider with a message. Maybe I can use data.put(VIRTUAL_FILE_ARRAY.getName(), ...);
and PsiDocumentManager.getInstance(null).getUncommittedDocuments()
to force the thing to operate on mutiple files. I've tried to reformat multiple files by selecting them in the explorer and it works, so I'm pretty sure we can make it work.
Rider UI
That's awesome. The plugin also does not currently show up on the marketplace for Rider, could you include it once this is fixed?
Yes, if I can make it work... I'll add it to the marketplace.
I can't make it work. I've also tried with the "Code Cleanup" action, either it doesn't work, or it only works on 1 file, or it pops up a dialog.
EDIT: see code in https://github.com/dubreuia/intellij-plugin-save-actions/tree/issue_310_support_rider
Did you try using the "Silent Code Cleanup" option? The user would have to set which option to use for silent code cleanup though.
Yes @giuliano-barberi-tf, unfortunately it doesn't work (works only for the current file).
I, too, am interested in this for Rider. I made a small script to run rclone to make a more permanent local history style file backup but would like some additional options over just the file watcher.
I'm releasing a partial fix in 2.1.0, it might work for the current file. Please let me know if it does
I've tested 2.1.0 in Rider (2020.2.2) using a Quick List with just the "Reformat Code" action. Got this exception:
java.lang.ClassCastException: class com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl cannot be cast to class com.intellij.openapi.editor.Editor (com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl and com.intellij.openapi.editor.Editor are in unnamed module of loader com.intellij.util.lang.UrlClassLoader @6f7fd0e6)
at com.jetbrains.rdclient.actions.ActionCallPolicy.getElement(ActionCallStrategy.kt:61)
at com.jetbrains.rider.actions.RiderActionCallPolicy.getActionCallStrategy(RiderActionCallPolicy.kt:31)
at com.jetbrains.rdclient.actions.base.FrontendActionUpdateTrait$DefaultImpls.frontendUpdate(FrontendActionUpdateTrait.kt:14)
at com.jetbrains.rdclient.actions.base.IBackendDelegatingActionOverride$DefaultImpls.frontendUpdate(IBackendDelegatingActionOverride.kt)
at com.jetbrains.rdclient.actions.base.BackendDelegatingAction.frontendUpdate(BackendDelegatingAction.kt:126)
at com.jetbrains.rdclient.actions.base.BackendDelegatingAction.actionPerformed(BackendDelegatingAction.kt:92)
at com.dubreuia.processors.BuildProcessor.lambda$static$4(BuildProcessor.java:119)
at com.dubreuia.processors.SaveReadCommand.execute(SaveReadCommand.java:50)
at com.dubreuia.core.component.Engine.lambda$processPsiFiles$5(Engine.java:106)
BTW: Awesome plugin! I enjoy using it in WebStorm and would love to have it in Rider as well.
Hey @sgaertner thank you so much for testing. I would also love to see the plugin work in Rider, but I'll have to debug more how the formatter works.
I'd also love to see this plugin to work in Rider. 😁
tried latetst (v 2.2.0) with installation from disk - but can't get it work (not even for the current file) - unfortunately
tried also the experimental from quick list
would love to see this plugin working in rider
Not working for me either, instalation from disk Reformat Code