This page gives recipes for the most common operations for working with the PSI (Program Structure Interface).
Unlike Developing Custom Language Plugins, it is about working with the PSI of existing languages (such as Java).
See also the PSI Performance section.
General How do I find a file if I know its name but don't know the path?FilenameIndex.getFilesByName()
RefactoringFactory.createRename()
FileContentUtil.reparseFiles()
If your plugin depends on Java functionality, see Java. Also consider using UAST if your plugin supports other JVM languages.
How do I find all inheritors of a class?ClassInheritorsSearch.search()
PsiShortNamesCache.getClassesByName()
OverridingMethodsSearch.search()
Extend JavaElementVisitor
or JavaRecursiveElementVisitor
and override relevant method(s). Pass it to PsiElement.accept()
of the parent PSI element (for example, PsiClass
or PsiMethod
).
Use dedicated (and heavily cached) methods from JavaLibraryUtil
:
hasLibraryClass()
to check presence via known library class FQN
hasLibraryJar()
using Maven coordinates (for example, io.micronaut:micronaut-core
).
07 May 2025
Modifying the PSIPSI PerformanceRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4