private static Language findLanguage(@NotNull Language baseLanguage, @NotNull FileViewProvider viewProvider) {
    final Set<Language> languages = viewProvider.getLanguages();
    Language candidate = null;
    for (final Language actualLanguage : languages) {
      if (actualLanguage.equals(baseLanguage)) {
        return baseLanguage;
      }
      if (candidate == null && actualLanguage.isKindOf(baseLanguage)) {
        candidate = actualLanguage;
      }
    }
    if (candidate != null) {
      return candidate;
    }
    throw new AssertionError(
        "Language " + baseLanguage + " doesn't participate in view provider " + viewProvider + ": " + new ArrayList<>(languages));
  }
private static Language findLanguage(@NotNull Language baseLanguage, @NotNull FileViewProvider viewProvider)