J2K: refactoring - AccessorBodyToExpression processing can be expressed as intention-based

This commit is contained in:
Valentin Kipyatkov
2016-03-02 19:39:58 +03:00
parent 05dc4c1c48
commit 7ba39bd8cf
@@ -54,8 +54,8 @@ object J2KPostProcessingRegistrar {
_processings.add(ConvertToStringTemplateProcessing())
_processings.add(UsePropertyAccessSyntaxProcessing())
_processings.add(RemoveRedundantSamAdaptersProcessing())
_processings.add(AccessorBodyToExpression())
registerIntentionBasedProcessing(ConvertToExpressionBodyIntention()) { it is KtPropertyAccessor }
registerIntentionBasedProcessing(IfThenToSafeAccessIntention())
registerIntentionBasedProcessing(IfThenToElvisIntention())
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) }
}
}
}