private static @NotNull Language getLanguage(@NotNull Caret caret, @NotNull PsiFile file) {
    Language language = PsiUtilBase.getLanguageInEditor(caret, file.getProject());
    return language != null ? language : file.getLanguage();
  }
private static @NotNull Language getLanguage(@NotNull Caret caret, @NotNull PsiFile file)