RegExp: don't localized strings in static fields to allow dynamic loading of language bundles

GitOrigin-RevId: f7796f934b82b0b9146c2d46d949fd0b66e3569c
This commit is contained in:
Bas Leijdekkers
2020-10-28 15:12:38 +01:00
committed by intellij-monorepo-bot
parent 1be4aff59f
commit 30e0a78e06

View File

@@ -7,7 +7,6 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorDescriptor; import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.openapi.options.colors.ColorSettingsPage;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.swing.*; import javax.swing.*;
@@ -15,28 +14,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class RegExpColorsPage implements ColorSettingsPage { public class RegExpColorsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[] {
new AttributesDescriptor(RegExpBundle.message("color.settings.plain.character"), RegExpHighlighter.CHARACTER),
new AttributesDescriptor(RegExpBundle.message("color.settings.operator.character"), RegExpHighlighter.META),
new AttributesDescriptor(RegExpBundle.message("color.settings.escaped.character"), RegExpHighlighter.ESC_CHARACTER),
new AttributesDescriptor(RegExpBundle.message("color.settings.invalid.escape.sequence"), RegExpHighlighter.INVALID_CHARACTER_ESCAPE),
new AttributesDescriptor(RegExpBundle.message("color.settings.redundant.escape.sequence"), RegExpHighlighter.REDUNDANT_ESCAPE),
new AttributesDescriptor(RegExpBundle.message("color.settings.brace"), RegExpHighlighter.BRACES),
new AttributesDescriptor(RegExpBundle.message("color.settings.bracket"), RegExpHighlighter.BRACKETS),
new AttributesDescriptor(RegExpBundle.message("color.settings.parenthesis"), RegExpHighlighter.PARENTHS),
new AttributesDescriptor(RegExpBundle.message("color.settings.comma"), RegExpHighlighter.COMMA),
new AttributesDescriptor(RegExpBundle.message("color.settings.bad.character"), RegExpHighlighter.BAD_CHARACTER),
new AttributesDescriptor(RegExpBundle.message("color.settings.character.class"), RegExpHighlighter.CHAR_CLASS),
new AttributesDescriptor(RegExpBundle.message("color.settings.quote.character"), RegExpHighlighter.QUOTE_CHARACTER),
new AttributesDescriptor(RegExpBundle.message("color.settings.comment"), RegExpHighlighter.COMMENT),
new AttributesDescriptor(RegExpBundle.message("color.settings.quantifier"), RegExpHighlighter.QUANTIFIER),
new AttributesDescriptor(RegExpBundle.message("color.settings.dot"), RegExpHighlighter.DOT),
new AttributesDescriptor(RegExpBundle.message("color.settings.inline.option"), RegExpHighlighter.OPTIONS),
new AttributesDescriptor(RegExpBundle.message("color.settings.name"), RegExpHighlighter.NAME),
new AttributesDescriptor(RegExpBundle.message("color.settings.matched.groups"), RegExpHighlighter.MATCHED_GROUPS)
};
@NonNls private static final HashMap<String,TextAttributesKey> ourTagToDescriptorMap = new HashMap<>();
@Override @Override
@NotNull @NotNull
@@ -51,7 +28,26 @@ public class RegExpColorsPage implements ColorSettingsPage {
@Override @Override
public AttributesDescriptor @NotNull [] getAttributeDescriptors() { public AttributesDescriptor @NotNull [] getAttributeDescriptors() {
return DESCRIPTORS; return new AttributesDescriptor[] {
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.plain.character"), RegExpHighlighter.CHARACTER),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.operator.character"), RegExpHighlighter.META),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.escaped.character"), RegExpHighlighter.ESC_CHARACTER),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.invalid.escape.sequence"), RegExpHighlighter.INVALID_CHARACTER_ESCAPE),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.redundant.escape.sequence"), RegExpHighlighter.REDUNDANT_ESCAPE),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.brace"), RegExpHighlighter.BRACES),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.bracket"), RegExpHighlighter.BRACKETS),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.parenthesis"), RegExpHighlighter.PARENTHS),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.comma"), RegExpHighlighter.COMMA),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.bad.character"), RegExpHighlighter.BAD_CHARACTER),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.character.class"), RegExpHighlighter.CHAR_CLASS),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.quote.character"), RegExpHighlighter.QUOTE_CHARACTER),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.comment"), RegExpHighlighter.COMMENT),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.quantifier"), RegExpHighlighter.QUANTIFIER),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.dot"), RegExpHighlighter.DOT),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.inline.option"), RegExpHighlighter.OPTIONS),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.name"), RegExpHighlighter.NAME),
new AttributesDescriptor(() -> RegExpBundle.message("color.settings.matched.groups"), RegExpHighlighter.MATCHED_GROUPS)
};
} }
@Override @Override
@@ -79,6 +75,8 @@ public class RegExpColorsPage implements ColorSettingsPage {
@Override @Override
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() { public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
return ourTagToDescriptorMap; final HashMap<String, TextAttributesKey> map = new HashMap<>();
map.put("matched_group", RegExpHighlighter.MATCHED_GROUPS);
return map;
} }
} }