KT-21974 Editor color scheme option for Kotlin typealias names (#1457)

This commit is contained in:
Toshiaki Kameyama
2018-01-05 01:39:39 +09:00
committed by Dmitry Jemerov
parent 06903f803b
commit 266b40b654
6 changed files with 27 additions and 0 deletions
@@ -74,6 +74,7 @@ options.kotlin.attribute.descriptor.kdoc.tag=Comments//KDoc//KDoc tag
options.kotlin.attribute.descriptor.kdoc.value=Comments//KDoc//Link in KDoc tag
options.kotlin.attribute.descriptor.object=Classes and Interfaces//Object
options.kotlin.attribute.descriptor.enumEntry=Classes and Interfaces//Enum entry
options.kotlin.attribute.descriptor.typeAlias=Classes and Interfaces//Type alias
options.kotlin.attribute.descriptor.var=Properties and Variables//Var (mutable variable, parameter or property)
options.kotlin.attribute.descriptor.local.variable=Properties and Variables//Local variable or value
options.kotlin.attribute.descriptor.captured.variable=Properties and Variables//Variables and values captured in a closure
@@ -59,6 +59,7 @@ public class KotlinHighlightingColors {
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 ENUM_ENTRY = createTextAttributesKey("KOTLIN_ENUM_ENTRY", DefaultLanguageHighlighterColors.INSTANCE_FIELD);
public static final TextAttributesKey TYPE_ALIAS = createTextAttributesKey("KOTLIN_TYPE_ALIAS", CLASS);
// variable kinds
public static final TextAttributesKey MUTABLE_VARIABLE = createTextAttributesKey("KOTLIN_MUTABLE_VARIABLE");
@@ -57,6 +57,9 @@ internal class TypeKindHighlightingVisitor(holder: AnnotationHolder, bindingCont
else if (referenceTarget is TypeParameterDescriptor) {
highlightName(expression, TYPE_PARAMETER)
}
else if (referenceTarget is TypeAliasDescriptor) {
highlightName(expression, TYPE_ALIAS)
}
}
}
@@ -92,6 +95,16 @@ internal class TypeKindHighlightingVisitor(holder: AnnotationHolder, bindingCont
super.visitClassOrObject(classOrObject)
}
override fun visitTypeAlias(typeAlias: KtTypeAlias) {
val identifier = typeAlias.nameIdentifier
val descriptor = bindingContext.get(BindingContext.TYPE_ALIAS, typeAlias)
if (identifier != null && descriptor != null) {
if (applyHighlighterExtensions(identifier, descriptor)) return
highlightName(identifier, TYPE_ALIAS)
}
super.visitTypeAlias(typeAlias)
}
override fun visitDynamicType(type: KtDynamicType) {
// Do nothing: 'dynamic' is highlighted as a keyword
}