Add a Navigation Action to the 'Navigate to' Menu
What you should know beforehand:
Examples (?):
If you want your navigation to appear in ReSharper's Navigate To menu (context navigation), you should create an action that implements the INavigateFromHereProvider
interface.
For example, let's create a context-dependent navigation that navigates to a class constructor. The initial caret position can be anywhere inside that class.
Notes
The class must implement the
INavigateFromHereProvider
interface and be marked with theContextNavigationProvider
attribute.GetSelectedTreeNode<ITreeNode>()
method ofIDataContext
return the tree node under the current caret position.We use the
GetParentOfType
method from Use Manual Navigation to obtain theIClassDeclaration
node.The
IClassDeclaration
class provides theConstructorDeclarations
property that returns an enumerable with class constructors.A created instance of the
ContextNavigation
class describes the navigation feature:"Constructor"
: the name of the item that appears in the Navigate to context menu.null
: action ID.NavigationGroup.Other
: defines the location in the Navigate to menu where the action should be placed.The last one argument is the action that is run once the Constructor item is selected in the Navigate to menu.
Note that ReSharper automatically decides whether to display the item in the menu or not.