Extends range of change visibility intention #KT-14093 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
44ce5f73f7
commit
3a606d13f0
@@ -56,14 +56,9 @@ open class ChangeVisibilityModifierIntention protected constructor(
|
|||||||
|
|
||||||
text = defaultText
|
text = defaultText
|
||||||
|
|
||||||
val modifierElement = element.visibilityModifier()
|
|
||||||
if (modifierElement != null) {
|
|
||||||
return modifierElement.textRange
|
|
||||||
}
|
|
||||||
|
|
||||||
val defaultRange = noModifierYetApplicabilityRange(element) ?: return null
|
val defaultRange = noModifierYetApplicabilityRange(element) ?: return null
|
||||||
|
|
||||||
if (element is KtPrimaryConstructor && defaultRange.isEmpty) {
|
if (element is KtPrimaryConstructor && defaultRange.isEmpty && element.visibilityModifier() == null) {
|
||||||
text = "Make primary constructor ${modifier.value}" // otherwise it may be confusing
|
text = "Make primary constructor ${modifier.value}" // otherwise it may be confusing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
internal anno<caret>tation class Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
private anno<caret>tation class Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
internal annotation cla<caret>ss Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
private annotation cla<caret>ss Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
anno<caret>tation internal class Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
anno<caret>tation private class Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
annotation internal cla<caret>ss Ann
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
annotation private cla<caret>ss Ann
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
// "Replace '@JvmField' with 'const'" "false"
|
// "Replace '@JvmField' with 'const'" "false"
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// ERROR: JvmField has no effect on a private property
|
// ERROR: JvmField has no effect on a private property
|
||||||
|
// ACTION: Make internal
|
||||||
|
// ACTION: Make protected
|
||||||
|
// ACTION: Make public
|
||||||
// ACTION: Move to constructor
|
// ACTION: Move to constructor
|
||||||
// ACTION: Specify type explicitly
|
// ACTION: Specify type explicitly
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// "Replace '@JvmField' with 'const'" "false"
|
// "Replace '@JvmField' with 'const'" "false"
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// ERROR: JvmField has no effect on a private property
|
// ERROR: JvmField has no effect on a private property
|
||||||
|
// ACTION: Make internal
|
||||||
|
// ACTION: Make public
|
||||||
// ACTION: Remove explicit type specification
|
// ACTION: Remove explicit type specification
|
||||||
fun getText() = ""
|
fun getText() = ""
|
||||||
<caret>@JvmField private val text: String = getText()
|
<caret>@JvmField private val text: String = getText()
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
// "Replace '@JvmField' with 'const'" "false"
|
// "Replace '@JvmField' with 'const'" "false"
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// ERROR: JvmField has no effect on a private property
|
// ERROR: JvmField has no effect on a private property
|
||||||
|
// ACTION: Make internal
|
||||||
|
// ACTION: Make public
|
||||||
// ACTION: Remove explicit type specification
|
// ACTION: Remove explicit type specification
|
||||||
<caret>@JvmField private val number: Int? = 42
|
<caret>@JvmField private val number: Int? = 42
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// ERROR: JvmField has no effect on a private property
|
// ERROR: JvmField has no effect on a private property
|
||||||
// ACTION: Add 'const' modifier
|
// ACTION: Add 'const' modifier
|
||||||
|
// ACTION: Make internal
|
||||||
|
// ACTION: Make public
|
||||||
// ACTION: Specify type explicitly
|
// ACTION: Specify type explicitly
|
||||||
val three = 3
|
val three = 3
|
||||||
<caret>@JvmField private val text = "${2 + three}"
|
<caret>@JvmField private val text = "${2 + three}"
|
||||||
@@ -2974,6 +2974,30 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/changeVisibility/private"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/changeVisibility/private"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasModifier1.kt")
|
||||||
|
public void testHasModifier1() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/hasModifier1.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasModifier2.kt")
|
||||||
|
public void testHasModifier2() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/hasModifier2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasModifier3.kt")
|
||||||
|
public void testHasModifier3() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/hasModifier3.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("hasModifier4.kt")
|
||||||
|
public void testHasModifier4() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/hasModifier4.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("noModifierListAnnotation.kt")
|
@TestMetadata("noModifierListAnnotation.kt")
|
||||||
public void testNoModifierListAnnotation() throws Exception {
|
public void testNoModifierListAnnotation() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/noModifierListAnnotation.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/noModifierListAnnotation.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user