"Use destructuring declaration" should not be available for top-level and class properties (#1205)

Fixes #KT-19167
This commit is contained in:
Kirill Rakhman
2017-07-24 14:33:46 +02:00
committed by Dmitry Jemerov
parent f558b4238c
commit 4c7ddbe397
4 changed files with 30 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -156,7 +156,7 @@ class DestructureIntention : SelfTargetingRangeIntention<KtDeclaration>(
else -> null
}
}
is KtVariableDeclaration -> parent
is KtProperty -> parent.takeIf { isLocal }
is KtFunctionLiteral -> if (!hasParameterSpecification() && lambdaSupported) this else null
else -> null
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: false
data class XY(val x: Int, val y: Int)
fun create() = XY(1, 2)
class Foo {
val xy = <caret>create()
}
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
data class XY(val x: Int, val y: Int)
fun create() = XY(1, 2)
val xy = <caret>create()
@@ -7832,6 +7832,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("classProperty.kt")
public void testClassProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/destructuringVariables/classProperty.kt");
doTest(fileName);
}
@TestMetadata("noInitializer.kt")
public void testNoInitializer() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/destructuringVariables/noInitializer.kt");
@@ -7844,6 +7850,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("toplevel.kt")
public void testToplevel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/destructuringVariables/toplevel.kt");
doTest(fileName);
}
@TestMetadata("var.kt")
public void testVar() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/destructuringVariables/var.kt");