Add reformat support to Rider
See original GitHub issueI 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 https://github.com/bobvandevijver/intellij-plugin-save-actions/commit/0a1d0afd4a2984381e0016de3e0ebedb1dcd368d 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)
_Originally posted by @bobvandevijver in https://github.com/dubreuia/intellij-plugin-save-actions/issues/18#issuecomment-426065888_
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
(copy pasted issue comments from #18 for clarity)
Please consider this code: https://github.com/JetBrains/resharper-unity/blob/183/rider/src/main/kotlin/com/jetbrains/rider/plugins/unity/SaveAllTracker.kt#L23 If we use this datacontext (inside
beforeActionPerformed
), instead of active editor to datacontext, then all dirty files should get formatted and saved.