Extract Function: Support extraction of expressions in delegation
specifiers
This commit is contained in:
+4
-2
@@ -65,6 +65,7 @@ import org.jetbrains.jet.lang.cfg.pseudocodeTraverser.TraversalOrder
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getTargetFunctionDescriptor
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
private val DEFAULT_FUNCTION_NAME = "myFun"
|
||||
@@ -541,7 +542,7 @@ fun ExtractionData.performAnalysis(): AnalysisResult {
|
||||
|
||||
val noContainerError = AnalysisResult(null, Status.CRITICAL_ERROR, listOf(ErrorMessage.NO_CONTAINER))
|
||||
|
||||
val commonParent = PsiTreeUtil.findCommonParent(originalElements)!!
|
||||
val commonParent = PsiTreeUtil.findCommonParent(originalElements) as JetElement
|
||||
|
||||
val enclosingDeclaration = commonParent.getParentByType(javaClass<JetDeclaration>(), true)
|
||||
val bodyElement = when (enclosingDeclaration) {
|
||||
@@ -550,7 +551,8 @@ fun ExtractionData.performAnalysis(): AnalysisResult {
|
||||
is JetParameter -> enclosingDeclaration.getDefaultValue()
|
||||
is JetClassInitializer -> enclosingDeclaration.getBody()
|
||||
is JetClass -> {
|
||||
if (commonParent.isInsideOf(enclosingDeclaration.getDelegationSpecifiers())) enclosingDeclaration else return noContainerError
|
||||
val delegationSpecifierList = enclosingDeclaration.getDelegationSpecifierList()
|
||||
if (delegationSpecifierList.isAncestor(commonParent)) commonParent else return noContainerError
|
||||
}
|
||||
else -> return noContainerError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user