Child pages
  • IntelliJ IDEA Architectural Overview

Versions Compared

Key

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

...

Traverse the file system, get file contents, rename, move, delete - typical file operations.

Recursive iteration should be performed using VfsUtilCore.iterateChildrenRecursively to prevent endless loops caused by recursive symlinks.

Where does it come from?

The VFS is built incrementally, by scanning the file system up and down starting from the project root. New files appearing in the file system are detected by VFS refreshes. A refresh operation can be initiated programmatically using (VirtualFileManager.getInstance().refresh() or VirtualFile.refresh()). VFS refreshes are also caused by the file system change notifications received by file system watchers (availble for the Windows and Mac operating systems).

...

To iterate over the elements in a file, use psiFile.accept(new PsiRecursiveElementVisitorPsiRecursiveElementWalkingVisitor()...);

Where does it come from?

...

  • From an action: e.getData(LangDataKeys.PSI_ELEMENT). Note: if an editor is currently open and the element under caret is a reference, this will return the result of resolving the reference. This may or not be what you need.
  • From a file by offset: PsiFile.findElementAt(). Note: this returns the lowest level element at the specified offset, which is normally a lexer token. You most likely need to use PsiTreeUtil.getParentOfType() to find the element you really need.
  • By iterating through a PSI file: using a PsiRecursiveElementVisitor PsiRecursiveElementWalkingVisitor.
  • By resolving a reference: PsiReference.resolve()

...