TextAttributes (@NotNull EditorColorsScheme scheme, TextAttributesKey @NotNull ... keys) { TextAttributes result = null; for (TextAttributesKey key : keys) { TextAttributes attributes = scheme.getAttributes(key).clone(); if (attributes == null) { continue; } if (result == null) { result = attributes; } Color currentForegroundColor = result.getForegroundColor(); if (currentForegroundColor == null) { result.setForegroundColor(attributes.getForegroundColor()); } Color currentBackgroundColor = result.getBackgroundColor(); if (currentBackgroundColor == null) { result.setBackgroundColor(attributes.getBackgroundColor()); } if (result.getForegroundColor() != null && result.getBackgroundColor() != null) { return result; } } if (result != null && result.getForegroundColor() == null) { return null; } if (result != null && result.getBackgroundColor() == null) { result.setBackgroundColor(scheme.getDefaultBackground()); } return result; }