Support named colors in ThemeJsonCompletionContributor

This commit is contained in:
Yaroslav Pankratyev
2018-10-15 20:43:14 +07:00
parent e08898d70e
commit 369f8f3eed
2 changed files with 198 additions and 2 deletions
@@ -107,7 +107,7 @@ public class ThemeJsonCompletionContributor extends CompletionContributor {
conditionFilter = key -> key.startsWith(presentNamePart);
mapFunction = key -> key.substring(presentNamePart.length() + 1); // + 1 for dot
}
return UiDefaultsHardcodedKeys.UI_DEFAULTS_KEYS.stream()
return UiDefaultsHardcodedKeys.ALL_KEYS.stream()
.filter(conditionFilter)
.map(mapFunction)
.map(key -> createLookupElement(key, shouldSurroundWithQuotes))
@@ -4,10 +4,18 @@ package org.jetbrains.idea.devkit.completion;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.ApiStatus;
import java.awt.*;
import java.util.Set;
/**
* @see ThemeJsonCompletionContributor
* @see javax.swing.UIDefaults
* @see com.intellij.ui.JBColor#namedColor(String, Color)
* @see com.intellij.ui.JBColor#namedColor(String, int)
*/
@ApiStatus.Experimental
public final class UiDefaultsHardcodedKeys { //TODO move
public final class UiDefaultsHardcodedKeys {
// hardcoded because these keys can differ from platform to platform and from theme to theme.
public static final Set<String> UI_DEFAULTS_KEYS = Sets.newHashSet(
"AATextInfoPropertyKey",
"AbstractButton.click.textAndMnemonic",
@@ -1123,5 +1131,193 @@ public final class UiDefaultsHardcodedKeys { //TODO move
"window",
"windowBorder",
"windowText"
);
public static final Set<String> NAMED_COLORS = Sets.newHashSet(
"ActionButton.hoverBackground",
"ActionButton.hoverBorderColor",
"ActionButton.pressedBackground",
"ActionButton.pressedBorderColor",
"Borders.ContrastBorderColor",
"Borders.color",
"Button.darcula.defaultEndColor",
"Button.darcula.defaultFocusedOutlineColor",
"Button.darcula.defaultShadowColor",
"Button.darcula.defaultStartColor",
"Button.darcula.disabledOutlineColor",
"Button.darcula.endColor",
"Button.darcula.focusedOutlineColor",
"Button.darcula.outlineDefaultEndColor",
"Button.darcula.outlineDefaultStartColor",
"Button.darcula.outlineEndColor",
"Button.darcula.outlineStartColor",
"Button.darcula.shadowColor",
"Button.darcula.smallComboButtonBackground",
"Button.darcula.startColor",
"ComboBox.darcula.arrowButtonBackground",
"ComboBox.darcula.arrowButtonDisabledForeground",
"ComboBox.darcula.arrowButtonForeground",
"ComboBox.darcula.editable.arrowButtonBackground",
"ComboBox.darcula.nonEditableBackground",
"ComboBox.disabledForeground",
"CompletionPopup.background",
"CompletionPopup.foreground",
"CompletionPopup.grayedForeground",
"CompletionPopup.matchForeground",
"CompletionPopup.matchSelectedForeground",
"CompletionPopup.selectedForeground",
"CompletionPopup.selectedGrayedForeground",
"CompletionPopup.selectionBackground",
"CompletionPopup.selectionInactiveBackground",
"DragAndDrop.backgroundBorderColor",
"DragAndDrop.backgroundColor",
"DragAndDrop.foregroundColor",
"Editor.background",
"Editor.foreground",
"Editor.shortcutForeground",
"EditorTabs.active.background",
"EditorTabs.active.foreground",
"EditorTabs.active.underlineColor",
"EditorTabs.borderColor",
"EditorTabs.inactive.maskColor",
"FileColor.Blue",
"FileColor.Green",
"FileColor.Orange",
"FileColor.Rose",
"FileColor.Violet",
"FileColor.Yellow",
"FlameGraph.JVMBackground",
"FlameGraph.JVMFocusBackground",
"FlameGraph.JVMFocusSearchNotMatchedBackground",
"FlameGraph.JVMSearchNotMatchedBackground",
"FlameGraph.frameForeground",
"FlameGraph.nativeBackground",
"FlameGraph.nativeFocusBackground",
"FlameGraph.nativeFocusSearchNotMatchedBackground",
"FlameGraph.nativeSearchNotMatchedBackground",
"FlameGraph.parentBackground",
"FlameGraph.parentFocusBackground",
"FlameGraph.parentFocusSearchNotMatchedBackground",
"FlameGraph.parentSearchNotMatchedBackground",
"Focus.activeErrorBorderColor",
"Focus.activeWarningBorderColor",
"Focus.borderColor",
"Focus.defaultButtonBorderColor",
"Focus.inactiveErrorBorderColor",
"Focus.inactiveWarningBorderColor",
"Github.List.tallRow.foreground",
"Github.List.tallRow.secondary.foreground",
"Github.List.tallRow.selectionBackground",
"Github.List.tallRow.selectionBackground.unfocused",
"Github.List.tallRow.selectionForeground",
"Github.List.tallRow.selectionForeground.unfocused",
"Group.separatorColor",
"HeaderColor.inactive",
"HelpTooltip.backgroundColor",
"HelpTooltip.borderColor",
"HelpTooltip.shortcutTextColor",
"HelpTooltip.textColor",
"Label.disabledForeground",
"Label.disabledText",
"Label.errorForeground",
"Label.foreground",
"Label.grayForeground",
"Label.selectedDisabledForeground",
"Label.selectedForeground",
"Menu.borderColor",
"MenuBar.borderColor",
"NavBar.borderColor",
"Notification.Error.background",
"Notification.Error.borderColor",
"Notification.MoreButton.background",
"Notification.MoreButton.foreground",
"Notification.MoreButton.innerBorderColor",
"Notification.ToolWindowError.background",
"Notification.ToolWindowError.borderColor",
"Notification.ToolWindowInfo.background",
"Notification.ToolWindowInfo.borderColor",
"Notification.ToolWindowWarning.background",
"Notification.ToolWindowWarning.borderColor",
"Notification.background",
"Notification.borderColor",
"Outline.color",
"Outline.disabledColor",
"Outline.focusedColor",
"Panel.background",
"Popup.Advertiser.background",
"Popup.Advertiser.borderColor",
"Popup.Advertiser.foreground",
"Popup.Border.color",
"Popup.Border.inactiveColor",
"Popup.Header.activeBackground",
"Popup.Header.inactiveBackground",
"Popup.Separator.foreground",
"Popup.Toolbar.Border.color",
"Popup.Toolbar.background",
"Popup.separatorColor",
"ProgressBar.failedColor",
"ProgressBar.failedEndColor",
"ProgressBar.indeterminateEndColor",
"ProgressBar.indeterminateStartColor",
"ProgressBar.passedColor",
"ProgressBar.passedEndColor",
"ProgressBar.progressColor",
"ProgressBar.trackColor",
"SearchEverywhere.Advertiser.background",
"SearchEverywhere.Advertiser.foreground",
"SearchEverywhere.Header.background",
"SearchEverywhere.List.Separator.Color",
"SearchEverywhere.SearchField.background",
"SearchEverywhere.SearchField.borderColor",
"SearchEverywhere.SearchField.grayForeground",
"SearchEverywhere.Tab.active.background",
"SearchEverywhere.Tab.active.foreground",
"SearchMatch.endColor",
"SearchMatch.startColor",
"Separator.foreground",
"SidePanel.background",
"StatusBar.borderColor",
"TabbedPane.contentAreaColor",
"TabbedPane.disabledText",
"TabbedPane.focusColor",
"TabbedPane.hoverColor",
"TabbedPane.selectedColor",
"TabbedPane.selectedDisabledColor",
"TitlePane.background",
"ToolTip.actions.background",
"ToolWindow.Button.hoverBackground",
"ToolWindow.Button.selectedBackground",
"ToolWindow.Button.selectedForeground",
"ToolWindow.header.active.background",
"ToolWindow.header.background",
"ToolWindow.header.border.background",
"ToolWindow.header.closeButton.background",
"ToolWindow.header.tab.hovered.active.background",
"ToolWindow.header.tab.hovered.background",
"ToolWindow.header.tab.selected.active.background",
"ToolWindow.header.tab.selected.background",
"ValidationTooltip.errorBackgroundColor",
"ValidationTooltip.errorBorderColor",
"ValidationTooltip.warningBackgroundColor",
"ValidationTooltip.warningBorderColor",
"WelcomeScreen.Projects.background",
"WelcomeScreen.Projects.selectionBackground",
"WelcomeScreen.Projects.selectionInactiveBackground",
"WelcomeScreen.background",
"WelcomeScreen.borderColor",
"WelcomeScreen.captionBackground",
"WelcomeScreen.captionForeground",
"WelcomeScreen.footerBackground",
"WelcomeScreen.footerForeground",
"WelcomeScreen.groupIconBorderColor",
"WelcomeScreen.headerBackground",
"WelcomeScreen.headerForeground",
"WelcomeScreen.separatorColor",
"tooltips.actions.keymap.text.color",
"tooltips.actions.settings.icon.background.color",
"tooltips.description.title.text.color"
);
public static final Set<String> ALL_KEYS = Sets.union(UI_DEFAULTS_KEYS, NAMED_COLORS);
}