From 1d8ec7b55946a48b4d5ea23f1ecff763e7f4e8a4 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Thu, 20 Aug 2015 17:46:17 +0300 Subject: [PATCH] IDEA-144037 Debuger: Api request: Create custom commands for Step Over and etc in DebuggerSession --- .../debugger/impl/DebuggerSession.java | 31 +++++++++-- .../impl/JvmSteppingCommandProvider.java | 54 +++++++++++++++++++ resources/src/META-INF/IdeaPlugin.xml | 2 + 3 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 java/debugger/impl/src/com/intellij/debugger/impl/JvmSteppingCommandProvider.java diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java index 71e81fbba7d9..d7cf1f2516cb 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/DebuggerSession.java @@ -273,8 +273,15 @@ public class DebuggerSession implements AbstractDebuggerSession { } public void stepOut(int stepSize) { - final SuspendContextImpl suspendContext = getSuspendContext(); - final DebugProcessImpl.ResumeCommand cmd = myDebugProcess.createStepOutCommand(suspendContext, stepSize); + SuspendContextImpl suspendContext = getSuspendContext(); + DebugProcessImpl.ResumeCommand cmd = null; + for (JvmSteppingCommandProvider handler : JvmSteppingCommandProvider.EP_NAME.getExtensions()) { + cmd = handler.getStepOutCommand(suspendContext, stepSize); + if (cmd != null) break; + } + if (cmd == null) { + cmd = myDebugProcess.createStepOutCommand(suspendContext, stepSize); + } setSteppingThrough(cmd.getContextThread()); resumeAction(cmd, Event.STEP); } @@ -284,8 +291,15 @@ public class DebuggerSession implements AbstractDebuggerSession { } public void stepOver(boolean ignoreBreakpoints, int stepSize) { - final SuspendContextImpl suspendContext = getSuspendContext(); - final DebugProcessImpl.ResumeCommand cmd = myDebugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints, stepSize); + SuspendContextImpl suspendContext = getSuspendContext(); + DebugProcessImpl.ResumeCommand cmd = null; + for (JvmSteppingCommandProvider handler : JvmSteppingCommandProvider.EP_NAME.getExtensions()) { + cmd = handler.getStepOverCommand(suspendContext, ignoreBreakpoints, stepSize); + if (cmd != null) break; + } + if (cmd == null) { + cmd = myDebugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints, stepSize); + } setSteppingThrough(cmd.getContextThread()); resumeAction(cmd, Event.STEP); } @@ -296,7 +310,14 @@ public class DebuggerSession implements AbstractDebuggerSession { public void stepInto(final boolean ignoreFilters, final @Nullable MethodFilter smartStepFilter, int stepSize) { final SuspendContextImpl suspendContext = getSuspendContext(); - final DebugProcessImpl.ResumeCommand cmd = myDebugProcess.createStepIntoCommand(suspendContext, ignoreFilters, smartStepFilter, stepSize); + DebugProcessImpl.ResumeCommand cmd = null; + for (JvmSteppingCommandProvider handler : JvmSteppingCommandProvider.EP_NAME.getExtensions()) { + cmd = handler.getStepIntoCommand(suspendContext, ignoreFilters, smartStepFilter, stepSize); + if (cmd != null) break; + } + if (cmd == null) { + cmd = myDebugProcess.createStepIntoCommand(suspendContext, ignoreFilters, smartStepFilter, stepSize); + } setSteppingThrough(cmd.getContextThread()); resumeAction(cmd, Event.STEP); } diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/JvmSteppingCommandProvider.java b/java/debugger/impl/src/com/intellij/debugger/impl/JvmSteppingCommandProvider.java new file mode 100644 index 000000000000..3331a4c98b8e --- /dev/null +++ b/java/debugger/impl/src/com/intellij/debugger/impl/JvmSteppingCommandProvider.java @@ -0,0 +1,54 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.impl; + +import com.intellij.debugger.engine.DebugProcessImpl; +import com.intellij.debugger.engine.MethodFilter; +import com.intellij.debugger.engine.SuspendContextImpl; +import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.Nullable; + +/** + * @author egor + */ +public abstract class JvmSteppingCommandProvider { + public static ExtensionPointName EP_NAME = + ExtensionPointName.create("com.intellij.debugger.jvmSteppingCommandProvider"); + + /** + * @return null if can not handle + */ + public DebugProcessImpl.ResumeCommand getStepIntoCommand(SuspendContextImpl suspendContext, + boolean ignoreFilters, + final MethodFilter smartStepFilter, + int stepSize) { + return null; + } + + /** + * @return null if can not handle + */ + public DebugProcessImpl.ResumeCommand getStepOutCommand(SuspendContextImpl suspendContext, int stepSize) { + return null; + } + + /** + * @return null if can not handle + */ + public DebugProcessImpl.ResumeCommand getStepOverCommand(SuspendContextImpl suspendContext, boolean ignoreBreakpoints, int stepSize) { + return null; + } +} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 5f6b1a4d0341..e9f3a0c2fe14 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -135,6 +135,8 @@ area="IDEA_PROJECT"/> +