Disable "Make constructor private" for annotations #KT-17600 Fixed

This commit is contained in:
shiraji
2017-04-28 05:16:25 +03:00
committed by Mikhail Glukhikh
parent c8c3d24b45
commit d542aef7e4
3 changed files with 11 additions and 0 deletions
@@ -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 Private : ChangeVisibilityModifierIntention(KtTokens.PRIVATE_KEYWORD), HighPriorityAction {
override fun applicabilityRange(element: KtDeclaration): TextRange? {
if (isAnnotationClassPrimaryConstructor(element)) return null
return if (element.canBePrivate()) super.applicabilityRange(element) else null
}
}
@@ -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);
}
@TestMetadata("notForAnnotationClassPrimaryConstructor.kt")
public void testNotForAnnotationClassPrimaryConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForAnnotationClassPrimaryConstructor.kt");
doTest(fileName);
}
@TestMetadata("notForLocal.kt")
public void testNotForLocal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/changeVisibility/private/notForLocal.kt");