Properties with custom property declarations highlighting rule.

Added support for package and class-level properties with custom PD.
Java syntethic extensions are ignored from this rule.

 #KT-30806 Fixed
This commit is contained in:
Vladimir Ilmov
2019-11-07 12:09:46 +03:00
parent bf37572b93
commit e2b91cfec7
11 changed files with 114 additions and 10 deletions
+2 -2
View File
@@ -1,13 +1,13 @@
// EXPECTED_DUPLICATED_HIGHLIGHTING
// FALSE_POSITIVE
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info> = 0
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info> = 0
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">field</info></info>
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">arg</info>) {
<info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">field</info></info> = <info textAttributesKey="KOTLIN_PARAMETER">arg</info> + 1
}
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">foo</info>(): <info textAttributesKey="KOTLIN_CLASS">Int</info> {
val <info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info> = <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info>
val <info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info> = <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">my</info></info>
return <info textAttributesKey="KOTLIN_LOCAL_VARIABLE">field</info>
}
@@ -0,0 +1,42 @@
// EXPECTED_DUPLICATED_HIGHLIGHTING
val <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">packageSize</info> = 0
val <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">packageSizeGetter</info></info>
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">packageSize</info> * 2
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">packageSizeSetter</info></info></info> = 5
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">value</info>) {
<info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">field</info></info> = <info textAttributesKey="KOTLIN_PARAMETER">value</info> * 2
}
var <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">packageSizeBean</info></info></info> = 5
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">packageSize</info> * 2
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">value</info>) {
<info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE">field</info></info> = <info textAttributesKey="KOTLIN_PARAMETER">value</info> * 2
}
class <info textAttributesKey="KOTLIN_CLASS">test</info>() {
// no highlighting check
val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">size</info> = 0
val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">classSize</info> = 0
val <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">classSizeGetter</info></info>
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">classSize</info> * 2
var <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">classSizeSetter</info></info></info> = 5
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">value</info>) {
<info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">field</info></info> = <info textAttributesKey="KOTLIN_PARAMETER">value</info> * 2
}
var <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">classSizeBean</info></info></info> = 5
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() = <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">classSize</info> * 2
<info textAttributesKey="KOTLIN_KEYWORD">set</info>(<info textAttributesKey="KOTLIN_PARAMETER">value</info>) {
<info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE">field</info></info> = <info textAttributesKey="KOTLIN_PARAMETER">value</info> * 2
}
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">callCustomPD</info>() {
<info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">classSizeBean</info></info></info> = 30
}
}
+15
View File
@@ -0,0 +1,15 @@
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">suspend</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">letsDoSuspendLambda</info>(<info textAttributesKey="KOTLIN_PARAMETER">block</info>: <info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">suspend</info> () -> <info textAttributesKey="KOTLIN_OBJECT">Unit</info>) {
val <info textAttributesKey="KOTLIN_LOCAL_VARIABLE">res</info> : <info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">suspend</info> (<info textAttributesKey="KOTLIN_CLASS">Int</info>) -> <info textAttributesKey="KOTLIN_CLASS">Int</info> = { <info textAttributesKey="KOTLIN_PARAMETER"><info textAttributesKey="KOTLIN_CLOSURE_DEFAULT_PARAMETER" descr=Automatically declared based on the expected type>it</info></info> + 1 };
<info textAttributesKey="KOTLIN_SUSPEND_FUNCTION_CALL">letsDoSomething</info> { <warning textAttributesKey="WARNING_ATTRIBUTES" descr=[UNUSED_EXPRESSION] The expression is unused><info textAttributesKey="KOTLIN_WRAPPED_INTO_REF" descr=Value captured in a closure>block</info></warning> }
<info textAttributesKey="KOTLIN_LOCAL_VARIABLE"><info textAttributesKey="KOTLIN_SUSPEND_FUNCTION_CALL">res</info></info>(5)
<info textAttributesKey="KOTLIN_WRAPPED_INTO_REF" descr=Value captured in a closure><info textAttributesKey="KOTLIN_SUSPEND_FUNCTION_CALL">block</info></info>()
}
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">suspend</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">letsDoSomething</info>(<info textAttributesKey="KOTLIN_PARAMETER">block</info>: <info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">suspend</info> () -> <info textAttributesKey="KOTLIN_OBJECT">Unit</info>) {
<info textAttributesKey="KOTLIN_SUSPEND_FUNCTION_CALL">doSomething</info>()
<info textAttributesKey="KOTLIN_SUSPEND_FUNCTION_CALL"><info textAttributesKey="KOTLIN_PARAMETER">block</info></info>()
}
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">suspend</info> fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">doSomething</info>() {
}
+3 -3
View File
@@ -7,7 +7,7 @@ val <info textAttributesKey="KOTLIN_CLASS">Int</info>.<info textAttributesKey="K
return this * this
}
val <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY">y</info> : <info textAttributesKey="KOTLIN_CLASS">Int</info> = 1
val <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">y</info> : <info textAttributesKey="KOTLIN_CLASS">Int</info> = 1
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() {
return 5.<info textAttributesKey="KOTLIN_EXTENSION_PROPERTY">sq</info> + <info textAttributesKey="KOTLIN_BACKING_FIELD_VARIABLE">field</info> + <info textAttributesKey="KOTLIN_PACKAGE_PROPERTY"><info textAttributesKey="KOTLIN_MUTABLE_VARIABLE">x</info></info>
}
@@ -17,13 +17,13 @@ class <info textAttributesKey="KOTLIN_CLASS">Foo</info>(
<info textAttributesKey="KOTLIN_PARAMETER">b</info> : <info textAttributesKey="KOTLIN_CLASS">String</info>,
var <info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">c</info></info> : <info textAttributesKey="KOTLIN_CLASS">String</info>
) {
<info>init</info> {
<info textAttributesKey="KOTLIN_KEYWORD">init</info> {
<info textAttributesKey="KOTLIN_PARAMETER">b</info>
}
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">f</info>(<info textAttributesKey="KOTLIN_PARAMETER">p</info> : <info textAttributesKey="KOTLIN_CLASS">Int</info> = <info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">a</info>) {}
var <info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY">v</info></info> : <info textAttributesKey="KOTLIN_CLASS">Int</info>
var <info textAttributesKey="KOTLIN_MUTABLE_VARIABLE"><info textAttributesKey="KOTLIN_INSTANCE_PROPERTY_CUSTOM_PROPERTY_DECLARATION">v</info></info> : <info textAttributesKey="KOTLIN_CLASS">Int</info>
<info textAttributesKey="KOTLIN_KEYWORD">get</info>() {
return 1;
}