Minor: extract function
This commit is contained in:
+13
-9
@@ -99,7 +99,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
|
|||||||
val result = arrayListOf<PsiElement>()
|
val result = arrayListOf<PsiElement>()
|
||||||
val ifParent = getParentOfType<JetIfExpression>(false)
|
val ifParent = getParentOfType<JetIfExpression>(false)
|
||||||
if (ifParent != null) {
|
if (ifParent != null) {
|
||||||
if (ifParent.then?.textRange?.contains(this.textRange) ?: false) {
|
if (ifParent.then.contains(this)) {
|
||||||
ifParent.elseKeyword?.let { result.add(it) }
|
ifParent.elseKeyword?.let { result.add(it) }
|
||||||
ifParent.`else`?.let { result.add(it) }
|
ifParent.`else`?.let { result.add(it) }
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
|
|||||||
|
|
||||||
val whenEntry = getParentOfType<JetWhenEntry>(false)
|
val whenEntry = getParentOfType<JetWhenEntry>(false)
|
||||||
if (whenEntry != null) {
|
if (whenEntry != null) {
|
||||||
if (whenEntry.expression?.textRange?.contains(this.textRange) ?: false) {
|
if (whenEntry.expression.contains(this)) {
|
||||||
val whenParent = whenEntry.getParentOfType<JetWhenExpression>(false)
|
val whenParent = whenEntry.getParentOfType<JetWhenExpression>(false)
|
||||||
if (whenParent != null) {
|
if (whenParent != null) {
|
||||||
result.addAll(whenParent.entries.filter { it != whenEntry })
|
result.addAll(whenParent.entries.filter { it != whenEntry })
|
||||||
@@ -129,7 +129,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
|
|||||||
val ifParent = getParentOfType<JetIfExpression>(false)
|
val ifParent = getParentOfType<JetIfExpression>(false)
|
||||||
if (ifParent != null) {
|
if (ifParent != null) {
|
||||||
// if (inlineFunCall()) {...}
|
// if (inlineFunCall()) {...}
|
||||||
if (ifParent.condition?.textRange?.contains(this.textRange) ?: false) {
|
if (ifParent.condition.contains(this)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,10 +139,10 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
|
|||||||
*/
|
*/
|
||||||
val ifParentElementAt = elementAt.getParentOfType<JetIfExpression>(false)
|
val ifParentElementAt = elementAt.getParentOfType<JetIfExpression>(false)
|
||||||
if (ifParentElementAt == null) {
|
if (ifParentElementAt == null) {
|
||||||
if (ifParent.then?.textRange?.contains(this.textRange) ?: false) {
|
if (ifParent.then.contains(this)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (ifParent.`else`?.textRange?.contains(this.textRange) ?: false) {
|
if (ifParent.`else`.contains(this)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
|
|||||||
/* try { inlineFunCall() }
|
/* try { inlineFunCall() }
|
||||||
catch()...
|
catch()...
|
||||||
*/
|
*/
|
||||||
if (tryParent.tryBlock.textRange?.contains(this.textRange) ?: false) {
|
if (tryParent.tryBlock.contains(this)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,21 +161,25 @@ public class KotlinSteppingCommandProvider: JvmSteppingCommandProvider() {
|
|||||||
val whenEntry = getParentOfType<JetWhenEntry>(false)
|
val whenEntry = getParentOfType<JetWhenEntry>(false)
|
||||||
if (whenEntry != null) {
|
if (whenEntry != null) {
|
||||||
// <caret>inlineFunCall -> ...
|
// <caret>inlineFunCall -> ...
|
||||||
if (whenEntry.conditions.any { it.textRange.contains(this.textRange) } ) {
|
if (whenEntry.conditions.any { it.contains(this) } ) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// <caret>1 == 2 -> inlineFunCall()
|
// <caret>1 == 2 -> inlineFunCall()
|
||||||
if (whenEntry.expression?.textRange?.contains(this.textRange) ?: false) {
|
if (whenEntry.expression.contains(this)) {
|
||||||
val parentEntryElementAt = elementAt.getParentOfType<JetWhenEntry>(false) ?: return true
|
val parentEntryElementAt = elementAt.getParentOfType<JetWhenEntry>(false) ?: return true
|
||||||
return parentEntryElementAt == whenEntry &&
|
return parentEntryElementAt == whenEntry &&
|
||||||
whenEntry.conditions.any { it.textRange.contains(elementAt.textRange) }
|
whenEntry.conditions.any { it.contains(elementAt) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun PsiElement?.contains(element: PsiElement): Boolean {
|
||||||
|
return this?.textRange?.contains(element.textRange) ?: false
|
||||||
|
}
|
||||||
|
|
||||||
override fun getStepOutCommand(suspendContext: SuspendContextImpl?, stepSize: Int): DebugProcessImpl.ResumeCommand? {
|
override fun getStepOutCommand(suspendContext: SuspendContextImpl?, stepSize: Int): DebugProcessImpl.ResumeCommand? {
|
||||||
if (suspendContext == null || suspendContext.isResumed) return null
|
if (suspendContext == null || suspendContext.isResumed) return null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user