diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddAccessorIntentions.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddAccessorIntentions.kt index 44bf5c97b10..292c5a8dcad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddAccessorIntentions.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddAccessorIntentions.kt @@ -19,6 +19,8 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.codeInsight.intention.LowPriorityAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.refactoring.isAbstract import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtProperty @@ -32,10 +34,12 @@ abstract class AbstractAddAccessorsIntention( override fun applicabilityRange(element: KtProperty): TextRange? { if (element.isLocal || element.isAbstract() || element.hasDelegate() || element.hasModifier(KtTokens.LATEINIT_KEYWORD) || - element.hasModifier(KtTokens.HEADER_KEYWORD) || element.hasModifier(KtTokens.CONST_KEYWORD)) { return null } + val descriptor = element.resolveToDescriptorIfAny() as? CallableMemberDescriptor ?: return null + if (descriptor.isHeader) return null + if (addSetter && (!element.isVar || element.setter != null)) return null if (addGetter && element.getter != null) return null return element.nameIdentifier?.textRange diff --git a/idea/testData/intentions/addPropertyAccessors/getter/header.kt b/idea/testData/intentions/addPropertyAccessors/getter/header.kt new file mode 100644 index 00000000000..eb25bf4557d --- /dev/null +++ b/idea/testData/intentions/addPropertyAccessors/getter/header.kt @@ -0,0 +1,6 @@ +// SKIP_ERRORS_BEFORE +// SKIP_ERRORS_AFTER +// IS_APPLICABLE: false +header class Header { + val x: Int +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 244c7613fce..fd087d9ce5a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -853,6 +853,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("header.kt") + public void testHeader() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/header.kt"); + doTest(fileName); + } + @TestMetadata("lateinit.kt") public void testLateinit() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addPropertyAccessors/getter/lateinit.kt");