Skip to content

Commit

Permalink
Fixed handling of negative number condition in catch block (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Feb 28, 2018
1 parent 654a982 commit b0be962
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ class ChainWrappingRule : Rule("chain-wrapping") {
prevLeaf.textContains('\n') &&
prevLeaf.prevLeafIgnoringWhitespaceAndComments()?.let { leaf ->
val type = leaf.node.elementType
type == KtTokens.LPAR || type == KtTokens.COMMA || sameLineTokens.contains(type)
type == KtTokens.LPAR ||
type == KtTokens.RPAR ||
type == KtTokens.COMMA ||
type == KtTokens.LBRACE ||
type == KtTokens.ELSE_KEYWORD ||
KtTokens.OPERATIONS.contains(type)
} == false &&
// LeafPsiElement->KtOperationReferenceExpression->KtPrefixExpression->KtWhenConditionWithExpression
node.treeParent?.treeParent?.treeParent?.elementType != KtNodeTypes.WHEN_CONDITION_EXPRESSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,17 @@ fun main() {
/* comment */
-3 == a()
) {}
if (c)
-7
else
-8
try {
fn()
} catch(e: Exception) {
-9
}
var x =
-2 >
(2 + 2)
-3
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,17 @@ fun main() {
/* comment */
-3 == a()
) {}
if (c)
-7
else
-8
try {
fn()
} catch(e: Exception) {
-9
}
var x =
-2 >
(2 + 2)
-3
}

0 comments on commit b0be962

Please sign in to comment.