Skip to content

Commit

Permalink
bugfix/indentation-of-comments(#553)
Browse files Browse the repository at this point in the history
### What's done:
  * Fixed bugs
  • Loading branch information
aktsay6 committed Nov 24, 2020
1 parent 4ab49e1 commit 45b3b52
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import com.pinterest.ktlint.core.ast.ElementType.ARROW
import com.pinterest.ktlint.core.ast.ElementType.AS_KEYWORD
import com.pinterest.ktlint.core.ast.ElementType.AS_SAFE
import com.pinterest.ktlint.core.ast.ElementType.BINARY_EXPRESSION
import com.pinterest.ktlint.core.ast.ElementType.BLOCK_COMMENT
import com.pinterest.ktlint.core.ast.ElementType.BODY
import com.pinterest.ktlint.core.ast.ElementType.CALL_EXPRESSION
import com.pinterest.ktlint.core.ast.ElementType.COLON
import com.pinterest.ktlint.core.ast.ElementType.DOT
import com.pinterest.ktlint.core.ast.ElementType.ELSE
import com.pinterest.ktlint.core.ast.ElementType.ELVIS
import com.pinterest.ktlint.core.ast.ElementType.EOL_COMMENT
import com.pinterest.ktlint.core.ast.ElementType.EQ
import com.pinterest.ktlint.core.ast.ElementType.IS_EXPRESSION
import com.pinterest.ktlint.core.ast.ElementType.KDOC_END
Expand Down Expand Up @@ -180,7 +182,7 @@ internal class DotCallChecker(config: IndentationConfig) : CustomIndentationChec
nextNode.isDotBeforeCallOrReference() ||
nextNode.elementType == OPERATION_REFERENCE && nextNode.firstChildNode.elementType.let {
it == ELVIS || it == IS_EXPRESSION || it == AS_KEYWORD || it == AS_SAFE
}
} || nextNode.elementType == EOL_COMMENT || nextNode.elementType == BLOCK_COMMENT
}
?.let {
// we need to get indent before the first expression in calls chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ fun `method name incorrect, part 4`() {
}
""".trimIndent()
lintMethod(code, LintError(2, 7, ruleId, "${FUNCTION_NAME_INCORRECT_CASE.warnText()} methODTREE", true))

foo
// we are calling bar
.bar()

bar
/* This is a block comment */
.foo()
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ fun `method name incorrect, part 4`() {
}
""".trimIndent()
lintMethod(code, LintError(2, 7, ruleId, "${FUNCTION_NAME_INCORRECT_CASE.warnText()} methODTREE", true))

foo
// we are calling bar
.bar()

bar
/* This is a block comment */
.foo()
}

0 comments on commit 45b3b52

Please sign in to comment.