From bd2ddbafb34f540f24722917bb3d8cd5cd55a218 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 10 Oct 2016 20:29:38 +0300 Subject: [PATCH] Refactoring: call apply method without returning intermediate object (cherry picked from commit a2f7e00) --- .../stepping/DebuggerSteppingHelper.java | 16 ++-------------- .../stepping/KotlinSteppingCommandProvider.kt | 9 ++++++++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/DebuggerSteppingHelper.java b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/DebuggerSteppingHelper.java index 2faabe32ded..e83f5bcda26 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/DebuggerSteppingHelper.java +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/DebuggerSteppingHelper.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.debugger.stepping; import com.intellij.debugger.engine.DebugProcessImpl; import com.intellij.debugger.engine.SuspendContextImpl; import com.intellij.debugger.engine.evaluation.EvaluateException; -import com.intellij.debugger.engine.events.SuspendContextCommandImpl; import com.intellij.debugger.impl.DebuggerUtilsEx; import com.intellij.debugger.jdi.StackFrameProxyImpl; import com.intellij.debugger.jdi.ThreadReferenceProxyImpl; @@ -38,7 +37,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.psi.KtFunctionLiteral; import org.jetbrains.kotlin.psi.KtNamedFunction; -import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import java.util.ArrayList; import java.util.List; @@ -63,14 +61,12 @@ public class DebuggerSteppingHelper { kotlinSourcePosition ); - SuspendContextCommandImpl command = action.createCommand(debugProcess, suspendContext, ignoreBreakpoints); - createStepRequest( suspendContext, getContextThread(), debugProcess.getVirtualMachineProxy().eventRequestManager(), StepRequest.STEP_LINE, StepRequest.STEP_OUT); - command.contextAction(); + action.apply(debugProcess, suspendContext, ignoreBreakpoints); return; } @@ -78,9 +74,6 @@ public class DebuggerSteppingHelper { } catch (EvaluateException ignored) { } - catch (Exception e) { - throw ExceptionUtilsKt.rethrow(e); - } } }; } @@ -105,23 +98,18 @@ public class DebuggerSteppingHelper { inlineArgument ); - SuspendContextCommandImpl command = action.createCommand(debugProcess, suspendContext, ignoreBreakpoints); createStepRequest( suspendContext, getContextThread(), debugProcess.getVirtualMachineProxy().eventRequestManager(), StepRequest.STEP_LINE, StepRequest.STEP_OUT); - command.contextAction(); + action.apply(debugProcess, suspendContext, ignoreBreakpoints); return; } debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction(); } catch (EvaluateException ignored) { - - } - catch (Exception e) { - throw ExceptionUtilsKt.rethrow(e); } } }; diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index ea53936033c..72b53632951 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -328,7 +328,14 @@ sealed class Action(val position: XSourcePositionImpl?) { class STEP_OUT: Action(null) class RUN_TO_CURSOR(position: XSourcePositionImpl): Action(position) - fun createCommand( + fun apply(debugProcess: DebugProcessImpl, + suspendContext: SuspendContextImpl, + ignoreBreakpoints: Boolean) { + val command = createCommand(debugProcess, suspendContext, ignoreBreakpoints) + command.contextAction() + } + + private fun createCommand( debugProcess: DebugProcessImpl, suspendContext: SuspendContextImpl, ignoreBreakpoints: Boolean