Find references to a property

Hi

In the R# plugin I'm trying to build, I need to find all references to a particular accessor/property. I have tried numerous way to get this info out of the API with no luck. When I instead trying to do the same with a plain method instead, I have no problem finding the references.

If I have a IAccessorDeclaration, how can I get all references in the solution pointing to this property (getter or setter doesn't matter)?
I've tried "all the ways" I've found in your API, like...
accessorDeclaration.GetReferences();
accessorDeclaration.GetSecondClassReferences();
solution.GetPsiServices().Finder.FindReferences(accessorDeclaration.DeclaredElement, searchDomain, myProgress);
...but whatever I try, no references can be found.

How can I find all references pointing to property?

Regards
Roger

2 comments
Comment actions Permalink

Hi, I’ve just tried using the

Finder
to locate the usages of a property, and it seems to work just fine. Here is the code I used:
var propDecl = _provider.GetSelectedElement<IPropertyDeclaration>(true, true);
var finder = _provider.PsiServices.Finder;
var references = finder.FindReferences(
   propDecl.DeclaredElement,
   SearchDomainFactory.Instance.CreateSearchDomain(_provider.SourceFile.ToProjectFile()),
   NullProgressIndicator.Instance);

Hope this helps,
Dmitri

0
Comment actions Permalink

Thanks!

The main problem for me was that I used IAccessorDeclaration instead of IPropertyDeclaration.

0

Please sign in to leave a comment.