indent assignment statement expressions properly

This commit is contained in:
FalsePattern 2024-10-29 16:21:33 +01:00
parent 19b0b09826
commit 4e1022d726
Signed by: falsepattern
GPG key ID: E930CDEC50C50E23

View file

@ -107,16 +107,32 @@ private fun getIndentBasedOnParentType(
if (parentType == ASM_EXPR &&
childType != KEYWORD_ASM &&
childType != KEYWORD_VOLATILE &&
!childType.isParen)
!childType.isParen
)
return normalIndent
//Assembly params
if (parentType == ASM_INPUT_LIST || parentType == ASM_OUTPUT_LIST)
return spaceIndent(2)
//Variable declarations
if (parentType == VAR_DECL_EXPR_STATEMENT &&
(childType == PLACEHOLDER ||
child?.treePrevNonSpace?.elementType == EQUAL)
)
return normalIndent
return noneIndent
}
private val ASTNode.treePrevNonSpace: ASTNode? get() {
var it = this.treePrev
while (it?.elementType == TokenType.WHITE_SPACE) {
it = it.treePrev
}
return it
}
private val normalIndent: Indent get() = Indent.getNormalIndent()
private fun spaceIndent(spaces: Int) = Indent.getSpaceIndent(2)