Implement option for wrapping assignment statements

#KT-21718 Fixed
This commit is contained in:
Dmitry Jemerov
2017-12-08 14:07:21 +01:00
parent 947833cad6
commit ab99bf843a
5 changed files with 53 additions and 5 deletions
@@ -415,10 +415,32 @@ abstract class KotlinCommonBlock(
}
nodePsi is KtProperty ->
return wrapAfterAnnotation(if (nodePsi.isLocal)
commonSettings.VARIABLE_ANNOTATION_WRAP
else
commonSettings.FIELD_ANNOTATION_WRAP)
return object : WrappingStrategy {
override fun getWrap(childElement: ASTNode): Wrap? {
val wrapSetting = if (nodePsi.isLocal) commonSettings.VARIABLE_ANNOTATION_WRAP else commonSettings.FIELD_ANNOTATION_WRAP
getWrapAfterAnnotation(childElement, wrapSetting)?.let {
return it
}
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == KtTokens.EQ) {
return Wrap.createWrap(settings.kotlinCommonSettings.ASSIGNMENT_WRAP, true)
}
return null
}
}
nodePsi is KtBinaryExpression -> {
if (nodePsi.operationToken == KtTokens.EQ) {
return object : WrappingStrategy {
override fun getWrap(childElement: ASTNode): Wrap? {
if (getPrevWithoutWhitespaceAndComments(childElement)?.elementType == KtNodeTypes.OPERATION_REFERENCE) {
return Wrap.createWrap(settings.kotlinCommonSettings.ASSIGNMENT_WRAP, true)
}
return null
}
}
}
return WrappingStrategy.NoWrapping
}
}
return WrappingStrategy.NoWrapping