How to collect certain Psi-Model nodes (e.g. all PsiClass nodes) from the whole project?
Answered
Hi,
as the title says: I'd like to collect PSI model nodes of certain types from the whole project (e.g. all PsiClass nodes, all PsiMethod nodes, all PsiAnnotation nodes, etc.) in dedicated sets.
1. What is a apropiate startpoint? An instance of com.intellij.openapi.project?
2. How's the traversal done?
Thx in advance
Kai
Please sign in to leave a comment.
com.intellij.psi.search.PsiShortNamesCache has some utility methods. Please explain your use case in more detail, there might be more suitable API.
Hi Yann,
thx for repling!
The sets of nodes are required to build domains for constraint solver variables. Depending on what constraints are used, different sets (aka domains) are needed. Therefore I need methods to collect nodes from the underlaying model (usually some kind of attributed AST). Cause I'm fairly new to IDEA's concepts, I need nodes from the model which is usually used to perform refactorings (Add, move, delete nodes, etc.). Generally, this is done by implementing some visitors, but I'd like to now the IDEA way...
Regards
Kai
The IDE way is to use to the PSI the IDE provides over the sources. See http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi.html for an introduction.