How do I parse a non persistent file?

Hello,
I'm trying to create a plugin to produce a report that summaries all implementations of all implementations of a method. I don't want the report to be persistent, so I created a custom VirtualFile and VirtualFileSystem with most of the methods stubbed out.

While I have most of the functionality working, I would like to be able to cross reference from the report back to the original methods. One way of achieving this, is to create the report in Java syntax:

// report on implmenentations of method Base.foo()
//
class _ { _() {

// [Show implementation of method in a form that supports 'Goto Declaration' (will get an error indicator since
// it's not a static method but that's ok).]
Impl1.foo();
//
// doThis();
// doThat();

Impl2.foo();
// callSomethingElse();

...
}}

The catch is, that while I can create the report and open it in an editor tab, the editor tab appears with red ring, indicating that the file is not part of the project and there's no PsiFile associated with the Document. Hunting around, I've not found a plugin that tries to do this kind of thing.

So my first questions are:

  • How do I create a non-persistent file that is treated as part of the project, gains a PSI representation and so can support Goto Declaration?

  • Is the approach taken aeasonable one or are there easier ways of doing this?


Thanks,
Steve.

Please sign in to leave a comment.