J2K: refactoring - AccessorBodyToExpression processing can be expressed as intention-based
This commit is contained in:
@@ -54,8 +54,8 @@ object J2KPostProcessingRegistrar {
|
|||||||
_processings.add(ConvertToStringTemplateProcessing())
|
_processings.add(ConvertToStringTemplateProcessing())
|
||||||
_processings.add(UsePropertyAccessSyntaxProcessing())
|
_processings.add(UsePropertyAccessSyntaxProcessing())
|
||||||
_processings.add(RemoveRedundantSamAdaptersProcessing())
|
_processings.add(RemoveRedundantSamAdaptersProcessing())
|
||||||
_processings.add(AccessorBodyToExpression())
|
|
||||||
|
|
||||||
|
registerIntentionBasedProcessing(ConvertToExpressionBodyIntention()) { it is KtPropertyAccessor }
|
||||||
registerIntentionBasedProcessing(IfThenToSafeAccessIntention())
|
registerIntentionBasedProcessing(IfThenToSafeAccessIntention())
|
||||||
registerIntentionBasedProcessing(IfThenToElvisIntention())
|
registerIntentionBasedProcessing(IfThenToElvisIntention())
|
||||||
registerIntentionBasedProcessing(IfNullToElvisIntention())
|
registerIntentionBasedProcessing(IfNullToElvisIntention())
|
||||||
@@ -210,14 +210,4 @@ object J2KPostProcessingRegistrar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AccessorBodyToExpression : J2kPostProcessing {
|
|
||||||
private val intention = ConvertToExpressionBodyIntention()
|
|
||||||
|
|
||||||
override fun createAction(element: KtElement, diagnostics: Diagnostics): (() -> Unit)? {
|
|
||||||
if (element !is KtPropertyAccessor) return null
|
|
||||||
if (!intention.isApplicableTo(element)) return null
|
|
||||||
return { intention.applyTo(element, true) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user