PsiFile () { Document document = myEditor.getDocument(); PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); return Objects.requireNonNull(psiFile, () -> "Can't find a psi file for the " + document + " in " + myEditor); }