Added highlighting for parameters.

This commit is contained in:
Evgeny Gerashchenko
2012-03-30 20:46:59 +04:00
parent 25bbc912e9
commit bf8e53efad
3 changed files with 20 additions and 8 deletions
@@ -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);
}
}
}
}