PsiFile file = PsiManager.getInstance(project).findFile(virtualFile); Project project = file.getProject(); System.out.println("Project name: " + project.getName());
PsiElement element = ... // some PSI element Project project = element.getProject(); Document document = PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile());This example retrieves the project that contains a given PsiElement and retrieves the document for the file containing that element using the PsiDocumentManager. Package library: The com.intellij.psi library belongs to the IntelliJ IDEA platform SDK.