提交 bf8e53ef 编写于 作者: E Evgeny Gerashchenko

Added highlighting for parameters.

上级 25bbc912
......@@ -132,6 +132,7 @@ public class JetColorSettingsPage implements ColorSettingsPage {
new AttributesDescriptor("Mutable variable, parameter or property", JetHighlightingColors.MUTABLE_VARIABLE),
new AttributesDescriptor("Local variable", JetHighlightingColors.LOCAL_VARIABLE),
new AttributesDescriptor("Parameter", JetHighlightingColors.PARAMETER),
new AttributesDescriptor("Closure or anonymous object bound variable", JetHighlightingColors.WRAPPED_INTO_REF),
new AttributesDescriptor("Instance property", JetHighlightingColors.INSTANCE_PROPERTY),
......
......@@ -161,14 +161,19 @@ public class JetHighlightingColors {
CodeInsightColors.ANNOTATION_NAME_ATTRIBUTES.getDefaultAttributes()
);
public static final TextAttributesKey MUTABLE_VARIABLE = TextAttributesKey.createTextAttributesKey(
"KOTLIN_MUTABLE_VARIABLE",
new TextAttributes(null, null, Color.BLACK, EffectType.LINE_UNDERSCORE, 0)
);
public static final TextAttributesKey LOCAL_VARIABLE = TextAttributesKey.createTextAttributesKey(
"KOTLIN_LOCAL_VARIABLE",
CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES.getDefaultAttributes()
);
public static final TextAttributesKey MUTABLE_VARIABLE = TextAttributesKey.createTextAttributesKey(
"KOTLIN_MUTABLE_VARIABLE",
new TextAttributes(null, null, Color.BLACK, EffectType.LINE_UNDERSCORE, 0)
public static final TextAttributesKey PARAMETER = TextAttributesKey.createTextAttributesKey(
"KOTLIN_PARAMETER",
CodeInsightColors.PARAMETER_ATTRIBUTES.getDefaultAttributes()
);
public static final TextAttributesKey WRAPPED_INTO_REF = TextAttributesKey.createTextAttributesKey(
......
......@@ -89,17 +89,23 @@ class VariablesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
private void highlightVariable(@NotNull PsiElement elementToHighlight, @NotNull DeclarationDescriptor descriptor) {
if (descriptor instanceof VariableDescriptor) {
if (((VariableDescriptor)descriptor).isVar()) {
VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
if (variableDescriptor.isVar()) {
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.MUTABLE_VARIABLE);
}
}
if (descriptor instanceof LocalVariableDescriptor) {
LocalVariableDescriptor variableDescriptor = (LocalVariableDescriptor) descriptor;
if (Boolean.TRUE.equals(bindingContext.get(MUST_BE_WRAPPED_IN_A_REF, variableDescriptor))) {
holder.createInfoAnnotation(elementToHighlight, "Wrapped into a ref-object to be modifier when captured in a closure").setTextAttributes(
JetHighlightingColors.WRAPPED_INTO_REF);
}
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.LOCAL_VARIABLE);
if (descriptor instanceof LocalVariableDescriptor) {
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.LOCAL_VARIABLE);
}
if (descriptor instanceof ValueParameterDescriptor) {
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(JetHighlightingColors.PARAMETER);
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册