I have multiple different StubIndex implementations, derived from "StringStubIndexExtension". I seem to be getting instances of one index returning PsiElements from another index, and I'm not quite sure how to track down how/why this might be happening. All of the index classes are listed in my plugin.xml with the <index> tag. I've checked/double checked all of my serialize/deserialze functions to make sure data is being written/read in the proper order with the proper types.
What can cause this, and what can I do to track down the issue?
Additional possibly relevant information:
One case that seems to trigger this frequently is when using FileContentUtil.reparseFiles(). More specifically:
1) The custom language I am supporting has a form of macro (#if SOMEDEFINE ... #endif)
2) I have an UI to toggle these in Intellij; doing so builds a collection of files that use said macro by querying a StubIndex for elements, and then building the list of their containing VirtualFiles
3) I pass this collection of VirtualFiles through FileContentUtil.reparseFiles() because the state of the macro value changes the way the file is parsed. Code inside of an #if/#endif block might disappear (gets turned into PsiComment during parsing), and code from a coresponding #else/#elseif block might suddenly get parsed when it previously wasn't.
My expectation is that each file should get reparsed, and a correct stub tree will be rebuilt. The issue tends to happen after the second or third reparse.