Skip to content

Commit

Permalink
Merge 790066b into bb1227a
Browse files Browse the repository at this point in the history
  • Loading branch information
kentr0w authored Nov 16, 2020
2 parents bb1227a + 790066b commit 3adc912
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class BlockStructureBraces(private val configRules: List<RulesConfig>) : Rule("b
if (braceSpace == null || braceSpace.elementType != WHITE_SPACE) {
node.addChild(PsiWhiteSpaceImpl(" "), nodeBefore)
} else {
(braceSpace as LeafPsiElement).replaceWithText(" ")
braceSpace.treeParent.replaceWhiteSpaceText(braceSpace, " ")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ fun ASTNode.isCorrect(): Boolean = this.findAllNodesWithSpecificType(TokenType.E
fun ASTNode.getAllChildrenWithType(elementType: IElementType): List<ASTNode> =
this.getChildren(null).filter { it.elementType == elementType }

fun ASTNode.replaceWhiteSpaceText(beforeNode: ASTNode, text: String) {
require(beforeNode.elementType == WHITE_SPACE)
this.addChild(PsiWhiteSpaceImpl(text), beforeNode)
this.removeChild(beforeNode)
}

/**
* obviously returns first child that match particular element type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,23 @@ fun mains() {
httpClient.doRequest()
}

class Example {
fun foo() {
if (condition1) {
if (condition2) {
bar()
}
}

if (condition3) {
if (condition4) {
foo()
} else {
bar()
}
} else {
foo()
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ fun mains() {
timeout = 100
}
httpClient.doRequest()
}
}

class Example {
fun foo() {
if (condition1)
if (condition2)
bar()

if (condition3)
if (condition4)
foo()
else
bar()
else
foo()
}
}

0 comments on commit 3adc912

Please sign in to comment.