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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user