Implementation of context navigation

I'm need to write R# plugin performs a specialized search from a class properties(R# 6x, vs2010). I've tried to use INavigateFromHereProvider

    [ActionHandler("ReSharperPlugIn1.NavigateFrom")] //binded to group-id="VS#Code Window"
    public class ClassNameNavigationAction : ContextNavigationActionBase<ClassNameContextNavigationProvider>
    { }

    public class ClassNameContextNavigationProvider : INavigateFromHereProvider
        private readonly ICSharpContextActionDataProvider _provider;

        public IEnumerable<ContextNavigation> CreateWorkflow(IDataContext dataContext)
            if (IsAvailable(dataContext))
                yield return new ContextNavigation("ClassName", "ClassNameNavigationAction", NavigationActionGroup.Other, () => Execute(dataContext));

        private void Execute(IDataContext dataContext)
            var selectionContext = dataContext.GetData(DataConstants.CurrentSelectionContext);
            var c1 = selectionContext as IType;

but I don't know how to get property as an object. In debug-mode I've called the context menu on the property's declaration and casting of "selectionContext" as IType(and others interfaces) returns null.
Please point my mistakes. Which interfaces should I use and implement to make this?

p.s. At the end results should be viewed in the window like a "Find Usages". How to do it?
Sorry for many questions, I've found out extremely little information about R# plugins and most of it are not detailed.

1 comment
Comment actions Permalink

Hi! It's very likely that CurrentSelectionContext simply isn't there, i.e. it has not been provided and you're actually getting 'null'. For a detailed implementation of a context navigation provider I suggest you check out this plugin -- the link is right to a navigation provider file, and you can navigate from there.

Hope this helps,
Dmitri Nesteruk


Please sign in to leave a comment.