intellij-plugin-save-actions icon indicating copy to clipboard operation
intellij-plugin-save-actions copied to clipboard

Add support for Rider

Open dubreuia opened this issue 4 years ago • 21 comments

See #18 : Rider (settings OK - reformat KO)

dubreuia avatar Apr 06 '20 16:04 dubreuia

This would be amazing. The only issue I've had with Rider is that I can't use a plugin like this.

heschtag avatar Apr 15 '20 12:04 heschtag

@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!

giuliano-barberi-tf avatar Jun 01 '20 16:06 giuliano-barberi-tf

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

dubreuia avatar Jun 01 '20 17:06 dubreuia

That would probably be due to the research I did earlier... See https://github.com/dubreuia/intellij-plugin-save-actions/issues/18#issuecomment-426065888.

bobvandevijver avatar Jun 01 '20 17:06 bobvandevijver

I completely forgot about that discussion we had. There is also #198

dubreuia avatar Jun 01 '20 17:06 dubreuia

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.

Screenshot from 2020-06-01 14-01-25 Screenshot from 2020-06-01 13-59-36

dubreuia avatar Jun 01 '20 17:06 dubreuia

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

giuliano-barberi-tf avatar Jun 01 '20 18:06 giuliano-barberi-tf

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.

dubreuia avatar Jun 01 '20 19:06 dubreuia

Rider UI

Screenshot from 2020-06-01 15-29-58

dubreuia avatar Jun 01 '20 19:06 dubreuia

That's awesome. The plugin also does not currently show up on the marketplace for Rider, could you include it once this is fixed?

giuliano-barberi-tf avatar Jun 01 '20 19:06 giuliano-barberi-tf

Yes, if I can make it work... I'll add it to the marketplace.

dubreuia avatar Jun 01 '20 19:06 dubreuia

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

dubreuia avatar Jun 01 '20 20:06 dubreuia

Did you try using the "Silent Code Cleanup" option? The user would have to set which option to use for silent code cleanup though.

giuliano-barberi-tf avatar Jun 01 '20 20:06 giuliano-barberi-tf

Yes @giuliano-barberi-tf, unfortunately it doesn't work (works only for the current file).

dubreuia avatar Jun 02 '20 18:06 dubreuia

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.

MostHated avatar Jul 04 '20 07:07 MostHated

I'm releasing a partial fix in 2.1.0, it might work for the current file. Please let me know if it does

dubreuia avatar Sep 11 '20 22:09 dubreuia

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.

sgaertner avatar Sep 14 '20 09:09 sgaertner

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.

dubreuia avatar Sep 14 '20 11:09 dubreuia

I'd also love to see this plugin to work in Rider. 😁

andgeno avatar Jan 21 '21 16:01 andgeno

tried latetst (v 2.2.0) with installation from disk - but can't get it work (not even for the current file) - unfortunately

image

tried also the experimental from quick list

image

would love to see this plugin working in rider

kimpenhaus avatar Apr 18 '21 09:04 kimpenhaus

Not working for me either, instalation from disk Reformat Code

jlKampos avatar Apr 27 '21 10:04 jlKampos