BraceMatcher (@NotNull FileType fileType, @NotNull Language lang) { PairedBraceMatcher matcher = LanguageBraceMatching.INSTANCE.forLanguage(lang); if (matcher != null) { if (matcher instanceof XmlAwareBraceMatcher) { return (XmlAwareBraceMatcher)matcher; } else if (matcher instanceof PairedBraceMatcherAdapter) { return (BraceMatcher)matcher; } else { return new PairedBraceMatcherAdapter(matcher, lang); } } BraceMatcher byFileType = getBraceMatcherByFileType(fileType); if (byFileType != null) return byFileType; if (fileType instanceof LanguageFileType) { Language language = ((LanguageFileType)fileType).getLanguage(); if (lang != language) { FileType type1 = lang.getAssociatedFileType(); if (type1 != null) { BraceMatcher braceMatcher = getBraceMatcherByFileType(type1); if (braceMatcher != null) { return braceMatcher; } } matcher = LanguageBraceMatching.INSTANCE.forLanguage(language); if (matcher != null) { return new PairedBraceMatcherAdapter(matcher, language); } } } return BraceMatcherHolder.ourDefaultBraceMatcher; }