TextAttributesKey (@Nullable Language language) { Stack<Language> languages = new Stack<>(); while (language != null && language != Language.ANY) { languages.push(language); language = language.getBaseLanguage(); } TextAttributesKey currentKey = INJECTED_LANGUAGE_FRAGMENT; while(!languages.empty()) { Language current = languages.pop(); currentKey = TextAttributesKey.createTextAttributesKey( current.getID() + ":INJECTED_LANGUAGE_FRAGMENT", currentKey); } return currentKey; }