Collection<String> (@NotNull PsiFile hostFile, @Nullable PsiElement psiElementAtOffset, @Nullable PsiFile injectedFile) { Set<String> languageIds = new HashSet<>(); for (Language language : hostFile.getViewProvider().getLanguages()) { languageIds.add(language.getID()); } if (injectedFile != null) { for (Language language : injectedFile.getViewProvider().getLanguages()) { languageIds.add(language.getID()); } } if (psiElementAtOffset != null) { SequencesKt.forEach(parents(psiElementAtOffset, true), p -> { languageIds.add(p.getLanguage().getID()); return null; }); } return languageIds; }