Add specific highlight for Enum class
#KT-39844 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
3f266aafb4
commit
e72a06bdf4
+1
@@ -114,6 +114,7 @@ internal class TypeKindHighlightingVisitor(holder: AnnotationHolder, bindingCont
|
|||||||
ClassKind.INTERFACE -> TRAIT
|
ClassKind.INTERFACE -> TRAIT
|
||||||
ClassKind.ANNOTATION_CLASS -> ANNOTATION
|
ClassKind.ANNOTATION_CLASS -> ANNOTATION
|
||||||
ClassKind.OBJECT -> OBJECT
|
ClassKind.OBJECT -> OBJECT
|
||||||
|
ClassKind.ENUM_CLASS -> ENUM
|
||||||
ClassKind.ENUM_ENTRY -> ENUM_ENTRY
|
ClassKind.ENUM_ENTRY -> ENUM_ENTRY
|
||||||
else -> if (descriptor.modality === Modality.ABSTRACT) ABSTRACT_CLASS else CLASS
|
else -> if (descriptor.modality === Modality.ABSTRACT) ABSTRACT_CLASS else CLASS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ internal fun textAttributesKeyForTypeDeclaration(declaration: PsiElement): TextA
|
|||||||
fun textAttributesForClass(klass: KtClass): TextAttributesKey = when {
|
fun textAttributesForClass(klass: KtClass): TextAttributesKey = when {
|
||||||
klass.isInterface() -> Colors.TRAIT
|
klass.isInterface() -> Colors.TRAIT
|
||||||
klass.isAnnotation() -> Colors.ANNOTATION
|
klass.isAnnotation() -> Colors.ANNOTATION
|
||||||
|
klass.isEnum() -> Colors.ENUM
|
||||||
klass is KtEnumEntry -> Colors.ENUM_ENTRY
|
klass is KtEnumEntry -> Colors.ENUM_ENTRY
|
||||||
klass.isAbstract() -> Colors.ABSTRACT_CLASS
|
klass.isAbstract() -> Colors.ABSTRACT_CLASS
|
||||||
else -> Colors.CLASS
|
else -> Colors.CLASS
|
||||||
|
|||||||
+1
@@ -49,6 +49,7 @@ public class KotlinHighlightingColors {
|
|||||||
public static final TextAttributesKey TRAIT = createTextAttributesKey("KOTLIN_TRAIT", DefaultLanguageHighlighterColors.INTERFACE_NAME);
|
public static final TextAttributesKey TRAIT = createTextAttributesKey("KOTLIN_TRAIT", DefaultLanguageHighlighterColors.INTERFACE_NAME);
|
||||||
public static final TextAttributesKey ANNOTATION = createTextAttributesKey("KOTLIN_ANNOTATION", JavaHighlightingColors.ANNOTATION_NAME_ATTRIBUTES);
|
public static final TextAttributesKey ANNOTATION = createTextAttributesKey("KOTLIN_ANNOTATION", JavaHighlightingColors.ANNOTATION_NAME_ATTRIBUTES);
|
||||||
public static final TextAttributesKey OBJECT = createTextAttributesKey("KOTLIN_OBJECT", CLASS);
|
public static final TextAttributesKey OBJECT = createTextAttributesKey("KOTLIN_OBJECT", CLASS);
|
||||||
|
public static final TextAttributesKey ENUM = createTextAttributesKey("KOTLIN_ENUM", JavaHighlightingColors.ENUM_NAME_ATTRIBUTES);
|
||||||
public static final TextAttributesKey ENUM_ENTRY = createTextAttributesKey("KOTLIN_ENUM_ENTRY", DefaultLanguageHighlighterColors.STATIC_FIELD);
|
public static final TextAttributesKey ENUM_ENTRY = createTextAttributesKey("KOTLIN_ENUM_ENTRY", DefaultLanguageHighlighterColors.STATIC_FIELD);
|
||||||
public static final TextAttributesKey TYPE_ALIAS = createTextAttributesKey("KOTLIN_TYPE_ALIAS", CLASS);
|
public static final TextAttributesKey TYPE_ALIAS = createTextAttributesKey("KOTLIN_TYPE_ALIAS", CLASS);
|
||||||
|
|
||||||
|
|||||||
@@ -593,6 +593,7 @@ highlighter.descriptor.text.label=Label
|
|||||||
highlighter.descriptor.text.local.variable=Properties and Variables//Local variable or value
|
highlighter.descriptor.text.local.variable=Properties and Variables//Local variable or value
|
||||||
highlighter.descriptor.text.named.argument=Named argument
|
highlighter.descriptor.text.named.argument=Named argument
|
||||||
highlighter.descriptor.text.object=Classes and Interfaces//Object
|
highlighter.descriptor.text.object=Classes and Interfaces//Object
|
||||||
|
highlighter.descriptor.text.enum=Classes and Interfaces//Enum
|
||||||
highlighter.descriptor.text.package.fun.call=Functions//Package-level function call
|
highlighter.descriptor.text.package.fun.call=Functions//Package-level function call
|
||||||
highlighter.descriptor.text.package.property.custom.property.declaration=Properties and Variables//Package-level property with custom property declarations
|
highlighter.descriptor.text.package.property.custom.property.declaration=Properties and Variables//Package-level property with custom property declarations
|
||||||
highlighter.descriptor.text.package.property=Properties and Variables//Package-level property
|
highlighter.descriptor.text.package.property=Properties and Variables//Package-level property
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ var <PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION><MUTABLE_VARIABLE>globalCounte
|
|||||||
|
|
||||||
<KEYWORD>object</KEYWORD> <OBJECT>Obj</OBJECT>
|
<KEYWORD>object</KEYWORD> <OBJECT>Obj</OBJECT>
|
||||||
|
|
||||||
<KEYWORD>enum</KEYWORD> <KEYWORD>class</KEYWORD> <CLASS>E</CLASS> { <ENUM_ENTRY>A</ENUM_ENTRY>, <ENUM_ENTRY>B</ENUM_ENTRY> }
|
<KEYWORD>enum</KEYWORD> <KEYWORD>class</KEYWORD> <ENUM>E</ENUM> { <ENUM_ENTRY>A</ENUM_ENTRY>, <ENUM_ENTRY>B</ENUM_ENTRY> }
|
||||||
|
|
||||||
<KEYWORD>interface</KEYWORD> <TRAIT>FunctionLike</TRAIT> {
|
<KEYWORD>interface</KEYWORD> <TRAIT>FunctionLike</TRAIT> {
|
||||||
<BUILTIN_ANNOTATION>operator</BUILTIN_ANNOTATION> <KEYWORD>fun</KEYWORD> <FUNCTION_DECLARATION>invoke</FUNCTION_DECLARATION>() = <NUMBER>1</NUMBER>
|
<BUILTIN_ANNOTATION>operator</BUILTIN_ANNOTATION> <KEYWORD>fun</KEYWORD> <FUNCTION_DECLARATION>invoke</FUNCTION_DECLARATION>() = <NUMBER>1</NUMBER>
|
||||||
@@ -163,6 +163,7 @@ var <PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION><MUTABLE_VARIABLE>globalCounte
|
|||||||
KotlinBundle.message("highlighter.descriptor.text.annotation") to KotlinHighlightingColors.ANNOTATION,
|
KotlinBundle.message("highlighter.descriptor.text.annotation") to KotlinHighlightingColors.ANNOTATION,
|
||||||
KotlinBundle.message("highlighter.descriptor.text.annotation.attribute.name") to KotlinHighlightingColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES,
|
KotlinBundle.message("highlighter.descriptor.text.annotation.attribute.name") to KotlinHighlightingColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES,
|
||||||
KotlinBundle.message("highlighter.descriptor.text.object") to KotlinHighlightingColors.OBJECT,
|
KotlinBundle.message("highlighter.descriptor.text.object") to KotlinHighlightingColors.OBJECT,
|
||||||
|
KotlinBundle.message("highlighter.descriptor.text.enum") to KotlinHighlightingColors.ENUM,
|
||||||
KotlinBundle.message("highlighter.descriptor.text.enumEntry") to KotlinHighlightingColors.ENUM_ENTRY,
|
KotlinBundle.message("highlighter.descriptor.text.enumEntry") to KotlinHighlightingColors.ENUM_ENTRY,
|
||||||
KotlinBundle.message("highlighter.descriptor.text.typeAlias") to KotlinHighlightingColors.TYPE_ALIAS,
|
KotlinBundle.message("highlighter.descriptor.text.typeAlias") to KotlinHighlightingColors.TYPE_ALIAS,
|
||||||
KotlinBundle.message("highlighter.descriptor.text.var") to KotlinHighlightingColors.MUTABLE_VARIABLE,
|
KotlinBundle.message("highlighter.descriptor.text.var") to KotlinHighlightingColors.MUTABLE_VARIABLE,
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
// IGNORE_FIR
|
// IGNORE_FIR
|
||||||
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
// EXPECTED_DUPLICATED_HIGHLIGHTING
|
||||||
|
|
||||||
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Target</info>(<info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">CLASS</info>, <info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">EXPRESSION</info>)
|
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Target</info>(<info descr="null" textAttributesKey="KOTLIN_ENUM">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">CLASS</info>, <info descr="null" textAttributesKey="KOTLIN_ENUM">AnnotationTarget</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">EXPRESSION</info>)
|
||||||
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Retention</info>(<info descr="null" textAttributesKey="KOTLIN_CLASS">AnnotationRetention</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">SOURCE</info>)
|
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Retention</info>(<info descr="null" textAttributesKey="KOTLIN_ENUM">AnnotationRetention</info>.<info descr="null" textAttributesKey="KOTLIN_ENUM_ENTRY">SOURCE</info>)
|
||||||
<info descr="null">annotation</info> class <info descr="null">Ann</info>
|
<info descr="null">annotation</info> class <info descr="null">Ann</info>
|
||||||
|
|
||||||
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Ann</info> class <info descr="null">A</info>
|
<info descr="null" textAttributesKey="KOTLIN_ANNOTATION">@Ann</info> class <info descr="null">A</info>
|
||||||
|
|||||||
Vendored
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
package testing
|
package testing
|
||||||
|
|
||||||
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">enum</info> class <info textAttributesKey="KOTLIN_CLASS">Test</info> {
|
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">enum</info> class <info textAttributesKey="KOTLIN_ENUM">Test</info> {
|
||||||
<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>,
|
<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>,
|
||||||
<info textAttributesKey="KOTLIN_ENUM_ENTRY">SECOND</info>
|
<info textAttributesKey="KOTLIN_ENUM_ENTRY">SECOND</info>
|
||||||
}
|
}
|
||||||
|
|
||||||
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">enum</info> class <info textAttributesKey="KOTLIN_CLASS">Type</info>(val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">id</info>: <info textAttributesKey="KOTLIN_CLASS">Int</info>) {
|
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">enum</info> class <info textAttributesKey="KOTLIN_ENUM">Type</info>(val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">id</info>: <info textAttributesKey="KOTLIN_CLASS">Int</info>) {
|
||||||
<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>(1),
|
<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>(1),
|
||||||
<info textAttributesKey="KOTLIN_ENUM_ENTRY">SECOND</info>(2)
|
<info textAttributesKey="KOTLIN_ENUM_ENTRY">SECOND</info>(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">testing</info>(<info textAttributesKey="KOTLIN_PARAMETER">t1</info>: <info textAttributesKey="KOTLIN_CLASS">Test</info>, <info textAttributesKey="KOTLIN_PARAMETER">t2</info>: <info textAttributesKey="KOTLIN_CLASS">Test</info>): <info textAttributesKey="KOTLIN_CLASS">Test</info> {
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">testing</info>(<info textAttributesKey="KOTLIN_PARAMETER">t1</info>: <info textAttributesKey="KOTLIN_ENUM">Test</info>, <info textAttributesKey="KOTLIN_PARAMETER">t2</info>: <info textAttributesKey="KOTLIN_ENUM">Test</info>): <info textAttributesKey="KOTLIN_ENUM">Test</info> {
|
||||||
if (<info textAttributesKey="KOTLIN_PARAMETER">t1</info> != <info textAttributesKey="KOTLIN_PARAMETER">t2</info>) return <info textAttributesKey="KOTLIN_CLASS">Test</info>.<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>
|
if (<info textAttributesKey="KOTLIN_PARAMETER">t1</info> != <info textAttributesKey="KOTLIN_PARAMETER">t2</info>) return <info textAttributesKey="KOTLIN_ENUM">Test</info>.<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>
|
||||||
return <info textAttributesKey="KOTLIN_PACKAGE_FUNCTION_CALL">testing</info>(<info textAttributesKey="KOTLIN_CLASS">Test</info>.<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>, <info textAttributesKey="KOTLIN_CLASS">Test</info>.<info textAttributesKey="KOTLIN_ENUM_ENTRY">SECOND</info>)
|
return <info textAttributesKey="KOTLIN_PACKAGE_FUNCTION_CALL">testing</info>(<info textAttributesKey="KOTLIN_ENUM">Test</info>.<info textAttributesKey="KOTLIN_ENUM_ENTRY">FIRST</info>, <info textAttributesKey="KOTLIN_ENUM">Test</info>.<info textAttributesKey="KOTLIN_ENUM_ENTRY">SECOND</info>)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user