Parser errors on plugin update

I hope this was asked before and there is an easy solution.
Since the start of the plugin development, I got one (fortunately minor) issue very often: When I release a new version of my plugin and I have worked on the parser or the variable resolving, IDEA shows (wrong) parser errors over all opened files. Invalidating the caches (File->Invalidate Caches) and a restart fixes the problem.

Is this a known issue? Can I force IDEA to automatically re-index everything on a plugin-update?

Cheers
Patrick

5 comments
Comment actions Permalink

If you have indices or PSI stubs in your plugin, you need to increment the version (FileBasedIndexExtension.getVersion(), StubIndexExtension.getVersion() or IStubFileElementType.getStubVersion()) every time you change the PSI structure or the index format or data stored in the index. This will ensure that indexes are rebuilt.

0
Comment actions Permalink

I don't even know, whether or not it is an indexing problem. I just guessed it because restarting, combined with clearing the cache solves the problem.

I'm not aware of using any of this explicitly, although IDEA seems to index all files on start-up (when I did a clear caches). Furthermore, I remember having this issue since the very first versions, when only the basic parser worked and I had no reference resolving, autocompletion, etc..
I have a screenshot from a user having this issue after updating the plugin to a more recent version. What you see are real parser error which make no sense, since the code is correct. Btw, below in the image are some identifier blue. These are built-in functions which are highlighted using an Annotator. Therefore, it doesn't really make sense that the Annotator has a PsiTree to work on, when the parser is full of errors, does it?

So when I don't have a FileBasedIndexExtension or StubIndexExtension, could this problem be related to something else?

Sidenote: I'm caching the resolve results and other information directly in the PsiElements. This is the only memory of information I'm currently using and it is invalidated with the subtreeChanged method as discussed earlier here.

Thanks
Patrick

0
Comment actions Permalink

In that case it's very strange that Invalidate Caches has any effect. Highlighting parser errors does not use any persisted or cached information. The resolve result caching shouldn't matter here, because the errors are not coming from reference resolution.

The PSI tree is built regardless of whether the parser has produced any errors; the errors are placed as PsiErrorElement nodes in the tree. So the Annotator will get its PSI tree in any case.

Are there any exceptions in the user's log when this happens?

0
Comment actions Permalink

I'm not even sure whether it is the "clear cache" that helps or the additional restart(s) would suffice.

The PSI tree is built regardless of whether the parser has produced any errors; the errors are placed as PsiErrorElement nodes in the tree. So the Annotator will get its PSI tree in any case.

Ewww, of course I should have know this. I already worked with PsiErrorElement.

Are there any exceptions in the user's log when this happens?

No, unfortunately I haven't seen any. Otherwise, I would have investigated in the issue.

Dmitry, thank you anyway, because knowing that it shouldn't be related to clearing the cache and indexing still helps. Next time I'm seeing this issue I try to find out which steps (except of clearing cache) fix the issue. I'm not aware that I did something bad in the parser implementation, but who knows..

Cheers
Patrick

0
Comment actions Permalink

Dmitry, let me give you a final update: I found the bug; it was of course in my code and it was related to the initialization of a class which provides all the small parsers (parselets) for each kind of expression. Due to wrong initialization, the hash-maps there were corrupted and did not contain all parselets anymore.
I'm still puzzled why this happens during an update, but it seems I have fixed the issue.

Thank you for your assistence,
Patrick

0

Please sign in to leave a comment.