remove usages of deprecated ColorKey.getFallbackColorKey

GitOrigin-RevId: 18831b8b5507dc601db12e968b6ff4818d8ef158
This commit is contained in:
Alexey Kudravtsev
2019-06-13 18:11:35 +03:00
committed by intellij-monorepo-bot
parent 7066385bb4
commit 1469637c54
4 changed files with 6 additions and 71 deletions
@@ -725,15 +725,6 @@ public abstract class AbstractColorsScheme extends EditorFontCacheImpl implement
private void writeColor(@NotNull Element colorElements, @NotNull ColorKey key) {
Color color = myColorsMap.get(key);
if (color == INHERITED_COLOR_MARKER) {
ColorKey fallbackKey = key.getFallbackColorKey();
Color parentFallback = myParentScheme instanceof AbstractColorsScheme ?
((AbstractColorsScheme)myParentScheme).getDirectlyDefinedColor(key) : null;
boolean parentOverwritingInheritance = parentFallback != null && parentFallback != INHERITED_COLOR_MARKER;
if (fallbackKey != null && parentOverwritingInheritance) {
colorElements.addContent(new Element(OPTION_ELEMENT)
.setAttribute(NAME_ATTR, key.getExternalName())
.setAttribute(BASE_ATTRIBUTES_ATTR, fallbackKey.getExternalName()));
}
return;
}
@@ -860,17 +851,9 @@ public abstract class AbstractColorsScheme extends EditorFontCacheImpl implement
@Nullable
protected Color getFallbackColor(@NotNull ColorKey fallbackKey) {
ColorKey cur = fallbackKey;
while (true) {
Color color = getDirectlyDefinedColor(cur);
if (color == NULL_COLOR_MARKER) return null;
ColorKey next = cur.getFallbackColorKey();
if (color != null && (color != INHERITED_COLOR_MARKER || next == null)) {
return color;
}
if (next == null) return null;
cur = next;
}
Color color = getDirectlyDefinedColor(fallbackKey);
if (color == NULL_COLOR_MARKER) return null;
return color;
}
/**
@@ -70,14 +70,8 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl
Color color = myColorsMap.get(key);
if (color != null) return color == NULL_COLOR_MARKER ? null : color;
ColorKey fallbackKey = key.getFallbackColorKey();
Color fallback = fallbackKey == null ? null : getFallbackColor(fallbackKey);
if (fallback != null && fallback != AbstractColorsScheme.INHERITED_COLOR_MARKER) return fallback;
if (!useDefaults) return null;
Color keyDefaults = key.getDefaultColor();
if (keyDefaults != null) return keyDefaults;
return fallbackKey == null ? null : fallbackKey.getDefaultColor();
return key.getDefaultColor();
}
@Override
@@ -97,14 +97,6 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
if (color != null && color != INHERITED_COLOR_MARKER) {
return color;
}
ColorKey fallbackKey = key.getFallbackColorKey();
if (fallbackKey != null) {
color = getFallbackColor(fallbackKey);
if (color != null) {
return color;
}
}
}
return myParentScheme.getColor(key);
}
@@ -35,7 +35,6 @@ import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
import com.intellij.psi.search.scope.packageSet.PackageSet;
import com.intellij.util.EventDispatcher;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
@@ -817,26 +816,11 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
super(name, group, colorKey.getExternalName(), scheme, null, null);
myColorKey = colorKey;
myKind = kind;
ColorKey fallbackKey = myColorKey.getFallbackColorKey();
Color fallbackColor = null;
if (fallbackKey != null) {
fallbackColor = scheme.getColor(fallbackKey);
myBaseAttributeDescriptor = ColorSettingsPages.getInstance().getColorDescriptor(fallbackKey);
if (myBaseAttributeDescriptor == null) {
myBaseAttributeDescriptor = Pair.create(null, new ColorDescriptor(fallbackKey.getExternalName(), fallbackKey, myKind));
}
myFallbackAttributes = new TextAttributes(myKind == ColorDescriptor.Kind.FOREGROUND ? fallbackColor : null,
myKind == ColorDescriptor.Kind.BACKGROUND ? fallbackColor : null,
null, null, Font.PLAIN);
}
myColor = scheme.getColor(myColorKey);
myInitialColor = ObjectUtils.chooseNotNull(fallbackColor, myColor);
myInitialColor = myColor;
myIsInheritedInitial = scheme.isInherited(myColorKey);
myIsInheritedInitial = false;
setInherited(myIsInheritedInitial);
if (myIsInheritedInitial) {
//setInheritedAttributes(getTextAttributes());
}
initCheckedStatus();
}
@@ -1121,24 +1105,6 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
return false;
}
public boolean isInherited(ColorKey key) {
ColorKey fallbackKey = key.getFallbackColorKey();
if (fallbackKey != null) {
if (myParentScheme instanceof AbstractColorsScheme) {
Color ownAttrs = ((AbstractColorsScheme)myParentScheme).getDirectlyDefinedColor(key);
if (ownAttrs != null) {
return ownAttrs == AbstractColorsScheme.INHERITED_COLOR_MARKER;
}
}
Color attributes = getColor(key);
if (attributes != null) {
Color fallback = getColor(fallbackKey);
return attributes == fallback;
}
}
return false;
}
public void resetToOriginal() {
if (myParentScheme instanceof AbstractColorsScheme) {
AbstractColorsScheme originalScheme = ((AbstractColorsScheme)myParentScheme).getOriginal();