List<MetaLanguage> (@NotNull Language language) { List<MetaLanguage> cached = language.getUserData(MATCHING_META_LANGUAGES); if (cached != null) { return cached; } if (!ApplicationManager.getApplication().getExtensionArea().hasExtensionPoint(MetaLanguage.EP_NAME)) { // don't cache return persistentListOf(); } List<MetaLanguage> toCache; if (language instanceof MetaLanguage) { toCache = persistentListOf(); } else { Set<MetaLanguage> result = new HashSet<>(); MetaLanguage.EP_NAME.forEachExtensionSafe(metaLanguage -> { if (metaLanguage.matchesLanguage(language)) { result.add(metaLanguage); } }); toCache = result.isEmpty() ? persistentListOf() : toPersistentList(result); } language.putUserData(MATCHING_META_LANGUAGES, toCache); return toCache; }