KT-21949 Please add a separate Color Scheme settings for properties synthesized from Java accessors (#1458)

This commit is contained in:
Toshiaki Kameyama
2018-01-08 21:04:43 +09:00
committed by Dmitry Jemerov
parent 19c35ef48c
commit 3b212558e2
6 changed files with 13 additions and 1 deletions
@@ -82,6 +82,7 @@ options.kotlin.attribute.descriptor.instance.property=Properties and Variables//
options.kotlin.attribute.descriptor.package.property=Properties and Variables//Package-level property
options.kotlin.attribute.descriptor.field=Properties and Variables//Backing field variable
options.kotlin.attribute.descriptor.extension.property=Properties and Variables//Extension property
options.kotlin.attribute.descriptor.synthetic.extension.property=Properties and Variables//Synthetic extension property
options.kotlin.attribute.descriptor.dynamic.property=Properties and Variables//Dynamic property
options.kotlin.attribute.descriptor.android.extensions.property=Properties and Variables//Android Extensions synthetic properties
options.kotlin.attribute.descriptor.it=Parameters//Lambda expression default parameter
@@ -70,6 +70,7 @@ public class KotlinHighlightingColors {
public static final TextAttributesKey PACKAGE_PROPERTY = createTextAttributesKey("KOTLIN_PACKAGE_PROPERTY", DefaultLanguageHighlighterColors.STATIC_FIELD);
public static final TextAttributesKey BACKING_FIELD_VARIABLE = createTextAttributesKey("KOTLIN_BACKING_FIELD_VARIABLE");
public static final TextAttributesKey EXTENSION_PROPERTY = createTextAttributesKey("KOTLIN_EXTENSION_PROPERTY", DefaultLanguageHighlighterColors.STATIC_FIELD);
public static final TextAttributesKey SYNTHETIC_EXTENSION_PROPERTY = createTextAttributesKey("KOTLIN_SYNTHETIC_EXTENSION_PROPERTY", EXTENSION_PROPERTY);
public static final TextAttributesKey DYNAMIC_PROPERTY_CALL = createTextAttributesKey("KOTLIN_DYNAMIC_PROPERTY_CALL");
public static final TextAttributesKey ANDROID_EXTENSIONS_PROPERTY_CALL = createTextAttributesKey("KOTLIN_ANDROID_EXTENSIONS_PROPERTY_CALL");
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.KtThisExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic
import org.jetbrains.kotlin.resolve.calls.tower.isSynthesized
internal class PropertiesHighlightingVisitor(holder: AnnotationHolder, bindingContext: BindingContext)
: AfterAnalysisHighlightingVisitor(holder, bindingContext) {
@@ -79,7 +80,7 @@ internal class PropertiesHighlightingVisitor(holder: AnnotationHolder, bindingCo
DYNAMIC_PROPERTY_CALL
descriptor.extensionReceiverParameter != null ->
EXTENSION_PROPERTY
if (descriptor.isSynthesized) SYNTHETIC_EXTENSION_PROPERTY else EXTENSION_PROPERTY
DescriptorUtils.isStaticDeclaration(descriptor) ->
PACKAGE_PROPERTY
@@ -60,6 +60,7 @@ class KotlinColorSettingsPage : ColorSettingsPage, RainbowColorSettingsPage {
dyn.<DYNAMIC_FUNCTION_CALL>dynamicCall</DYNAMIC_FUNCTION_CALL>()
dyn.<DYNAMIC_PROPERTY_CALL>dynamicProp</DYNAMIC_PROPERTY_CALL> = 5
val <LOCAL_VARIABLE>klass</LOCAL_VARIABLE> = <CLASS>MyClass</CLASS>::<KEYWORD>class</KEYWORD>
val year = java.time.LocalDate.now().<SYNTHETIC_EXTENSION_PROPERTY>year</SYNTHETIC_EXTENSION_PROPERTY>
}
<BUILTIN_ANNOTATION>override</BUILTIN_ANNOTATION> fun hashCode(): Int {
@@ -155,6 +156,7 @@ var <PACKAGE_PROPERTY><MUTABLE_VARIABLE>globalCounter</MUTABLE_VARIABLE></PACKAG
KotlinBundle.message("options.kotlin.attribute.descriptor.package.property") to KotlinHighlightingColors.PACKAGE_PROPERTY,
KotlinBundle.message("options.kotlin.attribute.descriptor.field") to KotlinHighlightingColors.BACKING_FIELD_VARIABLE,
KotlinBundle.message("options.kotlin.attribute.descriptor.extension.property") to KotlinHighlightingColors.EXTENSION_PROPERTY,
KotlinBundle.message("options.kotlin.attribute.descriptor.synthetic.extension.property") to KotlinHighlightingColors.SYNTHETIC_EXTENSION_PROPERTY,
KotlinBundle.message("options.kotlin.attribute.descriptor.dynamic.property") to KotlinHighlightingColors.DYNAMIC_PROPERTY_CALL,
KotlinBundle.message("options.kotlin.attribute.descriptor.android.extensions.property") to KotlinHighlightingColors.ANDROID_EXTENSIONS_PROPERTY_CALL,
KotlinBundle.message("options.kotlin.attribute.descriptor.it") to KotlinHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER,
@@ -0,0 +1 @@
val <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">weekYear</info> = java.util.<info textAttributesKey="KOTLIN_ABSTRACT_CLASS">Calendar</info>.<info textAttributesKey="KOTLIN_FUNCTION_CALL">getInstance</info>().<info textAttributesKey="KOTLIN_SYNTHETIC_EXTENSION_PROPERTY">weekYear</info>
@@ -120,6 +120,12 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
doTest(fileName);
}
@TestMetadata("SyntheticExtensionProperty.kt")
public void testSyntheticExtensionProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/SyntheticExtensionProperty.kt");
doTest(fileName);
}
@TestMetadata("Todo.kt")
public void testTodo() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/highlighter/Todo.kt");