TextAttributesKey (@NonNls @NotNull String externalName, @Nullable TextAttributesKey oldKey, TextAttributes defaultAttributes, TextAttributesKey fallbackAttributeKey) { if (oldKey == null) { return new TextAttributesKey(externalName, defaultAttributes, fallbackAttributeKey); } // ouch. Someone's re-creating already existing key with different attributes. // Have to re-create the new one with correct attributes, re-insert to the map // but don't allow to rewrite not-null fallback key if (oldKey.myFallbackAttributeKey != null && !oldKey.myFallbackAttributeKey.equals(fallbackAttributeKey)) { LOG.error(new IllegalStateException("TextAttributeKey(name:'" + externalName + "', fallbackAttributeKey:'" + fallbackAttributeKey + "') " + " was already registered with the other fallback attribute key: " + oldKey.myFallbackAttributeKey)); } // but don't allow to rewrite not-null default attributes if (oldKey.myDefaultAttributes != null && !oldKey.myDefaultAttributes.equals(defaultAttributes)) { LOG.error(new IllegalStateException("TextAttributeKey(name:'" + externalName + "', defaultAttributes:'" + defaultAttributes + "') " + " was already registered with the other defaultAttributes: " + oldKey.myDefaultAttributes)); } TextAttributes newDefaults = ObjectUtils.chooseNotNull(defaultAttributes, oldKey.myDefaultAttributes); // care with not calling unwanted providers TextAttributesKey newFallback = ObjectUtils.chooseNotNull(fallbackAttributeKey, oldKey.myFallbackAttributeKey); return new TextAttributesKey(externalName, newDefaults, newFallback); }