How do I create a virtual implementation for an interface from an xml document?

Say, I have an interface like

interface SomeInterface {
    List<MyEntity> getEntities();
}


And an xml file like

<impl for="SomeInterface">
    <method name="getEntities"> <!-- some magic here --> </method>
</impl>


Now, how do I pretend that my xml file is an implementation of SomeInterface, i.e. when I hit Ctrl+Alt+B (jump to implementation(s)) I jump right into my xml file <impl>, or <method> tag, depending on where we had invoked our Ctrl+Alt+B.
I guess I should create a virtual PsiClass for each xml 'implementation' and somehow manage changes in xml so that they are reflected in my virtual PsiClass. Maybe you can show me features/plugins that do something like this, so that I could see examples.

2 comments

You can implement custom QueryExecutor:

public class MyImplementationSearcher extends QueryExecutorBase<PsiElement,  PsiElement> {
  public void processQuery(PsiElement element, Processor<PsiElement> consumer) {
    //...
  }
}


and register it as a definitionsSearch extension:

<definitionsSearch implementation="MyImplementationSearcher"/>

0

This is exactly what I was looking for! Thanks!

0

Please sign in to leave a comment.