I started developing a plugin at the start of the year. And will agree that it is sometimes an uphill battle. But! These have worked for me
-
https://www.youtube.com/watch?v=y8adERbgt_M I have returned to this often.
-
JetBrains/resharper-rider-plugin: https://www.jetbrains.com/help/resharper/sdk/ It has the template for creation and some ok samples to get you started. (It’s referenced in the video above)
-
Access the underlying libraries with either dot peek or the built in funcitonality in rider/resharper to decompile libraries. Much of the rider/resharper functionality can be found in this decompiled code. It has helped me a lot.
-
If you for instance have a context action up and running. Try setting a breakpoint and play around in there to test what different methods do.
But hopefully this forum can also be a help. Do you have a github repo with the current progress?
I unfortunately don’t know how to find usages of a method. But I think that what you want to do can be achived through a ContextAction.
But roughly the skeleton should be something like this
[ContextAction(
Name = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
GroupType = typeof(CSharpContextActions))]
public class FindUsagesOfParentAction : ContextActionBase
{
private readonly ICSharpContextActionDataProvider _provider;
public FindUsagesOfParentAction(ICSharpContextActionDataProvider provider)
{
_provider = provider;
}
// This is called when the user clicks the action
protected override Action<ITextControl>? ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
if (_provider.GetSelectedTreeNode<IMethodDeclaration>() is not { } methodDeclaration)
{
// Do something with this
// If you don't modify the class you are in just return null
return null;
}
return null;
}
public override string Text => "Find parent usages";
public override bool IsAvailable(IUserDataHolder cache)
{
// This might catch the outer method.
if (_provider.GetSelectedTreeNode<IMethodDeclaration>() is not { } methodDeclaration)
return false;
return true;
}
}
This should at least present you with a context action when on a method.
I hope this help just a bit.
