PsiElement parent = // some parent element PsiElement child = parent.getFirstChild(); if (child != null) { // do something with child element }
PsiClass psiClass = // some PsiClass element PsiElement child = psiClass.getFirstChild(); int count = 0; while (child != null && count < 10) { // do something with child element child = child.getNextSibling(); count++; }This example retrieves the first child element of a given PsiClass element and iterates through the next 10 sibling elements, performing some action with each one. The com.intellij.psi package library provides a set of interfaces and classes for working with the PSI (Program Structure Interface) of a project in IntelliJ IDEA. It is included in the IntelliJ Platform SDK.