diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java index a04b165ff4f..7539696df3c 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetColorSettingsPage.java @@ -141,6 +141,8 @@ public class JetColorSettingsPage implements ColorSettingsPage { new AttributesDescriptor("Namespace property with backing field", JetHighlightingColors.NAMESPACE_PROPERTY_WITH_BACKING_FIELD), new AttributesDescriptor("Namespace property backing field access", JetHighlightingColors.NAMESPACE_BACKING_FIELD_ACCESS), + new AttributesDescriptor("Extension property", JetHighlightingColors.EXTENSION_PROPERTY), + new AttributesDescriptor("Function literal default parameter", JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER), new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.bad.character"), JetHighlightingColors.BAD_CHARACTER), diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java index cd36eec9c19..5161be6dac3 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/JetHighlightingColors.java @@ -185,7 +185,7 @@ public class JetHighlightingColors { "KOTLIN_INSTANCE_PROPERTY_WITH_BACKING_FIELD", TextAttributes .fromFlyweight(CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes() - .getFlyweight().withEffectType(EffectType.BOLD_DOTTED_LINE).withEffectColor( + .getFlyweight().withEffectType(EffectType.LINE_UNDERSCORE).withEffectColor( CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes().getForegroundColor())) ); @@ -202,12 +202,17 @@ public class JetHighlightingColors { public static final TextAttributesKey NAMESPACE_PROPERTY_WITH_BACKING_FIELD = TextAttributesKey.createTextAttributesKey( "KOTLIN_NAMESPACE_PROPERTY_WITH_BACKING_FIELD", TextAttributes.fromFlyweight(CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes() - .getFlyweight().withEffectType(EffectType.BOLD_DOTTED_LINE).withEffectColor( + .getFlyweight().withEffectType(EffectType.LINE_UNDERSCORE).withEffectColor( CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes().getForegroundColor())) ); public static final TextAttributesKey NAMESPACE_BACKING_FIELD_ACCESS = TextAttributesKey.createTextAttributesKey( "KOTLIN_NAMESPACE_BACKING_FIELD_ACCESS", - CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes() + CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes() + ); + + public static final TextAttributesKey EXTENSION_PROPERTY = TextAttributesKey.createTextAttributesKey( + "KOTLIN_EXTENSION_PROPERTY", + CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes() ); public static final TextAttributesKey FUNCTION_LITERAL_DEFAULT_PARAMETER = TextAttributesKey.createTextAttributesKey( diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java index 6ad441e6fa4..bf2b740394d 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/PropertiesHighlightingVisitor.java @@ -25,6 +25,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lexer.JetTokens; class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor { @@ -34,12 +35,16 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor { @Override public void visitSimpleNameExpression(JetSimpleNameExpression expression) { - // TODO highlight extension properties DeclarationDescriptor target = bindingContext.get(BindingContext.REFERENCE_TARGET, expression); if (!(target instanceof PropertyDescriptor)) { return; } + if (((PropertyDescriptor)target).getReceiverParameter() != ReceiverDescriptor.NO_RECEIVER) { + holder.createInfoAnnotation(expression, null).setTextAttributes( + JetHighlightingColors.EXTENSION_PROPERTY); + } + boolean namespace = target.getContainingDeclaration() instanceof NamespaceDescriptor; if (expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) { holder.createInfoAnnotation(expression, null).setTextAttributes( @@ -62,6 +67,8 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor { boolean namespace = propertyDescriptor.getContainingDeclaration() instanceof NamespaceDescriptor; putPropertyAnnotation(nameIdentifier, namespace, Boolean.TRUE.equals(backingFieldRequired)); } + + super.visitProperty(property); } @Override