mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] False negative "Join declaration and assignment" with a qualified reference
^KTIJ-26630 Fixed GitOrigin-RevId: 9a4ce1330396b57249cd2eeb1f49c456f081690b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b63199a336
commit
40cd2a16b1
+5
-6
@@ -126,19 +126,18 @@ class JoinDeclarationAndAssignmentIntention : SelfTargetingRangeIntention<KtProp
|
||||
if (property.typeReference == null) return null
|
||||
|
||||
val assignments = mutableListOf<KtBinaryExpression>()
|
||||
|
||||
fun process(binaryExpr: KtBinaryExpression) {
|
||||
if (binaryExpr.operationToken != KtTokens.EQ) return
|
||||
val leftReference = when (val left = binaryExpr.left) {
|
||||
is KtNameReferenceExpression ->
|
||||
left
|
||||
is KtDotQualifiedExpression ->
|
||||
if (left.receiverExpression is KtThisExpression) left.selectorExpression as? KtNameReferenceExpression else null
|
||||
else ->
|
||||
null
|
||||
is KtNameReferenceExpression -> left
|
||||
is KtDotQualifiedExpression -> left.selectorExpression as? KtNameReferenceExpression
|
||||
else -> null
|
||||
} ?: return
|
||||
if (leftReference.getReferencedName() != property.name) return
|
||||
assignments += binaryExpr
|
||||
}
|
||||
|
||||
propertyContainer.forEachDescendantOfType<KtBinaryExpression>(::process)
|
||||
|
||||
fun PsiElement?.isInvalidParent(): Boolean {
|
||||
|
||||
+10
@@ -12501,6 +12501,16 @@ public abstract class K1IntentionTestGenerated extends AbstractK1IntentionTest {
|
||||
runTest("testData/intentions/joinDeclarationAndAssignment/propertyReassignment.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualifiedName.kt")
|
||||
public void testQualifiedName() throws Exception {
|
||||
runTest("testData/intentions/joinDeclarationAndAssignment/qualifiedName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualifiedName2.kt")
|
||||
public void testQualifiedName2() throws Exception {
|
||||
runTest("testData/intentions/joinDeclarationAndAssignment/qualifiedName2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("testData/intentions/joinDeclarationAndAssignment/simple.kt");
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IS_APPLICABLE: true
|
||||
object Foo {
|
||||
val <caret>prop: Boolean
|
||||
|
||||
init {
|
||||
Foo.prop = true
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: true
|
||||
object Foo {
|
||||
val prop: Boolean = true
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// IS_APPLICABLE: true
|
||||
package pack
|
||||
|
||||
object Foo {
|
||||
val <caret>prop: Boolean
|
||||
|
||||
init {
|
||||
pack.Foo.prop = true
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// IS_APPLICABLE: true
|
||||
package pack
|
||||
|
||||
object Foo {
|
||||
val prop: Boolean = true
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user