Debugger: get topmost element at offset as contextElement

This commit is contained in:
Natalia Ukhorskaya
2015-08-25 13:24:24 +03:00
parent c6d29cc1d5
commit 06b13f1292
4 changed files with 43 additions and 7 deletions
@@ -70,8 +70,13 @@ public class CodeFragmentAnalyzer(
is JetDeclarationWithBody -> this.getBodyExpression()
is JetBlockExpression -> this.getStatements().lastOrNull()
else -> {
this.siblings(forward = false, withItself = false).firstIsInstanceOrNull<JetExpression>()
?: this.parents.firstIsInstanceOrNull<JetExpression>()
val previousSibling = this.siblings(forward = false, withItself = false).firstIsInstanceOrNull<JetExpression>()
if (previousSibling != null) return previousSibling
for (parent in this.parents) {
if (parent is JetWhenEntry || parent is JetIfExpression || parent is JetBlockExpression) return this
if (parent is JetExpression) return parent
}
null
}
} ?: this
}