Disable "Make constructor private" for annotations #KT-17600 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c8c3d24b45
commit
d542aef7e4
@@ -102,10 +102,13 @@ open class ChangeVisibilityModifierIntention protected constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected fun isAnnotationClassPrimaryConstructor(element: KtDeclaration) = element is KtPrimaryConstructor && (element.parent as? KtClass)?.hasModifier(KtTokens.ANNOTATION_KEYWORD) ?: false
|
||||||
|
|
||||||
class Public : ChangeVisibilityModifierIntention(KtTokens.PUBLIC_KEYWORD), HighPriorityAction
|
class Public : ChangeVisibilityModifierIntention(KtTokens.PUBLIC_KEYWORD), HighPriorityAction
|
||||||
|
|
||||||
class Private : ChangeVisibilityModifierIntention(KtTokens.PRIVATE_KEYWORD), HighPriorityAction {
|
class Private : ChangeVisibilityModifierIntention(KtTokens.PRIVATE_KEYWORD), HighPriorityAction {
|
||||||
override fun applicabilityRange(element: KtDeclaration): TextRange? {
|
override fun applicabilityRange(element: KtDeclaration): TextRange? {
|
||||||
|
if (isAnnotationClassPrimaryConstructor(element)) return null
|
||||||
return if (element.canBePrivate()) super.applicabilityRange(element) else null
|
return if (element.canBePrivate()) super.applicabilityRange(element) else null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
annotation class C<caret>(val v: Int)
|
||||||
@@ -2934,6 +2934,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("notForAnnotationClassPrimaryConstructor.kt")
|
||||||
|
public void testNotForAnnotationClassPrimaryConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForAnnotationClassPrimaryConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("notForLocal.kt")
|
@TestMetadata("notForLocal.kt")
|
||||||
public void testNotForLocal() throws Exception {
|
public void testNotForLocal() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForLocal.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForLocal.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user