Interface PsiFile

All Superinterfaces:
PsiElement
All Known Subinterfaces:
PsiBinaryFile, PsiPlainTextFile

public interface PsiFile extends PsiElement
A PSI element representing a file.

Please see IntelliJ Platform Architectural Overview for high-level overview.

See Also:
  • com.intellij.openapi.actionSystem.LangDataKeys#PSI_FILE
  • PsiElement.getContainingFile()
  • PsiManager#findFile(VirtualFile)
  • PsiDocumentManager#getPsiFile(com.intellij.openapi.editor.Document)
  • Field Details

    • EMPTY_ARRAY

      static final PsiFile[] EMPTY_ARRAY
      The empty array of PSI files which can be reused to avoid unnecessary allocations.
  • Method Details

    • getModificationStamp

      long getModificationStamp()
      Gets the modification stamp value. Modification stamp is a value changed by any modification of the content of the file. Note that it is not related to the file modification time.
      Returns:
      the modification stamp value
      See Also:
      • VirtualFile#getModificationStamp()
    • getOriginalFile

      @NotNull @NotNull PsiFile getOriginalFile()
      If the file is a non-physical copy of a file, returns the original file which had been copied. Otherwise, returns the same file.
      Returns:
      the original file of a copy, or the same file if the file is not a copy.
    • getPsiRoots

      @Deprecated @NotNull @NotNull PsiFile[] getPsiRoots()
      Deprecated.
      Use FileViewProvider#getAllFiles() instead.
      If the file contains multiple interspersed languages, returns the roots for PSI trees for each of these languages. (For example, a JSPX file contains JSP, XML and Java trees.)
      Returns:
      the array of PSI roots, or a single-element array containing this if the file has only a single language.
    • subtreeChanged

      void subtreeChanged()
      Called by the PSI framework when the contents of the file changes. If you override this method, you must call the base class implementation. While this method can be used to invalidate file-level caches, it is more much safe to invalidate them in clearCaches() since file contents can be reloaded completely (without any specific subtree change) without this method being called.
    • clearCaches

      default void clearCaches()
      Invalidate any file-specific cache in this method. It is called on file content change. If you override this method, you must call the base class implementation.