Lifecycle of PSI reference / Best way to find elements in a tree

Hi all,  Just wondering what is lifecycle of PSI reference?

Is it OK to  walk complete PSI tree on resolving reference, or shall I cache results somewhere?

What method shall I use to get PSI tags mathicng certain  value pattern?

2 comments

A lifecycle of a PSI reference is determined by the language that provides it; there is no common rule. Some languages create PsiReferences on demand, others implement PsiReference on the same class that implements PsiElement and return the same object.

Caching the results of resolving a reference is strongly recommended. You can use the ResolveCache class for this purpose.

Not sure about your last question. Depending on what exactly you need to accomplish, it may make sense to implement an index for the specific PSI elements that you need to find.

0

Be sure to check out the FAQ page - http://confluence.jetbrains.com/display/IDEADEV/Plugin+Development+FAQ

This question has been asked under the heading of 'Accessing and Modifying the Source Code', here is the direct link - http://devnet.jetbrains.com/thread/251579

Alan

0

Please sign in to leave a comment.