PsiFile (@NotNull PsiElement psiElement) { PsiFile topLevelFile = InjectedLanguageManager.getInstance(psiElement.getProject()).getTopLevelFile(psiElement); FileViewProvider topLevelViewProvider = topLevelFile.getViewProvider(); if (InjectionUtils.shouldFormatOnlyInjectedCode(topLevelViewProvider)) { return psiElement.getContainingFile(); } else { return topLevelFile; } }