"Convert property initializer to getter" intention: don't suggest if property has @JvmField annotation #KT-27139 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
3866c85a34
commit
ca335880eb
+2
-1
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||
import org.jetbrains.kotlin.idea.util.hasJvmFieldAnnotation
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
@@ -32,7 +33,7 @@ class ConvertPropertyInitializerToGetterIntention : SelfTargetingRangeIntention<
|
||||
|
||||
override fun applicabilityRange(element: KtProperty): TextRange? {
|
||||
val initializer = element.initializer
|
||||
return if (initializer != null && element.getter == null && !element.isExtensionDeclaration() && !element.isLocal)
|
||||
return if (initializer != null && element.getter == null && !element.isExtensionDeclaration() && !element.isLocal && !element.hasJvmFieldAnnotation())
|
||||
initializer.textRange
|
||||
else
|
||||
null
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
class Test {
|
||||
@JvmField
|
||||
val foo = <caret>1
|
||||
}
|
||||
@@ -6046,6 +6046,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
runTest("idea/testData/intentions/convertPropertyInitializerToGetter/inapplicableIfNoInitializer.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmField.kt")
|
||||
public void testJvmField() throws Exception {
|
||||
runTest("idea/testData/intentions/convertPropertyInitializerToGetter/jvmField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notInLambda.kt")
|
||||
public void testNotInLambda() throws Exception {
|
||||
runTest("idea/testData/intentions/convertPropertyInitializerToGetter/notInLambda.kt");
|
||||
|
||||
Reference in New Issue
Block a user