Is it possible to get two instances of the same PsiElement?

Does IntelliJ platform guarantee that we always obtain the same PSI instance for the same node?

0
2 comments
Official comment

Yes, at least for the physical PSI (based on document and AST). There are some cases of non-physical PSI to represent non-code elements, they sometimes allow duplication and implement equals/hashCode.

Note that PSI can be garbage-collected, then, of course, it will be recreated the next time it's needed.

Avatar
Permanently deleted user

Thanks!

0

Please sign in to leave a comment.