JBIterable<Language> (@Nullable PsiFile psiFile) { if (psiFile == null) return JBIterable.empty(); FileViewProvider viewProvider = psiFile.getViewProvider(); Language baseLanguage = viewProvider.getBaseLanguage(); Language dataLanguage = viewProvider instanceof TemplateLanguageFileViewProvider ? ((TemplateLanguageFileViewProvider)viewProvider).getTemplateDataLanguage() : null; return JBIterable.of(baseLanguage) .append(dataLanguage) .append(viewProvider.getLanguages()) .unique() .filter(language -> { PsiFile psi = viewProvider.getPsi(language); return psi != null && (language == baseLanguage || isAcceptableBaseLanguageFile(psi)); }); }