Skip to content

Commit

Permalink
Fixed node removal
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Jul 24, 2017
1 parent a120164 commit e538e53
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class NoSemicolonsRule : Rule("no-semi") {
) {
emit(node.startOffset, "Unnecessary semicolon", true)
if (autoCorrect) {
node.delete()
node.treeParent.removeChild(node)
}
} else if (nextLeaf !is PsiWhiteSpace) {
// todo: move to a separate rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SpacingAroundCurlyRule : Rule("curly-spacing") {
shouldNotToBeSeparatedBySpace(PsiTreeUtil.nextLeaf(nextLeaf, true))) {
emit(node.startOffset, "Unexpected space after \"${node.text}\"", true)
if (autoCorrect) {
nextLeaf.delete()
nextLeaf.node.treeParent.removeChild(nextLeaf.node)
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class SpacingAroundKeywordRule : Rule("keyword-spacing") {
}
} else if (keywordsWithoutSpaces.contains(node.elementType) && node.nextLeaf() is PsiWhiteSpace) {
val parent = node.parent
if (parent is KtPropertyAccessor && parent.hasBody()) {
val nextLeaf = node.nextLeaf()
if (parent is KtPropertyAccessor && parent.hasBody() && nextLeaf != null) {
emit(node.startOffset, "Unexpected spacing after \"${node.text}\"", true)
if (autoCorrect) {
node.nextLeaf()?.delete()
nextLeaf.node.treeParent.removeChild(nextLeaf.node)
}
}
}
Expand Down

0 comments on commit e538e53

Please sign in to comment.