FileType (@NotNull FileType type) { if (super.forFileType(type) != null) return type; while (type instanceof LanguageFileType) { Language language = ((LanguageFileType)type).getLanguage(); Language baseLanguage = language.getBaseLanguage(); if (baseLanguage == null) break; FileType baseFileType = FileTypeRegistry.getInstance().findFileTypeByLanguage(baseLanguage); if (baseFileType == null) break; if (super.forFileType(baseFileType) != null) return baseFileType; type = baseFileType; } return null; }