mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: add configuration for a separate color for record components (IDEA-350397)
GitOrigin-RevId: d3efcc3d50a2641306c32775ab356c188330f8e8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c2a0901cc
commit
0ed14734d9
+1
@@ -28,6 +28,7 @@ public final class JavaHighlightInfoTypes {
|
||||
public final static HighlightInfoType LOCAL_VARIABLE = createSymbolTypeInfo(JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES);
|
||||
public final static HighlightInfoType INSTANCE_FIELD = createSymbolTypeInfo(JavaHighlightingColors.INSTANCE_FIELD_ATTRIBUTES);
|
||||
public final static HighlightInfoType INSTANCE_FINAL_FIELD = createSymbolTypeInfo(JavaHighlightingColors.INSTANCE_FINAL_FIELD_ATTRIBUTES);
|
||||
public final static HighlightInfoType RECORD_COMPONENT = createSymbolTypeInfo(JavaHighlightingColors.RECORD_COMPONENT_ATTRIBUTES);
|
||||
public final static HighlightInfoType STATIC_FIELD = createSymbolTypeInfo(JavaHighlightingColors.STATIC_FIELD_ATTRIBUTES);
|
||||
public final static HighlightInfoType STATIC_FIELD_IMPORTED = createSymbolTypeInfo(JavaHighlightingColors.STATIC_FIELD_IMPORTED_ATTRIBUTES);
|
||||
public final static HighlightInfoType STATIC_FINAL_FIELD = createSymbolTypeInfo(JavaHighlightingColors.STATIC_FINAL_FIELD_ATTRIBUTES);
|
||||
|
||||
+8
-3
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.packageDependencies.DependencyValidationManagerImpl;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.light.LightRecordField;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.TreeUtil;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
@@ -206,7 +207,7 @@ public final class HighlightNamesUtil {
|
||||
return isStaticallyImported ? JavaHighlightInfoTypes.STATIC_METHOD_CALL_IMPORTED : JavaHighlightInfoTypes.STATIC_METHOD;
|
||||
}
|
||||
if (isInheritedMethod) return JavaHighlightInfoTypes.INHERITED_METHOD;
|
||||
if(method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
|
||||
return JavaHighlightInfoTypes.ABSTRACT_METHOD;
|
||||
}
|
||||
return JavaHighlightInfoTypes.METHOD_CALL;
|
||||
@@ -218,6 +219,9 @@ public final class HighlightNamesUtil {
|
||||
|| var instanceof PsiParameter parameter && parameter.getDeclarationScope() instanceof PsiForeachStatement) {
|
||||
return JavaHighlightInfoTypes.LOCAL_VARIABLE;
|
||||
}
|
||||
if (var instanceof PsiRecordComponent || var instanceof LightRecordField) {
|
||||
return JavaHighlightInfoTypes.RECORD_COMPONENT;
|
||||
}
|
||||
if (var instanceof PsiField) {
|
||||
if (var.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
boolean staticallyImported = isStaticallyImported(elementToHighlight);
|
||||
@@ -233,8 +237,9 @@ public final class HighlightNamesUtil {
|
||||
}
|
||||
}
|
||||
if (var instanceof PsiParameter parameter) {
|
||||
return parameter.getDeclarationScope() instanceof PsiLambdaExpression ? JavaHighlightInfoTypes.LAMBDA_PARAMETER
|
||||
: JavaHighlightInfoTypes.PARAMETER;
|
||||
return parameter.getDeclarationScope() instanceof PsiLambdaExpression
|
||||
? JavaHighlightInfoTypes.LAMBDA_PARAMETER
|
||||
: JavaHighlightInfoTypes.PARAMETER;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public final class JavaHighlightingColors {
|
||||
public static final TextAttributesKey REASSIGNED_PARAMETER_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("REASSIGNED_PARAMETER_ATTRIBUTES", DefaultLanguageHighlighterColors.REASSIGNED_PARAMETER);
|
||||
public static final TextAttributesKey INSTANCE_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INSTANCE_FIELD_ATTRIBUTES", DefaultLanguageHighlighterColors.INSTANCE_FIELD);
|
||||
public static final TextAttributesKey INSTANCE_FINAL_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INSTANCE_FINAL_FIELD_ATTRIBUTES", INSTANCE_FIELD_ATTRIBUTES);
|
||||
public static final TextAttributesKey RECORD_COMPONENT_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("RECORD_COMPONENT_ATTRIBUTES", INSTANCE_FINAL_FIELD_ATTRIBUTES);
|
||||
public static final TextAttributesKey STATIC_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FIELD_ATTRIBUTES", DefaultLanguageHighlighterColors.STATIC_FIELD);
|
||||
public static final TextAttributesKey STATIC_FIELD_IMPORTED_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FIELD_IMPORTED_ATTRIBUTES", STATIC_FIELD_ATTRIBUTES);
|
||||
public static final TextAttributesKey STATIC_FINAL_FIELD_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("STATIC_FINAL_FIELD_ATTRIBUTES", STATIC_FIELD_ATTRIBUTES);
|
||||
|
||||
+3
-1
@@ -57,6 +57,7 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.implicit.anonymous.parameter"), JavaHighlightingColors.IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.instance.field"), JavaHighlightingColors.INSTANCE_FIELD_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.instance.final.field"), JavaHighlightingColors.INSTANCE_FINAL_FIELD_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.record.component"), JavaHighlightingColors.RECORD_COMPONENT_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.static.field"), JavaHighlightingColors.STATIC_FIELD_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.static.imported.field"), JavaHighlightingColors.STATIC_FIELD_IMPORTED_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.static.final.field"), JavaHighlightingColors.STATIC_FINAL_FIELD_ATTRIBUTES),
|
||||
@@ -117,6 +118,7 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
ourTags.put("annotationAttributeName", JavaHighlightingColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES);
|
||||
ourTags.put("javadocTagValue", JavaHighlightingColors.DOC_COMMENT_TAG_VALUE);
|
||||
ourTags.put("instanceFinalField", JavaHighlightingColors.INSTANCE_FINAL_FIELD_ATTRIBUTES);
|
||||
ourTags.put("recordComponent", JavaHighlightingColors.RECORD_COMPONENT_ATTRIBUTES);
|
||||
ourTags.put("staticallyConstImported", JavaHighlightingColors.STATIC_FINAL_FIELD_IMPORTED_ATTRIBUTES);
|
||||
ourTags.put("staticallyImported", JavaHighlightingColors.STATIC_FIELD_IMPORTED_ATTRIBUTES);
|
||||
ourTags.put("static_imported_method", JavaHighlightingColors.STATIC_METHOD_CALL_IMPORTED_ATTRIBUTES);
|
||||
@@ -191,7 +193,7 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
void <methodDeclaration>method</methodDeclaration>();
|
||||
}
|
||||
@interface <annotationName>AnnotationType</annotationName> {}
|
||||
record <record>Point</record>(int x, int y) {}
|
||||
record <record>Point</record>(int <recordComponent>x</recordComponent>, int <recordComponent>y</recordComponent>) {}
|
||||
abstract class <abstractClass>SomeAbstractClass</abstractClass> {
|
||||
}""";
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ options.java.attribute.descriptor.implicit.anonymous.parameter=Parameters//Impli
|
||||
options.java.attribute.descriptor.inherited.method=Methods//Inherited method
|
||||
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.record.component=Class Fields//Record component
|
||||
options.java.attribute.descriptor.interface=Classes and Interfaces//Interface
|
||||
options.java.attribute.descriptor.javadoc.comment=Comments//JavaDoc//Text
|
||||
options.java.attribute.descriptor.javadoc.markup=Comments//JavaDoc//Markup
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public final class JavaColorSettingsPage extends AbstractBasicJavaColorSettingsP
|
||||
void <methodDeclaration>method</methodDeclaration>();
|
||||
}
|
||||
@interface <annotationName>AnnotationType</annotationName> {}
|
||||
record <record>Point</record>(int x, int y) {}
|
||||
record <record>Point</record>(int <recordComponent>x</recordComponent>, int <recordComponent>y</recordComponent>) {}
|
||||
abstract class <abstractClass>SomeAbstractClass</abstractClass> {
|
||||
protected int <field>instanceField</field> = <staticallyImported>staticField</staticallyImported>;
|
||||
}""";
|
||||
|
||||
@@ -148,6 +148,7 @@ public class JavaEditorTextAttributesTest extends LightPlatformTestCase {
|
||||
PUBLIC_REFERENCE { color: #000000; font-style: normal; }
|
||||
REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES { color: #000000; font-style: normal; text-decoration: underline #909090; }
|
||||
REASSIGNED_PARAMETER_ATTRIBUTES { color: #000000; font-style: normal; text-decoration: underline #909090; }
|
||||
RECORD_COMPONENT_ATTRIBUTES { color: #660e7a; font-style: normal; font-weight: bold; }
|
||||
RECORD_NAME_ATTRIBUTES { color: #000000; font-style: normal; }
|
||||
STATIC_FIELD_ATTRIBUTES { color: #660e7a; font-style: italic; }
|
||||
STATIC_FIELD_IMPORTED_ATTRIBUTES { color: #660e7a; font-style: italic; }
|
||||
@@ -207,6 +208,7 @@ public class JavaEditorTextAttributesTest extends LightPlatformTestCase {
|
||||
PUBLIC_REFERENCE { color: #a9b7c6; font-style: normal; }
|
||||
REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES { color: #a9b7c6; font-style: normal; text-decoration: underline #707d95; }
|
||||
REASSIGNED_PARAMETER_ATTRIBUTES { color: #a9b7c6; font-style: normal; text-decoration: underline #707d95; }
|
||||
RECORD_COMPONENT_ATTRIBUTES { color: #9876aa; font-style: normal; }
|
||||
RECORD_NAME_ATTRIBUTES { color: #a9b7c6; font-style: normal; }
|
||||
STATIC_FIELD_ATTRIBUTES { color: #9876aa; font-style: italic; }
|
||||
STATIC_FIELD_IMPORTED_ATTRIBUTES { color: #9876aa; font-style: italic; }
|
||||
|
||||
Reference in New Issue
Block a user