Extract Function: Extract smart-cast value as parameter
#KT-7576 Fixed
This commit is contained in:
@@ -191,13 +191,9 @@ public fun JetElement.getContainingPseudocode(context: BindingContext): Pseudoco
|
||||
?: getNonStrictParentOfType<JetProperty>()
|
||||
?: return null
|
||||
|
||||
val enclosingPseudocodeDeclaration = if (pseudocodeDeclaration is JetFunctionLiteral) {
|
||||
parents(withItself = false).firstOrNull { it is JetDeclaration && it !is JetFunctionLiteral } as? JetDeclaration
|
||||
?: pseudocodeDeclaration
|
||||
}
|
||||
else {
|
||||
pseudocodeDeclaration
|
||||
}
|
||||
val enclosingPseudocodeDeclaration = (pseudocodeDeclaration as? JetFunctionLiteral)?.let {
|
||||
it.parents(withItself = false).firstOrNull { it is JetDeclaration && it !is JetFunctionLiteral } as? JetDeclaration
|
||||
} ?: pseudocodeDeclaration
|
||||
|
||||
val enclosingPseudocode = PseudocodeUtil.generatePseudocode(enclosingPseudocodeDeclaration, context)
|
||||
return enclosingPseudocode.getPseudocodeByElement(pseudocodeDeclaration)
|
||||
|
||||
@@ -667,3 +667,12 @@ public fun JetExpression.getAnnotationEntries(): List<JetAnnotationEntry> {
|
||||
else -> emptyList<JetAnnotationEntry>()
|
||||
}
|
||||
}
|
||||
|
||||
public fun JetElement.getQualifiedExpressionForSelector(): JetQualifiedExpression? {
|
||||
val parent = getParent()
|
||||
return if (parent is JetQualifiedExpression && parent.getSelectorExpression() == this) parent else null
|
||||
}
|
||||
|
||||
public fun JetElement.getQualifiedExpressionForSelectorOrThis(): JetElement {
|
||||
return getQualifiedExpressionForSelector() ?: this
|
||||
}
|
||||
Reference in New Issue
Block a user