mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
Provide a better compatibility with old color schemes
This commit is contained in:
@@ -166,34 +166,6 @@ public final class TextAttributesKey implements Comparable<TextAttributesKey>, J
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to <code>createTextAttributesKey(externalName, fallbackAttributeKey)</code> but allows to specify attributes which will be used
|
||||
* in default scheme as well as in a scheme created as a copy of default scheme. If specified, shadows a fallback attribute: a scheme
|
||||
* designer may need to clear the attributes to restore dependency on the fallback key. It is strongly recommended to use this method
|
||||
* only if absolutely necessary to define specific highlighting attributes which can not be referenced by any of the keys in
|
||||
* <code>DefaultLanguageHighlighterColors</code>.
|
||||
* <p>
|
||||
* If a scheme doesn't have the specified key if, for example, it was designed without an installed language plug-in, a fallback key
|
||||
* will be used instead of default text attributes specified here.
|
||||
* </p>
|
||||
*
|
||||
* @param externalName The unique identifier of the key.
|
||||
* @param fallbackAttributeKey The fallback key to use if text attributes for this key are not defined.
|
||||
* @param defaultAttributes The default text attributes associated with the key.
|
||||
* @return
|
||||
*/
|
||||
@NotNull
|
||||
public static TextAttributesKey createTextAttributesKey(@NonNls @NotNull String externalName,
|
||||
TextAttributesKey fallbackAttributeKey,
|
||||
TextAttributes defaultAttributes) {
|
||||
TextAttributesKey key = find(externalName);
|
||||
key.setFallbackAttributeKey(fallbackAttributeKey);
|
||||
if (key.myDefaultAttributes == null || key.myDefaultAttributes == NULL_ATTRIBUTES) {
|
||||
key.myDefaultAttributes = defaultAttributes;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public TextAttributesKey getFallbackAttributeKey() {
|
||||
return myFallbackAttributeKey;
|
||||
}
|
||||
|
||||
+23
-23
@@ -16,48 +16,48 @@
|
||||
package com.intellij.openapi.editor;
|
||||
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
|
||||
/**
|
||||
* Base highlighter colors for multiple languages.
|
||||
*
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // SyntaxHighlighterColors is used for compatibility with old schemes
|
||||
public class DefaultLanguageHighlighterColors {
|
||||
|
||||
public final static TextAttributesKey TEMPLATE_LANGUAGE_COLOR =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_TEMPLATE_LANGUAGE_COLOR");
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_TEMPLATE_LANGUAGE_COLOR", HighlighterColors.TEXT);
|
||||
public final static TextAttributesKey IDENTIFIER =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_IDENTIFIER", HighlighterColors.TEXT);
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_IDENTIFIER");
|
||||
public final static TextAttributesKey NUMBER =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_NUMBER", SyntaxHighlighterColors.NUMBER.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_NUMBER");
|
||||
public final static TextAttributesKey KEYWORD =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_KEYWORD", SyntaxHighlighterColors.KEYWORD.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_KEYWORD");
|
||||
public final static TextAttributesKey STRING =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_STRING", SyntaxHighlighterColors.STRING.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_STRING", HighlighterColors.TEXT);
|
||||
public final static TextAttributesKey BLOCk_COMMENT =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_BLOCK_COMMENT", SyntaxHighlighterColors.JAVA_BLOCK_COMMENT.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_BLOCK_COMMENT");
|
||||
public final static TextAttributesKey LINE_COMMENT =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_LINE_COMMENT", SyntaxHighlighterColors.LINE_COMMENT.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_LINE_COMMENT");
|
||||
public final static TextAttributesKey DOC_COMMENT =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT", SyntaxHighlighterColors.DOC_COMMENT.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT");
|
||||
public final static TextAttributesKey OPERATION_SIGN =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_OPERATION_SIGN", SyntaxHighlighterColors.OPERATION_SIGN.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_OPERATION_SIGN");
|
||||
public final static TextAttributesKey BRACES =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_BRACES", SyntaxHighlighterColors.BRACES.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_BRACES");
|
||||
public final static TextAttributesKey DOT =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOT", SyntaxHighlighterColors.DOT.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOT");
|
||||
public final static TextAttributesKey SEMICOLON =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_SEMICOLON", SyntaxHighlighterColors.JAVA_SEMICOLON.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_SEMICOLON");
|
||||
public final static TextAttributesKey COMMA =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_COMMA", SyntaxHighlighterColors.COMMA.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_COMMA");
|
||||
public final static TextAttributesKey PARENTHESES =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_PARENTHS", SyntaxHighlighterColors.PARENTHS.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_PARENTHS");
|
||||
public final static TextAttributesKey BRACKETS =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_BRACKETS", SyntaxHighlighterColors.BRACKETS.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_BRACKETS");
|
||||
|
||||
public final static TextAttributesKey LABEL =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_LABEL");
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_LABEL", IDENTIFIER);
|
||||
public final static TextAttributesKey CONSTANT =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_CONSTANT", IDENTIFIER);
|
||||
public final static TextAttributesKey LOCAL_VARIABLE =
|
||||
@@ -87,15 +87,15 @@ public class DefaultLanguageHighlighterColors {
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_STATIC_FIELD", IDENTIFIER);
|
||||
|
||||
public final static TextAttributesKey DOC_COMMENT_MARKUP =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_MARKUP", SyntaxHighlighterColors.DOC_COMMENT_MARKUP.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_MARKUP");
|
||||
public final static TextAttributesKey DOC_COMMENT_TAG =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG", SyntaxHighlighterColors.DOC_COMMENT_TAG.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG");
|
||||
public final static TextAttributesKey DOC_COMMENT_TAG_VALUE =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG_VALUE");
|
||||
public final static TextAttributesKey VALID_STRING_ESCAPE =
|
||||
TextAttributesKey
|
||||
.createTextAttributesKey("DEFAULT_VALID_STRING_ESCAPE", SyntaxHighlighterColors.VALID_STRING_ESCAPE.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_VALID_STRING_ESCAPE");
|
||||
public final static TextAttributesKey INVALID_STRING_ESCAPE =
|
||||
TextAttributesKey
|
||||
.createTextAttributesKey("DEFAULT_INVALID_STRING_ESCAPE", SyntaxHighlighterColors.INVALID_STRING_ESCAPE.getDefaultAttributes());
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_INVALID_STRING_ESCAPE");
|
||||
|
||||
public final static TextAttributesKey PREDEFINED_SYMBOL =
|
||||
TextAttributesKey.createTextAttributesKey("DEFAULT_PREDEFINED_SYMBOL", IDENTIFIER);
|
||||
|
||||
+1
-4
@@ -445,10 +445,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme {
|
||||
if (key.getFallbackAttributeKey() != null && value.isEmpty()) return false;
|
||||
boolean hasDefaultValue = value.equals(defaultAttribute);
|
||||
if (myParentScheme == null) return !hasDefaultValue;
|
||||
if (EditorColorsManager.getInstance().getGlobalScheme() == this
|
||||
&& myParentScheme instanceof AbstractColorsScheme
|
||||
&& !((AbstractColorsScheme)myParentScheme).myAttributesMap.containsKey(key)) return !value.isEmpty();
|
||||
return !value.equals(myParentScheme.getAttributes(key));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void writeAttributes(Element attrElements) throws WriteExternalException {
|
||||
|
||||
+4
-1
@@ -53,7 +53,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
|
||||
|
||||
@Override
|
||||
public TextAttributes getAttributes(TextAttributesKey key) {
|
||||
if (key != null) {
|
||||
if (key != null) {
|
||||
TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
|
||||
TextAttributes attributes = myAttributesMap.get(key);
|
||||
if (fallbackKey == null) {
|
||||
@@ -63,6 +63,9 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
|
||||
if (attributes != null && !attributes.isEmpty()) return attributes;
|
||||
attributes = getFallbackAttributes(fallbackKey);
|
||||
if (attributes != null) return attributes;
|
||||
if (myParentScheme instanceof DefaultColorsScheme && !DEFAULT_SCHEME_NAME.equals(getName())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return myParentScheme.getAttributes(key);
|
||||
|
||||
@@ -90,6 +90,71 @@
|
||||
<option name="FOREGROUND" value="808000" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_STRING">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="008000"/>
|
||||
<option name="FONT_TYPE" value="1"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_KEYWORD">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="80"/>
|
||||
<option name="FONT_TYPE" value="1"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_NUMBER">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="ff"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_BLOCK_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="808080"/>
|
||||
<option name="FONT_TYPE" value="2"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_LINE_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="808080"/>
|
||||
<option name="FONT_TYPE" value="2"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_DOC_COMMENT">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="808080"/>
|
||||
<option name="FONT_TYPE" value="2"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_DOC_MARKUP">
|
||||
<value>
|
||||
<option name="BACKGROUND" value="e2ffe2"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_DOC_COMMENT_TAG">
|
||||
<value>
|
||||
<option name="EFFECT_COLOR" value="808080"/>
|
||||
<option name="EFFECT_TYPE" value="1"/>
|
||||
<option name="FONT_TYPE" value="1"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_DOC_COMMENT_TAG_VALUE">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="3d3d3d"/>
|
||||
<option name="FONT_TYPE" value="3"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_INVALID_STRING_ESCAPE">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="008000"/>
|
||||
<option name="BACKGROUND" value="ffcccc"/>
|
||||
</value>
|
||||
</option>
|
||||
<option name="DEFAULT_VALID_STRING_ESCAPE">
|
||||
<value>
|
||||
<option name="FOREGROUND" value="000080"/>
|
||||
<option name="FONT_TYPE" value="1"/>
|
||||
</value>
|
||||
</option>
|
||||
|
||||
<option name="LINE_PARTIAL_COVERAGE">
|
||||
<value>
|
||||
|
||||
Reference in New Issue
Block a user