2

How we can find all the references of an existing PsiElement. Specifically a SwiftFunctionDeclaration. I've tried with

ReferencesSearch.search(functionDeclaration, ProjectScope.getProjectScope(functionDeclaration.getProject())).findAll();

But it will not work if the method is an interface method, and it's accessed through Protocol reference instead of concrete class.

Example:

protocol Test {
func calculate()
}

class TestingClass : Test {
func calculate() {
 }
}

So if I'm using something like that, let s = TestingClass(), s.calculate() it will find that calculate method has references. But if I'm softening the reference let s: Test = TestingClass(), s.calculate() it will tell me that calculate method inside of TestClass doesn't have any references.

The question is: is there an API which will give me the references even if used through Protocol. If not, is there possible to find if a SwiftFunctionDeclaration is an implementation method of a specific Protocol?

Vadim Salajan
  • 145
  • 1
  • 9

0 Answers0