diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt rename to idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/ktRefactoringUtil.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/ktRefactoringUtil.kt new file mode 100644 index 00000000000..924afd41e8b --- /dev/null +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/ktRefactoringUtil.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring + +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import org.jetbrains.kotlin.psi.psiUtil.isAncestor +import org.jetbrains.kotlin.resolve.BindingContext + +fun KtElement.getContextForContainingDeclarationBody(): BindingContext? { + val enclosingDeclaration = getStrictParentOfType() + val bodyElement = when (enclosingDeclaration) { + is KtDeclarationWithBody -> enclosingDeclaration.getBodyExpression() + is KtWithExpressionInitializer -> enclosingDeclaration.getInitializer() + is KtDestructuringDeclaration -> enclosingDeclaration.getInitializer() + is KtParameter -> enclosingDeclaration.getDefaultValue() + is KtAnonymousInitializer -> enclosingDeclaration.body + is KtClass -> { + val delegationSpecifierList = enclosingDeclaration.getSuperTypeList() + if (delegationSpecifierList.isAncestor(this)) this else null + } + else -> null + } + return bodyElement?.let { it.analyze() } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt rename to idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiRange.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt rename to idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index d68abcd5fb5..d251daaf146 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -324,23 +324,6 @@ fun PsiElement.getLineCount(): Int { fun PsiElement.isMultiLine(): Boolean = getLineCount() > 1 -fun KtElement.getContextForContainingDeclarationBody(): BindingContext? { - val enclosingDeclaration = getStrictParentOfType() - val bodyElement = when (enclosingDeclaration) { - is KtDeclarationWithBody -> enclosingDeclaration.bodyExpression - is KtWithExpressionInitializer -> enclosingDeclaration.initializer - is KtDestructuringDeclaration -> enclosingDeclaration.initializer - is KtParameter -> enclosingDeclaration.defaultValue - is KtAnonymousInitializer -> enclosingDeclaration.body - is KtClass -> { - val delegationSpecifierList = enclosingDeclaration.getSuperTypeList() - if (delegationSpecifierList.isAncestor(this)) this else null - } - else -> null - } - return bodyElement?.let { it.analyze() } -} - fun chooseContainerElement( containers: List, editor: Editor,