Fix KNE in intentions
EA-124846 Fixed
This commit is contained in:
@@ -79,10 +79,10 @@ fun getLambdaByImplicitItReference(expression: KtNameReferenceExpression) =
|
|||||||
resolveToAutoCreatedItDescriptor(expression)?.containingDeclaration?.source?.getPsi() as? KtFunctionLiteral
|
resolveToAutoCreatedItDescriptor(expression)?.containingDeclaration?.source?.getPsi() as? KtFunctionLiteral
|
||||||
|
|
||||||
// returns assignment which replaces initializer
|
// returns assignment which replaces initializer
|
||||||
fun splitPropertyDeclaration(property: KtProperty): KtBinaryExpression {
|
fun splitPropertyDeclaration(property: KtProperty): KtBinaryExpression? {
|
||||||
val parent = property.parent
|
val parent = property.parent
|
||||||
|
|
||||||
val initializer = property.initializer!!
|
val initializer = property.initializer ?: return null
|
||||||
|
|
||||||
val explicitTypeToSet = if (property.typeReference != null) null else initializer.analyze().getType(initializer)
|
val explicitTypeToSet = if (property.typeReference != null) null else initializer.analyze().getType(initializer)
|
||||||
|
|
||||||
|
|||||||
+1
@@ -36,6 +36,7 @@ class UnfoldPropertyToIfIntention : SelfTargetingRangeIntention<KtProperty>(KtPr
|
|||||||
|
|
||||||
override fun applyTo(element: KtProperty, editor: Editor?) {
|
override fun applyTo(element: KtProperty, editor: Editor?) {
|
||||||
val assignment = splitPropertyDeclaration(element)
|
val assignment = splitPropertyDeclaration(element)
|
||||||
|
?: return // if element initializer is null the apply should not be invoked. If suddenly invoked splitPropertyDeclaration will return null
|
||||||
BranchedUnfoldingUtils.unfoldAssignmentToIf(assignment, editor)
|
BranchedUnfoldingUtils.unfoldAssignmentToIf(assignment, editor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -38,7 +38,7 @@ class UnfoldPropertyToWhenIntention : SelfTargetingRangeIntention<KtProperty>(Kt
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun applyTo(element: KtProperty, editor: Editor?) {
|
override fun applyTo(element: KtProperty, editor: Editor?) {
|
||||||
val assignment = splitPropertyDeclaration(element)
|
val assignment = splitPropertyDeclaration(element) ?: return
|
||||||
BranchedUnfoldingUtils.unfoldAssignmentToWhen(assignment, editor)
|
BranchedUnfoldingUtils.unfoldAssignmentToWhen(assignment, editor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user