Implicit exhaustive when annotation / highlighting

This commit is contained in:
Mikhail Glukhikh
2015-12-25 15:18:52 +03:00
committed by Mikhail Glukhikh
parent 7d6ccc40c2
commit 0cc09872b6
8 changed files with 39 additions and 1 deletions
@@ -135,6 +135,7 @@ options.kotlin.attribute.descriptor.variable.as.function.like.call=Variable as f
options.kotlin.attribute.descriptor.smart.cast=Smart-cast value
options.kotlin.attribute.descriptor.smart.constant=Smart constant
options.kotlin.attribute.descriptor.smart.cast.receiver=Smart-cast implicit receiver
options.kotlin.attribute.descriptor.implicit.exhaustive.when=Implicitly exhaustive when
options.kotlin.attribute.descriptor.label=Label
change.to.function.invocation=Change to function invocation
migrate.sure=Replace sure() calls by !! in project
@@ -85,6 +85,7 @@ public class KotlinHighlightingColors {
public static final TextAttributesKey SMART_CAST_VALUE = createTextAttributesKey("KOTLIN_SMART_CAST_VALUE");
public static final TextAttributesKey SMART_CONSTANT = createTextAttributesKey("KOTLIN_SMART_CONSTANT");
public static final TextAttributesKey SMART_CAST_RECEIVER = createTextAttributesKey("KOTLIN_SMART_CAST_RECEIVER");
public static final TextAttributesKey IMPLICIT_EXHAUSTIVE_WHEN = createTextAttributesKey("KOTLIN_IMPLICIT_EXHAUSTIVE_WHEN");
public static final TextAttributesKey LABEL = createTextAttributesKey("KOTLIN_LABEL");
public static final TextAttributesKey DEBUG_INFO = createTextAttributesKey("KOTLIN_DEBUG_INFO");
public static final TextAttributesKey RESOLVED_TO_ERROR = createTextAttributesKey("KOTLIN_RESOLVED_TO_ERROR");
@@ -110,6 +110,15 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
.setTextAttributes(KotlinHighlightingColors.SMART_CAST_VALUE);
}
if (expression instanceof KtWhenExpression) {
KtWhenExpression whenExpression = (KtWhenExpression) expression;
boolean implicitExhaustiveWhen = bindingContext.get(IMPLICIT_EXHAUSTIVE_WHEN, whenExpression) == Boolean.TRUE;
if (implicitExhaustiveWhen) {
holder.createInfoAnnotation(whenExpression.getWhenKeyword(), "When is implicitly exhaustive")
.setTextAttributes(KotlinHighlightingColors.IMPLICIT_EXHAUSTIVE_WHEN);
}
}
super.visitExpression(expression);
}