Child pages
  • IntelliJ IDEA Architectural Overview

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


To access an individual PSI element, you must first get a PSI file and then get a PSI treethat tree that contains this element. Note, that PSI trees are language-dependent.
Like PSI files, PSI elements are created on demand when the PSI is accessed for a particular file.


To access a PSI tree within a PSI file, use File View Provider :
where the language parameter takes values of the Language type defined in StdLanguages class. For example, to get the PSI tree for XML, use psiFile.getViewProvider().getPsi(StdLanguages.XML).

Getting Individual Elements from PSI Tree

Most interesting modification operations are performed on the level of individual PSI elements, not files as a whole.

  • To iterate over the elements in a PSI tree, use psiFile.accept(new PsiRecursiveElementVisitor()...)
  • To find a PSI element of a particular language at the specified offset in the PSI file, use psiFile.getViewProvider().findElementAt(offset,language)
  • To get child elements of a PSE tree in a particular language, use psiFile.getViewProvider().getPsi(language).getChildren()

What can I do with one?

  • To find a PSI file to which this PSI element belongs, use psiElement.getContainingFile()
  • To get child elements of a PSI element, use psiElement.getChildren()