Debugger: Add breakpoint applicability tests

This commit adds a number of tests that check breakpoint placing behavior, and an inline action that work the same way as tests.
This commit is contained in:
Yan Zhulanow
2019-07-16 17:05:37 +09:00
parent a8d08815a6
commit 25fb77e7ad
19 changed files with 436 additions and 17 deletions
@@ -12,12 +12,16 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.startOffset
fun PsiFile.getLineStartOffset(line: Int): Int? {
return getLineStartOffset(line, skipWhitespace = true)
}
fun PsiFile.getLineStartOffset(line: Int, skipWhitespace: Boolean): Int? {
val doc = viewProvider.document ?: PsiDocumentManager.getInstance(project).getDocument(this)
if (doc != null && line >= 0 && line < doc.lineCount) {
val startOffset = doc.getLineStartOffset(line)
val element = findElementAt(startOffset) ?: return startOffset
if (element is PsiWhiteSpace || element is PsiComment) {
if (skipWhitespace && (element is PsiWhiteSpace || element is PsiComment)) {
return PsiTreeUtil.skipSiblingsForward(element, PsiWhiteSpace::class.java, PsiComment::class.java)?.startOffset ?: startOffset
}
return startOffset