public class MyVisitor extends PsiElementVisitor { @Override public void visitElement(PsiElement element) { // Do some operations on the element } } // Visit all elements of the PSI tree PsiFile file = ... // Get a PsiFile object file.accept(new MyVisitor());
public class MyVisitor extends PsiElementVisitor { @Override public void visitVariable(PsiVariable variable) { if (variable.getType().equals(PsiType.BOOLEAN)) { // Do some operations on the boolean variable } } } // Visit only boolean variables in the PSI tree PsiFile file = ... // Get a PsiFile object file.accept(new MyVisitor());The com.intellij.psi package is part of the IntelliJ IDEA platform SDK.