# PSI Elements

> For the complete documentation index, see [llms.txt](https://plugins.jetbrains.com/docs/intellij/llms.txt).

A PSI (Program Structure Interface) file represents a hierarchy of PSI elements (so-called PSI trees). A single [PSI file](psi-files.html) (itself being a PSI element) may expose several PSI trees in specific programming languages (see [File View Providers](file-view-providers.html)). A PSI element, in its turn, can have child PSI elements.

PSI elements and operations at the level of individual PSI elements are used to explore the source code's internal structure as it is interpreted by the IntelliJ Platform. For example, PSI elements can be used to perform code analysis, such as [code inspections](https://www.jetbrains.com/help/idea/code-inspection.html) or [intention actions](https://www.jetbrains.com/idea/help/intention-actions.html).

[PsiElement](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/core-api/src/com/intellij/psi/PsiElement.java) is the common base for PSI elements.

> **Tip:**
> PSI classes for specific languages usually start with a language prefix, for example, [JsonArray](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/json/gen/com/intellij/json/psi/JsonArray.java).
>
>
>
> The Java PSI API, developed many years ago when there was no plan to support other languages, uses the `Psi` prefix, for example, [PsiIdentifier](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/java/java-psi-api/src/com/intellij/psi/PsiIdentifier.java) or [PsiElementFactory](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/java/java-psi-api/src/com/intellij/psi/PsiElementFactory.java). Don't confuse Java with the core PSI API.
>
>
>
> To use Java PSI API, [add a dependency](plugin-dependencies.html) on the Java plugin.

## How do I get a PSI element?

| Context | API |
| --- | --- |
| [Action](action-system.html) | [AnActionEvent.getData(CommonDataKeys.PSI_ELEMENT)](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java)  Note: If an editor is currently open and the element under caret is a [reference](psi-references.html), this will return the result of resolving the reference.   |
| [PSI File](psi-files.html) | [PsiFile.findElementAt(offset)](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/core-api/src/com/intellij/psi/PsiFile.java) - This returns a leaf element at the specified offset, normally a lexer token. Use `PsiTreeUtil.getParentOfType()` to find the element of the exact type.  [PsiRecursiveElementWalkingVisitor](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/core-api/src/com/intellij/psi/PsiRecursiveElementWalkingVisitor.java)   |
| [Reference](psi-references.html) | [PsiReference.resolve()](https://github.com/JetBrains/intellij-community/tree/idea/263.7307.200/platform/core-api/src/com/intellij/psi/PsiReference.java) |

## What can I do with PSI elements?

See [PSI Cookbook](psi-cookbook.html) and [Modifying the PSI](modifying-psi.html).

