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>

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.

Comment actions Permalink

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"/>

Comment actions Permalink

This is exactly what I was looking for! Thanks!


Please sign in to leave a comment.