PsiFile (@NotNull PsiFile file) { if (!file.isValid()) { PsiFile fileToUse = PsiUtilCore.getPsiFile(myProject, file.getViewProvider().getVirtualFile()); CodeFormattingData.copy(file, fileToUse); return fileToUse; } return file; }