UserData lifecycle

There are various caches that are mediated through UserDataHolder.  Especially frequently the PyFile is tagged with some data.  I'm wondering what's the lifecycle of these caches especially with respect to PyFile.  When are these caches cleared? Is there a way to force clear these caches? Do stubs inherit the caches of the corresponding PyFile objects?

1 comment
Comment actions Permalink

There is no automatic mechanism that would clear the userdata of a PSI element. Normally it lives as long as the element itself, which for a PsiFile can be the entire IDE usage session.

If you need to store a value in UserData that depends on other things (such as the contents of the file itself), you can use CachedValuesManager.createCachedValue() and specify the dependencies for the value.

There is no mechanism to copy UserData between PSI elements and the corresponding stubs.


Please sign in to leave a comment.