public static @Nullable PsiFile getCachedInjectedFileWithLanguage(@NotNull PsiElement element, @NotNull Language language) {
    if (!element.isValid()) return null;
    PsiFile containingFile = PsiUtilCore.getTemplateLanguageFile(element.getContainingFile());
    if (containingFile == null || !containingFile.isValid()) return null;
    return InjectedLanguageManager.getInstance(containingFile.getProject())
      .getCachedInjectedDocumentsInRange(containingFile, element.getTextRange())
      .stream()
      .map(documentWindow -> PsiDocumentManager.getInstance(containingFile.getProject()).getPsiFile(documentWindow))
      .filter(file -> file != null && file.getLanguage() == LanguageSubstitutors.getInstance()
        .substituteLanguage(language, file.getVirtualFile(), file.getProject()))
      .max(LONGEST_INJECTION_HOST_RANGE_COMPARATOR)
      .orElse(null);
  }
public static @Nullable PsiFile getCachedInjectedFileWithLanguage(@NotNull PsiElement element, @NotNull Language language)