mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
Java: add configuration for a separate color for record classes (IDEA-338018)
GitOrigin-RevId: 45ef46717d9d49575a3a207fbeacd2ea3759fb83
This commit is contained in:
committed by
intellij-monorepo-bot
parent
962277f78f
commit
3c2a0901cc
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl;
|
||||
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
@@ -45,7 +45,8 @@ public final class JavaHighlightInfoTypes {
|
||||
public final static HighlightInfoType ANONYMOUS_CLASS_NAME = createSymbolTypeInfo(JavaHighlightingColors.ANONYMOUS_CLASS_NAME_ATTRIBUTES);
|
||||
public final static HighlightInfoType INTERFACE_NAME = createSymbolTypeInfo(JavaHighlightingColors.INTERFACE_NAME_ATTRIBUTES);
|
||||
public final static HighlightInfoType ENUM_NAME = createSymbolTypeInfo(JavaHighlightingColors.ENUM_NAME_ATTRIBUTES);
|
||||
public final static HighlightInfoType TYPE_PARAMETER_NAME
|
||||
public final static HighlightInfoType RECORD_NAME = createSymbolTypeInfo(JavaHighlightingColors.RECORD_NAME_ATTRIBUTES);
|
||||
public final static HighlightInfoType TYPE_PARAMETER_NAME
|
||||
= new HighlightInfoType.HighlightInfoTypeImpl(HighlightInfoType.SYMBOL_TYPE_SEVERITY,
|
||||
JavaHighlightingColors.TYPE_PARAMETER_NAME_ATTRIBUTES);
|
||||
public final static HighlightInfoType ABSTRACT_CLASS_NAME = createSymbolTypeInfo(JavaHighlightingColors.ABSTRACT_CLASS_NAME_ATTRIBUTES);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInsight.daemon.impl.analysis;
|
||||
|
||||
import com.intellij.application.options.colors.ScopeAttributesUtil;
|
||||
@@ -248,6 +248,7 @@ public final class HighlightNamesUtil {
|
||||
if (aClass.isAnnotationType()) return JavaHighlightInfoTypes.ANNOTATION_NAME;
|
||||
if (aClass.isInterface()) return JavaHighlightInfoTypes.INTERFACE_NAME;
|
||||
if (aClass.isEnum()) return JavaHighlightInfoTypes.ENUM_NAME;
|
||||
if (aClass.isRecord()) return JavaHighlightInfoTypes.RECORD_NAME;
|
||||
if (aClass instanceof PsiTypeParameter) return JavaHighlightInfoTypes.TYPE_PARAMETER_NAME;
|
||||
PsiModifierList modList = aClass.getModifierList();
|
||||
if (modList != null && modList.hasModifierProperty(PsiModifier.ABSTRACT)) return JavaHighlightInfoTypes.ABSTRACT_CLASS_NAME;
|
||||
@@ -379,6 +380,7 @@ public final class HighlightNamesUtil {
|
||||
static HighlightInfo highlightKeyword(@NotNull PsiKeyword keyword) {
|
||||
return nameBuilder(JavaHighlightInfoTypes.JAVA_KEYWORD).range(keyword).create();
|
||||
}
|
||||
|
||||
static HighlightInfo highlightClassKeyword(@NotNull PsiKeyword keyword) {
|
||||
return nameBuilder(JavaHighlightInfoTypes.JAVA_KEYWORD_CLASS_FILE).range(keyword).create();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.highlighter;
|
||||
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
@@ -43,6 +43,7 @@ public final class JavaHighlightingColors {
|
||||
public static final TextAttributesKey TYPE_PARAMETER_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("TYPE_PARAMETER_NAME_ATTRIBUTES", DefaultLanguageHighlighterColors.PARAMETER);
|
||||
public static final TextAttributesKey INTERFACE_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("INTERFACE_NAME_ATTRIBUTES", DefaultLanguageHighlighterColors.INTERFACE_NAME);
|
||||
public static final TextAttributesKey ENUM_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ENUM_NAME_ATTRIBUTES", CLASS_NAME_ATTRIBUTES);
|
||||
public static final TextAttributesKey RECORD_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("RECORD_NAME_ATTRIBUTES", CLASS_NAME_ATTRIBUTES);
|
||||
public static final TextAttributesKey ABSTRACT_CLASS_NAME_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("ABSTRACT_CLASS_NAME_ATTRIBUTES", CLASS_NAME_ATTRIBUTES);
|
||||
public static final TextAttributesKey METHOD_CALL_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("METHOD_CALL_ATTRIBUTES", DefaultLanguageHighlighterColors.FUNCTION_CALL);
|
||||
public static final TextAttributesKey METHOD_DECLARATION_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("METHOD_DECLARATION_ATTRIBUTES", DefaultLanguageHighlighterColors.FUNCTION_DECLARATION);
|
||||
|
||||
@@ -50,6 +50,7 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.abstract.class"), JavaHighlightingColors.ABSTRACT_CLASS_NAME_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.interface"), JavaHighlightingColors.INTERFACE_NAME_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.enum"), JavaHighlightingColors.ENUM_NAME_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.record"), JavaHighlightingColors.RECORD_NAME_ATTRIBUTES),
|
||||
new AttributesDescriptor(OptionsBundle.messagePointer("options.java.attribute.descriptor.local.variable"), JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.reassigned.local.variable"), JavaHighlightingColors.REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES),
|
||||
new AttributesDescriptor(JavaOptionBundle.messagePointer("options.java.attribute.descriptor.reassigned.parameter"), JavaHighlightingColors.REASSIGNED_PARAMETER_ATTRIBUTES),
|
||||
@@ -111,6 +112,7 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
ourTags.put("abstractClass", JavaHighlightingColors.ABSTRACT_CLASS_NAME_ATTRIBUTES);
|
||||
ourTags.put("interface", JavaHighlightingColors.INTERFACE_NAME_ATTRIBUTES);
|
||||
ourTags.put("enum", JavaHighlightingColors.ENUM_NAME_ATTRIBUTES);
|
||||
ourTags.put("record", JavaHighlightingColors.RECORD_NAME_ATTRIBUTES);
|
||||
ourTags.put("annotationName", JavaHighlightingColors.ANNOTATION_NAME_ATTRIBUTES);
|
||||
ourTags.put("annotationAttributeName", JavaHighlightingColors.ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES);
|
||||
ourTags.put("javadocTagValue", JavaHighlightingColors.DOC_COMMENT_TAG_VALUE);
|
||||
@@ -143,6 +145,11 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
return ColorDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Note: this method is overridden in {@link JavaColorSettingsPage}.
|
||||
* Any changes you make here, you will probably want to do there as well.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public String getDemoText() {
|
||||
@@ -183,6 +190,8 @@ public abstract class AbstractBasicJavaColorSettingsPage
|
||||
int <static_final>CONSTANT</static_final> = 2;
|
||||
void <methodDeclaration>method</methodDeclaration>();
|
||||
}
|
||||
@interface <annotationName>AnnotationType</annotationName> {}
|
||||
record <record>Point</record>(int x, int y) {}
|
||||
abstract class <abstractClass>SomeAbstractClass</abstractClass> {
|
||||
}""";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ options.java.attribute.descriptor.class=Classes and Interfaces//Class
|
||||
options.java.attribute.descriptor.constructor.call=Methods//Constructor call
|
||||
options.java.attribute.descriptor.constructor.declaration=Methods//Constructor declaration
|
||||
options.java.attribute.descriptor.enum=Classes and Interfaces//Enum
|
||||
options.java.attribute.descriptor.record=Classes and Interfaces//Record
|
||||
options.java.attribute.descriptor.implicit.anonymous.parameter=Parameters//Implicit anonymous class parameter
|
||||
options.java.attribute.descriptor.inherited.method=Methods//Inherited method
|
||||
options.java.attribute.descriptor.instance.field=Class Fields//Instance field
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.options.colors.RainbowColorSettingsPage;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -31,60 +30,65 @@ public final class JavaColorSettingsPage extends AbstractBasicJavaColorSettingsP
|
||||
@Override
|
||||
public @NotNull String getDemoText() {
|
||||
return
|
||||
"/* Block comment */\n" +
|
||||
"import <class>java.util.Date</class>;\n" +
|
||||
"import static <interface>AnInterface</interface>.<static_final>CONSTANT</static_final>;\n" +
|
||||
"import static <class>java.util.Date</class>.<static_method>parse</static_method>;\n" +
|
||||
"import static <class>SomeClass</class>.<static>staticField</static>;\n" +
|
||||
"/**\n" +
|
||||
" * Doc comment here for <code>SomeClass</code>\n" +
|
||||
" * @param <javadocTagValue>T</javadocTagValue> type parameter\n" +
|
||||
" * @see <class>Math</class>#<methodCall>sin</methodCall>(double)\n" +
|
||||
" */\n" +
|
||||
"<annotationName>@Annotation</annotationName> (<annotationAttributeName>name</annotationAttributeName>=value)\n" +
|
||||
"public class <class>SomeClass</class><<typeParameter>T</typeParameter> extends <interface>Runnable</interface>> { // some comment\n" +
|
||||
" private <typeParameter>T</typeParameter> <field>field</field> = null;\n" +
|
||||
" 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" +
|
||||
" protected final int protectedField = 0;\n" +
|
||||
" final int packagePrivateField = 0;\n" +
|
||||
"\n" +
|
||||
" /**" +
|
||||
RainbowHighlighter.generatePaletteExample("\n * ") + "\n" +
|
||||
" * @param <javadocTagValue>param1</javadocTagValue>\n" +
|
||||
" * @param <javadocTagValue>param2</javadocTagValue>\n" +
|
||||
" * @param <javadocTagValue>param3</javadocTagValue>\n" +
|
||||
" */\n" +
|
||||
" public <constructorDeclaration>SomeClass</constructorDeclaration>(<interface>AnInterface</interface> <param>param1</param>,\n" +
|
||||
" int <param>param2</param>,\n" +
|
||||
" int <param>param3</param>) {\n" +
|
||||
" int <reassignedLocalVar>reassignedValue</reassignedLocalVar> = this.<warning>staticField</warning> + <param>param2</param> + <param>param3</param>;\n" +
|
||||
" long <localVar>localVar1</localVar>, <localVar>localVar2</localVar>, <localVar>localVar3</localVar>, <localVar>localVar4</localVar>;\n" +
|
||||
" <error>int <localVar>localVar</localVar> = \"IntelliJ\"</error>; // Error, incompatible types\n" +
|
||||
" <class>System</class>.<static>out</static>.<methodCall>println</methodCall>(<private><field>anotherString</field></private> + <inherited_method>toString</inherited_method>() + <localVar>localVar</localVar>);\n" +
|
||||
" int <localVar>sum</localVar> = <protected><field>protectedField</field></protected> + <package_private><field>packagePrivateField</field></package_private> + <public><static>staticField</static></public>;\n" +
|
||||
" long <localVar>time</localVar> = <static_imported_method><deprecated>parse</deprecated></static_imported_method>(\"1.2.3\"); // Method is deprecated\n" +
|
||||
" new <class>Thread</class>().<for_removal>countStackFrames</for_removal>(); // Method is deprecated and marked for removal\n" +
|
||||
" <reassignedLocalVar>reassignedValue</reassignedLocalVar> ++; \n" +
|
||||
" <field>field</field>.<abstract_method>run</abstract_method>(); \n" +
|
||||
" new <anonymousClass>SomeClass</anonymousClass>() {\n" +
|
||||
" {\n" +
|
||||
" int <localVar>a</localVar> = <implicitAnonymousParameter>localVar</implicitAnonymousParameter>;\n" +
|
||||
" }\n" +
|
||||
" };\n" +
|
||||
" int[] <localVar>l</localVar> = new <constructorCall>ArrayList</constructorCall><<class>String</class>>().<methodCall>toArray</methodCall>(new int[<staticallyConstImported>CONSTANT</staticallyConstImported>]);\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
"enum <enum>AnEnum</enum> { <static_final>CONST1</static_final>, <static_final>CONST2</static_final> }\n" +
|
||||
"interface <interface>AnInterface</interface> {\n" +
|
||||
" int <static_final>CONSTANT</static_final> = 2;\n" +
|
||||
" void <methodDeclaration>method</methodDeclaration>();\n" +
|
||||
"}\n" +
|
||||
"abstract class <abstractClass>SomeAbstractClass</abstractClass> {\n" +
|
||||
" protected int <field>instanceField</field> = <staticallyImported>staticField</staticallyImported>;\n" +
|
||||
"}";
|
||||
"""
|
||||
/* Block comment */
|
||||
import <class>java.util.Date</class>;
|
||||
import static <interface>AnInterface</interface>.<static_final>CONSTANT</static_final>;
|
||||
import static <class>java.util.Date</class>.<static_method>parse</static_method>;
|
||||
import static <class>SomeClass</class>.<static>staticField</static>;
|
||||
/**
|
||||
* Doc comment here for <code>SomeClass</code>
|
||||
* @param <javadocTagValue>T</javadocTagValue> type parameter
|
||||
* @see <class>Math</class>#<methodCall>sin</methodCall>(double)
|
||||
*/
|
||||
<annotationName>@Annotation</annotationName> (<annotationAttributeName>name</annotationAttributeName>=value)
|
||||
public class <class>SomeClass</class><<typeParameter>T</typeParameter> extends <interface>Runnable</interface>> { // some comment
|
||||
private <typeParameter>T</typeParameter> <field>field</field> = null;
|
||||
private double <unusedField>unusedField</unusedField> = 12345.67890;
|
||||
private <unknownType>UnknownType</unknownType> <field>anotherString</field> = "Another\\nStrin\\g";
|
||||
public static int <static>staticField</static> = 0;
|
||||
public final int <instanceFinalField>instanceFinalField</instanceFinalField> = 0;
|
||||
protected final int protectedField = 0;
|
||||
final int packagePrivateField = 0;
|
||||
|
||||
/**""" +
|
||||
RainbowHighlighter.generatePaletteExample("\n * ") +
|
||||
"""
|
||||
|
||||
* @param <javadocTagValue>param1</javadocTagValue>
|
||||
* @param <javadocTagValue>param2</javadocTagValue>
|
||||
* @param <javadocTagValue>param3</javadocTagValue>
|
||||
*/
|
||||
public <constructorDeclaration>SomeClass</constructorDeclaration>(<interface>AnInterface</interface> <param>param1</param>,
|
||||
int <param>param2</param>,
|
||||
int <param>param3</param>) {
|
||||
int <reassignedLocalVar>reassignedValue</reassignedLocalVar> = this.<warning>staticField</warning> + <param>param2</param> + <param>param3</param>;
|
||||
long <localVar>localVar1</localVar>, <localVar>localVar2</localVar>, <localVar>localVar3</localVar>, <localVar>localVar4</localVar>;
|
||||
<error>int <localVar>localVar</localVar> = "IntelliJ"</error>; // Error, incompatible types
|
||||
<class>System</class>.<static>out</static>.<methodCall>println</methodCall>(<private><field>anotherString</field></private> + <inherited_method>toString</inherited_method>() + <localVar>localVar</localVar>);
|
||||
int <localVar>sum</localVar> = <protected><field>protectedField</field></protected> + <package_private><field>packagePrivateField</field></package_private> + <public><static>staticField</static></public>;
|
||||
long <localVar>time</localVar> = <static_imported_method><deprecated>parse</deprecated></static_imported_method>("1.2.3"); // Method is deprecated
|
||||
new <class>Thread</class>().<for_removal>countStackFrames</for_removal>(); // Method is deprecated and marked for removal
|
||||
<reassignedLocalVar>reassignedValue</reassignedLocalVar> ++;\s
|
||||
<field>field</field>.<abstract_method>run</abstract_method>();\s
|
||||
new <anonymousClass>SomeClass</anonymousClass>() {
|
||||
{
|
||||
int <localVar>a</localVar> = <implicitAnonymousParameter>localVar</implicitAnonymousParameter>;
|
||||
}
|
||||
};
|
||||
int[] <localVar>l</localVar> = new <constructorCall>ArrayList</constructorCall><<class>String</class>>().<methodCall>toArray</methodCall>(new int[<staticallyConstImported>CONSTANT</staticallyConstImported>]);
|
||||
}
|
||||
}
|
||||
enum <enum>AnEnum</enum> { <static_final>CONST1</static_final>, <static_final>CONST2</static_final> }
|
||||
interface <interface>AnInterface</interface> {
|
||||
int <static_final>CONSTANT</static_final> = 2;
|
||||
void <methodDeclaration>method</methodDeclaration>();
|
||||
}
|
||||
@interface <annotationName>AnnotationType</annotationName> {}
|
||||
record <record>Point</record>(int x, int y) {}
|
||||
abstract class <abstractClass>SomeAbstractClass</abstractClass> {
|
||||
protected int <field>instanceField</field> = <staticallyImported>staticField</staticallyImported>;
|
||||
}""";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +101,7 @@ public final class JavaColorSettingsPage extends AbstractBasicJavaColorSettingsP
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Language getLanguage() {
|
||||
public @NotNull Language getLanguage() {
|
||||
return JavaLanguage.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.editor;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaHighlightingColors;
|
||||
@@ -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_NAME_ATTRIBUTES { color: #000000; font-style: normal; }
|
||||
STATIC_FIELD_ATTRIBUTES { color: #660e7a; font-style: italic; }
|
||||
STATIC_FIELD_IMPORTED_ATTRIBUTES { color: #660e7a; font-style: italic; }
|
||||
STATIC_FINAL_FIELD_ATTRIBUTES { color: #660e7a; font-style: italic; font-weight: bold; }
|
||||
@@ -206,6 +207,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_NAME_ATTRIBUTES { color: #a9b7c6; font-style: normal; }
|
||||
STATIC_FIELD_ATTRIBUTES { color: #9876aa; font-style: italic; }
|
||||
STATIC_FIELD_IMPORTED_ATTRIBUTES { color: #9876aa; font-style: italic; }
|
||||
STATIC_FINAL_FIELD_ATTRIBUTES { color: #9876aa; font-style: italic; }
|
||||
|
||||
Reference in New Issue
Block a user