I am working on a plugin to make IDEA aware of classes and interfaces generated by an annotation processor without building the project.
I already implemented the basic required classes to do that (thanks to Colin Fleming reply to my previous post).
Now, I would like to cache the generated PsiClass because they do not change as long as the file/class from the which the generated PsiClass does not change either.
Filebased-indexes seems to be the right tool for the job as they already implement the logic of refreshing their content when a VirtualFile changes. But having PsiClass as value requires to be able to serialize them to a binary format. Is it a good idea at all (serializing a PsiClass)? Does a PsiClass serializer implementation already exist somewhere?
I had a look at stub indexes but after looking at the doc and deeply at the source code I figured I cannot use one because my generated classes/interfaces are not backed by their own VirtualFile.
I thought about implementing a handradfted cache as Project component but, looking at the code of the StubIndexImpl class, I see that keeping a cache up to date with a VirtualFile content is a tricky job. I would rather leverage the existing solutions.
Thank you in advance for any insight.