private static @NotNull PsiFile getContainingFile(@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;
    }
  }
private static @NotNull PsiFile getContainingFile(@NotNull PsiElement psiElement)