special color for final instance fields (IDEA-120374)

This commit is contained in:
Anna Kozlova
2015-10-16 12:10:26 +02:00
parent 6b591e4b25
commit d9e1d4266b
5 changed files with 9 additions and 3 deletions
@@ -191,9 +191,9 @@ public class HighlightNamesUtil {
return HighlightInfoType.LOCAL_VARIABLE;
}
if (var instanceof PsiField) {
return var.hasModifierProperty(PsiModifier.STATIC) ? var.hasModifierProperty(PsiModifier.FINAL)
? HighlightInfoType.STATIC_FINAL_FIELD
: HighlightInfoType.STATIC_FIELD : HighlightInfoType.INSTANCE_FIELD;
return var.hasModifierProperty(PsiModifier.STATIC)
? var.hasModifierProperty(PsiModifier.FINAL) ? HighlightInfoType.STATIC_FINAL_FIELD : HighlightInfoType.STATIC_FIELD
: var.hasModifierProperty(PsiModifier.FINAL) ? HighlightInfoType.INSTANCE_FINAL_FIELD : HighlightInfoType.INSTANCE_FIELD;
}
if (var instanceof PsiParameter) {
return HighlightInfoType.PARAMETER;
@@ -71,6 +71,7 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.reassigned.parameter"), CodeInsightColors.REASSIGNED_PARAMETER_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.implicit.anonymous.parameter"), CodeInsightColors.IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.instance.field"), CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.instance.final.field"), CodeInsightColors.INSTANCE_FINAL_FIELD_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.static.field"), CodeInsightColors.STATIC_FIELD_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.static.final.field"), CodeInsightColors.STATIC_FINAL_FIELD_ATTRIBUTES),
new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.parameter"), CodeInsightColors.PARAMETER_ATTRIBUTES),
@@ -120,6 +121,7 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
ourTags.put("annotationName", CodeInsightColors.ANNOTATION_NAME_ATTRIBUTES);
ourTags.put("annotationAttributeName", CodeInsightColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES);
ourTags.put("javadocTagValue", JavaHighlightingColors.DOC_COMMENT_TAG_VALUE);
ourTags.put("instanceFinalField", CodeInsightColors.INSTANCE_FINAL_FIELD_ATTRIBUTES);
}
@Override
@@ -168,6 +170,7 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
" private double <unusedField>unusedField</unusedField> = 12345.67890;\n" +
" private <unknownType>UnknownType</unknownType> <field>anotherString</field> = \"Another\\nStrin\\g\";\n" +
" public static int <static>staticField</static> = 0;\n" +
" public final int <instanceFinalField>instanceFinalField</instanceFinalField> = 0;\n" +
"\n" +
" public <constructorDeclaration>SomeClass</constructorDeclaration>(<interface>AnInterface</interface> <param>param</param>, int[] <reassignedParameter>reassignedParam</reassignedParameter>) {\n" +
" <error>int <localVar>localVar</localVar> = \"IntelliJ\"</error>; // Error, incompatible types\n" +
@@ -69,6 +69,7 @@ public interface HighlightInfoType {
HighlightInfoType LOCAL_VARIABLE = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.LOCAL_VARIABLE_ATTRIBUTES);
HighlightInfoType INSTANCE_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.INSTANCE_FIELD_ATTRIBUTES);
HighlightInfoType INSTANCE_FINAL_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.INSTANCE_FINAL_FIELD_ATTRIBUTES);
HighlightInfoType STATIC_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.STATIC_FIELD_ATTRIBUTES);
HighlightInfoType STATIC_FINAL_FIELD = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.STATIC_FINAL_FIELD_ATTRIBUTES);
HighlightInfoType PARAMETER = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.PARAMETER_ATTRIBUTES);
@@ -37,6 +37,7 @@ public interface CodeInsightColors {
TextAttributesKey REASSIGNED_PARAMETER_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("REASSIGNED_PARAMETER_ATTRIBUTES", PARAMETER_ATTRIBUTES);
TextAttributesKey IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES");
TextAttributesKey INSTANCE_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INSTANCE_FIELD_ATTRIBUTES");
TextAttributesKey INSTANCE_FINAL_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INSTANCE_FINAL_FIELD_ATTRIBUTES", INSTANCE_FIELD_ATTRIBUTES);
TextAttributesKey STATIC_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FIELD_ATTRIBUTES");
TextAttributesKey STATIC_FINAL_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FINAL_FIELD_ATTRIBUTES", STATIC_FIELD_ATTRIBUTES);
TextAttributesKey CLASS_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("CLASS_NAME_ATTRIBUTES");
@@ -80,6 +80,7 @@ options.java.attribute.descriptor.reassigned.local.variable=Variables//Reassigne
options.java.attribute.descriptor.reassigned.parameter=Parameters//Reassigned parameter
options.java.attribute.descriptor.implicit.anonymous.parameter=Parameters//Implicit anonymous class parameter
options.java.attribute.descriptor.instance.field=Class Fields//Instance field
options.java.attribute.descriptor.instance.final.field=Class Fields//Instance final field
options.java.attribute.descriptor.static.field=Class Fields//Static field
options.java.attribute.descriptor.static.final.field=Class Fields//Constant (static final field)
options.java.attribute.descriptor.parameter=Parameters//Parameter