KT-11811 There is no intention "Make protected" for a val declared in parameters of constructor
#KT-11811 Fixed
This commit is contained in:
@@ -130,11 +130,12 @@ open class ChangeVisibilityModifierIntention protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun canBeProtected(declaration: KtDeclaration): Boolean {
|
private fun canBeProtected(declaration: KtDeclaration): Boolean {
|
||||||
var parent = declaration.parent
|
val parent = declaration.parent
|
||||||
if (parent is KtClassBody) {
|
return when (parent) {
|
||||||
parent = parent.parent
|
is KtClassBody -> parent.parent is KtClass
|
||||||
|
is KtParameterList -> parent.parent is KtPrimaryConstructor
|
||||||
|
else -> false
|
||||||
}
|
}
|
||||||
return parent is KtClass
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
abstract class C(<caret>val p: Int)
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
abstract class C(<caret>protected val p: Int)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
abstract class C(<caret>p: Int)
|
||||||
+1
@@ -1,6 +1,7 @@
|
|||||||
// "Remove 'val' from parameter" "false"
|
// "Remove 'val' from parameter" "false"
|
||||||
// ACTION: Make internal
|
// ACTION: Make internal
|
||||||
// ACTION: Make private
|
// ACTION: Make private
|
||||||
|
// ACTION: Make protected
|
||||||
// ACTION: Create test
|
// ACTION: Create test
|
||||||
class C(<caret>val x: String) {
|
class C(<caret>val x: String) {
|
||||||
}
|
}
|
||||||
@@ -2528,12 +2528,24 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constructorParameter.kt")
|
||||||
|
public void testConstructorParameter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/protected/constructorParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noModifier.kt")
|
@TestMetadata("noModifier.kt")
|
||||||
public void testNoModifier() throws Exception {
|
public void testNoModifier() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/protected/noModifier.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/protected/noModifier.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("notForNonValParameter.kt")
|
||||||
|
public void testNotForNonValParameter() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/protected/notForNonValParameter.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("notForObjectMember.kt")
|
@TestMetadata("notForObjectMember.kt")
|
||||||
public void testNotForObjectMember() throws Exception {
|
public void testNotForObjectMember() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/protected/notForObjectMember.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/protected/notForObjectMember.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user