Made styles for properties cascading, and therefore easier to tune.
This commit is contained in:
@@ -134,13 +134,9 @@ public class JetColorSettingsPage implements ColorSettingsPage {
|
||||
new AttributesDescriptor("Mutable local variable (var)", JetHighlightingColors.LOCAL_VAR),
|
||||
|
||||
new AttributesDescriptor("Instance property", JetHighlightingColors.INSTANCE_PROPERTY),
|
||||
new AttributesDescriptor("Instance property with backing field", JetHighlightingColors.INSTANCE_PROPERTY_WITH_BACKING_FIELD),
|
||||
new AttributesDescriptor("Instance property backing field access", JetHighlightingColors.INSTANCE_BACKING_FIELD_ACCESS),
|
||||
|
||||
new AttributesDescriptor("Namespace property", JetHighlightingColors.NAMESPACE_PROPERTY),
|
||||
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("Property with backing field", JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD),
|
||||
new AttributesDescriptor("Property backing field access", JetHighlightingColors.BACKING_FIELD_ACCESS),
|
||||
new AttributesDescriptor("Extension property", JetHighlightingColors.EXTENSION_PROPERTY),
|
||||
|
||||
new AttributesDescriptor("Function literal default parameter", JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER),
|
||||
|
||||
@@ -181,33 +181,19 @@ public class JetHighlightingColors {
|
||||
CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes()
|
||||
);
|
||||
|
||||
public static final TextAttributesKey INSTANCE_PROPERTY_WITH_BACKING_FIELD = TextAttributesKey.createTextAttributesKey(
|
||||
"KOTLIN_INSTANCE_PROPERTY_WITH_BACKING_FIELD",
|
||||
TextAttributes
|
||||
.fromFlyweight(CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes()
|
||||
.getFlyweight().withEffectType(EffectType.LINE_UNDERSCORE).withEffectColor(
|
||||
CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes().getForegroundColor()))
|
||||
);
|
||||
|
||||
public static final TextAttributesKey INSTANCE_BACKING_FIELD_ACCESS = TextAttributesKey.createTextAttributesKey(
|
||||
"KOTLIN_INSTANCE_BACKING_FIELD_ACCESS",
|
||||
CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES.getDefaultAttributes()
|
||||
);
|
||||
|
||||
public static final TextAttributesKey NAMESPACE_PROPERTY = TextAttributesKey.createTextAttributesKey(
|
||||
"KOTLIN_NAMESPACE_PROPERTY",
|
||||
CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes()
|
||||
);
|
||||
|
||||
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.LINE_UNDERSCORE).withEffectColor(
|
||||
CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes().getForegroundColor())) );
|
||||
public static final TextAttributesKey PROPERTY_WITH_BACKING_FIELD = TextAttributesKey.createTextAttributesKey(
|
||||
"KOTLIN_PROPERTY_WITH_BACKING_FIELD",
|
||||
new TextAttributes(null, null, INSTANCE_PROPERTY.getDefaultAttributes().getForegroundColor(), EffectType.LINE_UNDERSCORE, 0)
|
||||
);
|
||||
|
||||
public static final TextAttributesKey NAMESPACE_BACKING_FIELD_ACCESS = TextAttributesKey.createTextAttributesKey(
|
||||
"KOTLIN_NAMESPACE_BACKING_FIELD_ACCESS",
|
||||
CodeInsightColors.STATIC_FIELD_ATTRIBUTES.getDefaultAttributes()
|
||||
public static final TextAttributesKey BACKING_FIELD_ACCESS = TextAttributesKey.createTextAttributesKey(
|
||||
"KOTLIN_BACKING_FIELD_ACCESS",
|
||||
new TextAttributes()
|
||||
);
|
||||
|
||||
public static final TextAttributesKey EXTENSION_PROPERTY = TextAttributesKey.createTextAttributesKey(
|
||||
|
||||
@@ -46,14 +46,9 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
}
|
||||
|
||||
boolean namespace = target.getContainingDeclaration() instanceof NamespaceDescriptor;
|
||||
putPropertyAnnotation(expression, namespace, false);
|
||||
if (expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER) {
|
||||
holder.createInfoAnnotation(expression, null).setTextAttributes(
|
||||
(namespace ?
|
||||
JetHighlightingColors.NAMESPACE_BACKING_FIELD_ACCESS :
|
||||
JetHighlightingColors.INSTANCE_BACKING_FIELD_ACCESS)
|
||||
);
|
||||
} else {
|
||||
putPropertyAnnotation(expression, namespace, false);
|
||||
holder.createInfoAnnotation(expression, null).setTextAttributes(JetHighlightingColors.BACKING_FIELD_ACCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,15 +83,16 @@ class PropertiesHighlightingVisitor extends AfterAnalysisHighlightingVisitor {
|
||||
}
|
||||
|
||||
private void putPropertyAnnotation(@NotNull PsiElement elementToHighlight, boolean namespace, boolean withBackingField) {
|
||||
holder.createInfoAnnotation(
|
||||
elementToHighlight,
|
||||
"This property has a backing field")
|
||||
.setTextAttributes(withBackingField ?
|
||||
(namespace
|
||||
? JetHighlightingColors.NAMESPACE_PROPERTY_WITH_BACKING_FIELD
|
||||
: JetHighlightingColors.INSTANCE_PROPERTY_WITH_BACKING_FIELD) :
|
||||
(namespace
|
||||
? JetHighlightingColors.NAMESPACE_PROPERTY
|
||||
: JetHighlightingColors.INSTANCE_PROPERTY));
|
||||
holder.createInfoAnnotation(elementToHighlight, null).setTextAttributes(
|
||||
namespace
|
||||
? JetHighlightingColors.NAMESPACE_PROPERTY
|
||||
: JetHighlightingColors.INSTANCE_PROPERTY
|
||||
);
|
||||
if (withBackingField) {
|
||||
holder.createInfoAnnotation(
|
||||
elementToHighlight,
|
||||
"This property has a backing field")
|
||||
.setTextAttributes(JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user