"field": highlighting fix, including color schemes and example

This commit is contained in:
Mikhail Glukhikh
2015-09-16 18:20:39 +03:00
parent 9939f96c09
commit 094c6cebc3
8 changed files with 35 additions and 1 deletions
@@ -133,6 +133,7 @@ options.kotlin.attribute.descriptor.instance.property=Instance property
options.kotlin.attribute.descriptor.package.property=Package-level property
options.kotlin.attribute.descriptor.property.with.backing=Property with backing field
options.kotlin.attribute.descriptor.backing.field.access=Backing field access
options.kotlin.attribute.descriptor.field=Backing field variable
options.kotlin.attribute.descriptor.extension.property=Extension property
options.kotlin.attribute.descriptor.dynamic.property=Dynamic property
options.kotlin.attribute.descriptor.it=Function literal default parameter
@@ -66,6 +66,7 @@ public class JetHighlightingColors {
public static final TextAttributesKey PACKAGE_PROPERTY = createTextAttributesKey("KOTLIN_PACKAGE_PROPERTY", CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
public static final TextAttributesKey PROPERTY_WITH_BACKING_FIELD = createTextAttributesKey("KOTLIN_PROPERTY_WITH_BACKING_FIELD");
public static final TextAttributesKey BACKING_FIELD_ACCESS = createTextAttributesKey("KOTLIN_BACKING_FIELD_ACCESS");
public static final TextAttributesKey BACKING_FIELD_VARIABLE = createTextAttributesKey("KOTLIN_BACKING_FIELD_VARIABLE");
public static final TextAttributesKey EXTENSION_PROPERTY = createTextAttributesKey("KOTLIN_EXTENSION_PROPERTY");
public static final TextAttributesKey DYNAMIC_PROPERTY_CALL = createTextAttributesKey("KOTLIN_DYNAMIC_PROPERTY_CALL");
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.psi.JetParameter;
import org.jetbrains.kotlin.psi.JetProperty;
@@ -42,6 +43,10 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
return;
}
DeclarationDescriptor target = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
if (target instanceof SyntheticFieldDescriptor) {
JetPsiChecker.highlightName(holder, expression, JetHighlightingColors.BACKING_FIELD_VARIABLE);
return;
}
if (!(target instanceof PropertyDescriptor)) {
return;
}