diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/AddOperatorModifierIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/AddOperatorModifierIntention.kt index 961c3fa5dc4..223f419d2d1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/AddOperatorModifierIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/AddOperatorModifierIntention.kt @@ -20,7 +20,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny -import org.jetbrains.kotlin.idea.refactoring.withHeaderImplementations +import org.jetbrains.kotlin.idea.refactoring.withExpectedActuals import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.util.OperatorChecks @@ -34,7 +34,7 @@ class AddOperatorModifierIntention : SelfTargetingRangeIntention( override fun applyTo(element: KtParameter, editor: Editor?) { val function = element.getStrictParentOfType() ?: return val parameterIndex = function.valueParameters.indexOf(element) - val descriptor = function.resolveToHeaderDescriptorIfPossible() as? FunctionDescriptor ?: return + val descriptor = function.resolveToExpectedDescriptorIfPossible() as? FunctionDescriptor ?: return runChangeSignature(element.project, descriptor, configureChangeSignature(parameterIndex), element, text) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt index ca5262c8ab4..47769a004bb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertReceiverToParameterIntention.kt @@ -28,7 +28,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.core.getOrCreateValueParameterList import org.jetbrains.kotlin.idea.refactoring.changeSignature.* -import org.jetbrains.kotlin.idea.refactoring.resolveToHeaderDescriptorIfPossible +import org.jetbrains.kotlin.idea.refactoring.resolveToExpectedDescriptorIfPossible import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.psi.KtNamedFunction @@ -61,7 +61,7 @@ class ConvertReceiverToParameterIntention : SelfTargetingOffsetIndependentIntent override fun applyTo(element: KtTypeReference, editor: Editor?) { val function = element.parent as? KtNamedFunction ?: return - val descriptor = function.resolveToHeaderDescriptorIfPossible() as FunctionDescriptor + val descriptor = function.resolveToExpectedDescriptorIfPossible() as FunctionDescriptor val project = function.project @@ -102,7 +102,7 @@ class ConvertReceiverToParameterIntention : SelfTargetingOffsetIndependentIntent if (!brokenOff) { runChangeSignature( element.project, - function.resolveToHeaderDescriptorIfPossible() as FunctionDescriptor, + function.resolveToExpectedDescriptorIfPossible() as FunctionDescriptor, configureChangeSignature(newName), function.receiverTypeReference!!, text diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt index 5bc63d59c40..0c876e79161 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/declarations/ConvertMemberToExtensionIntention.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.idea.highlighter.markers.isExpectedOrExpectedClassMe import org.jetbrains.kotlin.idea.highlighter.markers.liftToExpected import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getReturnTypeReference -import org.jetbrains.kotlin.idea.refactoring.withHeaderImplementations +import org.jetbrains.kotlin.idea.refactoring.withExpectedActuals import org.jetbrains.kotlin.idea.references.KtReference import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.idea.util.application.runWriteAction @@ -61,7 +61,7 @@ class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention { val descriptor = element.unsafeResolveToDescriptor() val containingClass = descriptor.containingDeclaration as ClassDescriptor - val isEffectiveHeader = allowHeader && element.isExpectedOrExpectedClassMember() + val isEffectivelyExpected = allowExpected && element.isExpectedOrExpectedClassMember() val file = element.containingKtFile val project = file.project @@ -157,8 +157,9 @@ class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention { - if (!extension.hasBody() && !isEffectiveHeader) { + if (!extension.hasBody() && !isEffectivelyExpected) { //TODO: methods in PSI for setBody extension.add(psiFactory.createBlock(bodyText)) selectBody(extension) @@ -189,7 +190,7 @@ class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention { val templateProperty = psiFactory.createDeclaration("var v: Any\nget()=$bodyText\nset(value){\n$bodyText\n}") - if (!isEffectiveHeader) { + if (!isEffectivelyExpected) { val templateGetter = templateProperty.getter!! val templateSetter = templateProperty.setter!! @@ -244,13 +245,13 @@ class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention { - val headerDeclaration = element.liftToExpected() as? KtCallableDeclaration - if (headerDeclaration != null) { - element.withHeaderImplementations().filterIsInstance().forEach { + val expectedDeclaration = element.liftToExpected() as? KtCallableDeclaration + if (expectedDeclaration != null) { + element.withExpectedActuals().filterIsInstance().forEach { if (it != element) { - processSingleDeclaration(it, allowHeader) + processSingleDeclaration(it, allowExpected) } } } - return processSingleDeclaration(element, allowHeader) + return processSingleDeclaration(element, allowExpected) } private fun newTypeParameterList(member: KtCallableDeclaration): KtTypeParameterList? { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt index 20213146455..a8bbc9df464 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/kotlinRefactoringUtil.kt @@ -967,13 +967,13 @@ fun KtNamedDeclaration.isCompanionMemberOf(klass: KtClassOrObject): Boolean { return containingObject.isCompanion() && containingObject.containingClassOrObject == klass } -internal fun KtDeclaration.withHeaderImplementations(): List { +internal fun KtDeclaration.withExpectedActuals(): List { val header = liftToExpected() ?: return listOf(this) val implementations = header.actualsForExpected() return listOf(header) + implementations } -internal fun KtDeclaration.resolveToHeaderDescriptorIfPossible(): DeclarationDescriptor { +internal fun KtDeclaration.resolveToExpectedDescriptorIfPossible(): DeclarationDescriptor { val descriptor = unsafeResolveToDescriptor() return descriptor.liftToExpected() ?: descriptor } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt index 4025291e0df..95889573da7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/safeDelete/KotlinSafeDeleteProcessor.kt @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.idea.highlighter.markers.liftToExpected import org.jetbrains.kotlin.idea.refactoring.checkSuperMethods import org.jetbrains.kotlin.idea.refactoring.formatClass import org.jetbrains.kotlin.idea.refactoring.formatFunction -import org.jetbrains.kotlin.idea.refactoring.withHeaderImplementations +import org.jetbrains.kotlin.idea.refactoring.withExpectedActuals import org.jetbrains.kotlin.idea.references.KtReference import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchOptions import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchParameters @@ -86,7 +86,7 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() { fun getSearchInfo(element: PsiElement) = NonCodeUsageSearchInfo(getIgnoranceCondition(), element) fun searchKotlinDeclarationReferences(declaration: KtDeclaration): Sequence { - val elementsToSearch = if (declaration is KtParameter) declaration.withHeaderImplementations() else listOf(declaration) + val elementsToSearch = if (declaration is KtParameter) declaration.withExpectedActuals() else listOf(declaration) return elementsToSearch.asSequence().flatMap { val searchParameters = KotlinReferencesSearchParameters( it,