[HIGHLIGHT] Specific keyword rules for val,var highlighting.

'Kotlin keyword' rule configured as fallback rule for all Kotlin keywords:
- Created 'var'/'val' rules with fallback to 'Kotlin keyword'
- BUILTIN_ANNOTATION rule fallback changed from Java to 'Kotlin keyword'

 #KT-13344 Fixed
This commit is contained in:
Vladimir Ilmov
2019-11-05 12:31:50 +03:00
parent 34ea47a868
commit 9fb95e776e
4 changed files with 12 additions and 3 deletions
@@ -60,7 +60,10 @@ livetemplate.description.exval=Extension read-only property
livetemplate.description.exvar=Extension read-write property
options.kotlin.attribute.descriptor.annotation=Annotation
options.kotlin.attribute.descriptor.builtin.annotation=Modifier
options.kotlin.attribute.descriptor.builtin.annotation=Keywords//Modifier
options.kotlin.attribute.descriptor.builtin.keyword.val=Keywords//'val'
options.kotlin.attribute.descriptor.builtin.keyword.var=Keywords//'var'
options.kotlin.attribute.descriptor.builtin.keyword=Keywords//Keyword
options.kotlin.attribute.descriptor.string.escape=String//Escape in string and template braces
options.kotlin.attribute.descriptor.closure.braces=Braces and Operators//Lambda expression braces and arrow
options.kotlin.attribute.descriptor.safe.access=Braces and Operators//Safe access dot
@@ -51,6 +51,8 @@ public class KotlinHighlighter extends SyntaxHighlighterBase {
fillMap(keys1, KtTokens.KEYWORDS, KotlinHighlightingColors.KEYWORD);
keys1.put(KtTokens.VAL_KEYWORD, KotlinHighlightingColors.VAL_KEYWORD);
keys1.put(KtTokens.VAR_KEYWORD, KotlinHighlightingColors.VAR_KEYWORD);
keys1.put(KtTokens.AS_SAFE, KotlinHighlightingColors.KEYWORD);
keys1.put(KtTokens.INTEGER_LITERAL, KotlinHighlightingColors.NUMBER);
keys1.put(KtTokens.FLOAT_LITERAL, KotlinHighlightingColors.NUMBER);
@@ -26,7 +26,9 @@ import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAtt
public class KotlinHighlightingColors {
// default keys (mostly syntax elements)
public static final TextAttributesKey KEYWORD = createTextAttributesKey("KOTLIN_KEYWORD", JavaHighlightingColors.KEYWORD);
public static final TextAttributesKey BUILTIN_ANNOTATION = createTextAttributesKey("KOTLIN_BUILTIN_ANNOTATION", JavaHighlightingColors.KEYWORD);
public static final TextAttributesKey BUILTIN_ANNOTATION = createTextAttributesKey("KOTLIN_BUILTIN_ANNOTATION", KotlinHighlightingColors.KEYWORD);
public static final TextAttributesKey VAL_KEYWORD = createTextAttributesKey("KOTLIN_KEYWORD_VAL", KotlinHighlightingColors.KEYWORD);
public static final TextAttributesKey VAR_KEYWORD = createTextAttributesKey("KOTLIN_KEYWORD_VAR", KotlinHighlightingColors.KEYWORD);
public static final TextAttributesKey NUMBER = createTextAttributesKey("KOTLIN_NUMBER", DefaultLanguageHighlighterColors.NUMBER);
public static final TextAttributesKey STRING = createTextAttributesKey("KOTLIN_STRING", DefaultLanguageHighlighterColors.STRING);
public static final TextAttributesKey STRING_ESCAPE = createTextAttributesKey("KOTLIN_STRING_ESCAPE", DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE);
@@ -119,7 +119,9 @@ var <PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAG
infix fun String.to(key: TextAttributesKey) = AttributesDescriptor(this, key)
return arrayOf(
OptionsBundle.message("options.java.attribute.descriptor.keyword") to KotlinHighlightingColors.KEYWORD,
KotlinBundle.message("options.kotlin.attribute.descriptor.builtin.keyword") to KotlinHighlightingColors.KEYWORD,
KotlinBundle.message("options.kotlin.attribute.descriptor.builtin.keyword.val") to KotlinHighlightingColors.VAL_KEYWORD,
KotlinBundle.message("options.kotlin.attribute.descriptor.builtin.keyword.var") to KotlinHighlightingColors.VAR_KEYWORD,
KotlinBundle.message("options.kotlin.attribute.descriptor.builtin.annotation") to KotlinHighlightingColors.BUILTIN_ANNOTATION,
OptionsBundle.message("options.java.attribute.descriptor.number") to KotlinHighlightingColors.NUMBER,
OptionsBundle.message("options.java.attribute.descriptor.string") to KotlinHighlightingColors.STRING,