Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ _dotTrace*
/**/.idea
*/**/Packages
/**/.intellijPlatform

# NuGet tools
.nuget/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## 26.04.XXXX
- Fix issue: register `GoToHandlerAction` as a VS/ReSharper keyboard-assignable action with a default shortcut of `Alt+H`. Users can now find it in Tools > Options > Environment > Keyboard as `GoToHandlerAction`.

## 26.03.07XX
- Fix issue #93: rename `GoToHandlrAction` kotlin file to `GoToHandlerAction` since this is what is referenced in the plugin.xml file.

Expand Down
52 changes: 52 additions & 0 deletions src/dotnet/MediatorPlugin/Actions/GoToHandlerNavigationAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using JetBrains.Application.DataContext;
using JetBrains.Application.Shortcuts.ShortcutManager;
using JetBrains.Application.UI.Actions;
using JetBrains.Application.UI.ActionsRevised.Menu;
using JetBrains.Diagnostics;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Feature.Services.Navigation.ContextNavigation;
using JetBrains.ReSharper.Psi.Tree;
using ReSharper.MediatorPlugin.Diagnostics;
using ReSharper.MediatorPlugin.Services.Find;
using ReSharper.MediatorPlugin.Services.Navigation;

namespace ReSharper.MediatorPlugin.Actions;

#pragma warning disable CS0612
[Action("GoToHandlerAction", "Go to Handler", ShortcutScope = ShortcutScope.TextEditor, DefaultShortcutText = "Alt+H")]
#pragma warning restore CS0612
public class GoToHandlerNavigationAction : IExecutableAction
{
private readonly IHandlerSelector _handlerSelector = new HandlerSelector();

public bool Update(IDataContext context, ActionPresentation presentation, DelegateUpdate nextUpdate)
{
var selectedTreeNode = context.GetSelectedTreeNode<ITreeNode>();

if (selectedTreeNode is not IIdentifier identifier)
return nextUpdate.Invoke();

return _handlerSelector.IsMediatorRequestSupported(identifier);
}

public void Execute(IDataContext context, DelegateExecute nextExecute)
{
Logger.Instance.Log(LoggingLevel.INFO, "GoToHandlerNavigationAction.Execute called");

var solution = context.GetComponent<ISolution>();
var selectedTreeNode = context.GetSelectedTreeNode<ITreeNode>();

if (selectedTreeNode is not IIdentifier)
{
Logger.Instance.Log(LoggingLevel.VERBOSE, "Selected element is not an identifier");
return;
}

_handlerSelector.NavigateToHandler
(
solution,
selectedTreeNode,
new DataContextNavigationOptionsFactory(context)
);
}
}
Loading