Language (@NotNull final PsiFile file) { final Set<Language> languages = file.getViewProvider().getLanguages(); if (languages.contains(JavaLanguage.INSTANCE)) return JavaLanguage.INSTANCE; for (final Language language : languages) { if (language.isKindOf(JavaLanguage.INSTANCE)) return language; } return null; }