Bug 206797 - 'Step into Selection' should also be enabled if editor does
not have focus
diff --git a/org.eclipse.jdt.debug.ui/plugin.properties b/org.eclipse.jdt.debug.ui/plugin.properties
index adb2f45..5740f10 100644
--- a/org.eclipse.jdt.debug.ui/plugin.properties
+++ b/org.eclipse.jdt.debug.ui/plugin.properties
@@ -160,7 +160,6 @@
showNullEntriesAction.label=Show &Null Array Entries
showNullEntriesAction.tooltip=Show Null Array Entries
-stepIntoSelectionAction.label=Step &Into Selection
stepIntoSelectionHyperlinkDetector.label=Step Into Selection
stepIntoSelectionHyperlinkDetector.description=Performs the step into selection command on demand via a hyperlink
diff --git a/org.eclipse.jdt.debug.ui/plugin.xml b/org.eclipse.jdt.debug.ui/plugin.xml
index cba101c..0b678e8 100644
--- a/org.eclipse.jdt.debug.ui/plugin.xml
+++ b/org.eclipse.jdt.debug.ui/plugin.xml
@@ -152,26 +152,6 @@
id="org.eclipse.jdt.debug.ui.actions.AddExceptionBreakpoint">
</action>
<action
- definitionId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
- label="%stepIntoSelectionAction.label"
- helpContextId="step_into_selection_action_context"
- class="org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionActionDelegate"
- menubarPath="org.eclipse.ui.run/jdtGroup"
- enablesFor="*"
- id="org.eclipse.jdt.debug.ui.actions.StepIntoSelection">
- <enablement>
- <and>
- <systemProperty
- name="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
- value="true">
- </systemProperty>
- <objectClass
- name="org.eclipse.jface.text.ITextSelection">
- </objectClass>
- </and>
- </enablement>
- </action>
- <action
id="org.eclipse.jdt.debug.ui.actions.ForceReturn"
class="org.eclipse.jdt.internal.debug.ui.actions.ForceReturnAction"
definitionId="org.eclipse.jdt.debug.ui.commands.ForceReturn"
@@ -428,6 +408,74 @@
style="push">
</command>
</menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="menu:org.eclipse.ui.run?endof=emptyStepGroup">
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
+ style="push">
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:#ClassFileEditorContext?before=additions">
+ <separator
+ name="java.debug">
+ </separator>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <systemTest
+ property="org.eclipse.jdt.debug.ui.debuggerActive"
+ value="true">
+ </systemTest>
+ <systemTest
+ property="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
+ value="true">
+ </systemTest>
+ <with
+ variable="activeMenuSelection">
+ <instanceof
+ value="org.eclipse.jface.text.ITextSelection">
+ </instanceof>
+ </with>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:#CompilationUnitEditorContext?before=additions">
+ <separator
+ name="java.debug">
+ </separator>
+ <command
+ commandId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <systemTest
+ property="org.eclipse.jdt.debug.ui.debuggerActive"
+ value="true">
+ </systemTest>
+ <systemTest
+ property="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
+ value="true">
+ </systemTest>
+ <with
+ variable="activeMenuSelection">
+ <instanceof
+ value="org.eclipse.jface.text.ITextSelection">
+ </instanceof>
+ </with>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
</extension>
<extension
point="org.eclipse.ui.views">
@@ -956,7 +1004,7 @@
icon="icons/full/elcl16/runtoline_co.gif"
id="org.eclipse.jdt.debug.ui.cuPopup.RunToLine"
label="%runToLineAction.label"
- menubarPath="additions">
+ menubarPath="java.debug">
</action>
<action
label="%Execute.label"
@@ -964,7 +1012,7 @@
helpContextId="execute_action_context"
definitionId="org.eclipse.jdt.debug.ui.commands.Execute"
class="org.eclipse.jdt.internal.debug.ui.actions.ExecuteAction"
- menubarPath="additions"
+ menubarPath="java.debug"
id="org.eclipse.jdt.debug.ui.cuPopup.Execute">
</action>
<action
@@ -973,7 +1021,7 @@
helpContextId="display_action_context"
definitionId="org.eclipse.jdt.debug.ui.commands.Display"
class="org.eclipse.jdt.internal.debug.ui.actions.PopupDisplayAction"
- menubarPath="additions"
+ menubarPath="java.debug"
id="org.eclipse.jdt.debug.ui.cuPopup.Display">
</action>
<action
@@ -982,7 +1030,7 @@
helpContextId="inspect_action_context"
definitionId="org.eclipse.jdt.debug.ui.commands.Inspect"
class="org.eclipse.jdt.internal.debug.ui.actions.PopupInspectAction"
- menubarPath="additions"
+ menubarPath="java.debug"
id="org.eclipse.jdt.debug.ui.cuPopup.Inspect">
</action>
<action
@@ -990,7 +1038,7 @@
icon="$nl$/icons/full/etool16/watch_exp.gif"
helpContextId="watch_action_context"
class="org.eclipse.jdt.internal.debug.ui.actions.WatchAction"
- menubarPath="additions"
+ menubarPath="java.debug"
id="org.eclipse.jdt.debug.ui.cuPopup.Watch">
</action>
</viewerContribution>
@@ -1008,7 +1056,7 @@
helpContextId="force_return_action_context"
definitionId="org.eclipse.jdt.debug.ui.commands.ForceReturn"
class="org.eclipse.jdt.internal.debug.ui.actions.ForceReturnAction"
- menubarPath="additions"
+ menubarPath="java.debug"
id="org.eclipse.jdt.debug.ui.cuPopup.ForceReturn">
</action>
</viewerContribution>
@@ -1027,7 +1075,7 @@
helpContextId="instance_count_action_context"
id="org.eclipse.jdt.debug.ui.cuPopup.InstanceCount"
label="%instanceCount.label"
- menubarPath="additions"
+ menubarPath="java.debug"
tooltip="%instanceCount.tooltip">
</action>
<action
@@ -1037,39 +1085,11 @@
icon="icons/full/elcl16/all_instances.gif"
id="org.eclipse.jdt.debug.ui.cuPopup.AllInstances"
label="%allInstances.label"
- menubarPath="additions"
+ menubarPath="java.debug"
tooltip="%allInstances.tooltip">
</action>
</viewerContribution>
<viewerContribution
- targetID="#CompilationUnitEditorContext"
- id="org.eclipse.jdt.debug.ui.CUPopupActions">
- <visibility>
- <and>
- <systemProperty
- name="org.eclipse.jdt.debug.ui.debuggerActive"
- value="true">
- </systemProperty>
- <systemProperty
- name="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
- value="true">
- </systemProperty>
- <objectClass
- name="org.eclipse.jface.text.ITextSelection">
- </objectClass>
- </and>
- </visibility>
- <action
- class="org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionActionDelegate"
- definitionId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
- enablesFor="*"
- helpContextId="step_into_selection_action_context"
- id="org.eclipse.jdt.debug.ui.cuPopup.StepIntoSelection"
- label="%stepIntoSelectionAction.label"
- menubarPath="additions">
- </action>
- </viewerContribution>
- <viewerContribution
targetID="#ClassFileEditorContext"
id="org.eclipse.jdt.debug.ui.CFPopupActions">
<visibility>
@@ -1175,34 +1195,6 @@
tooltip="%allInstances.tooltip">
</action>
</viewerContribution>
- <viewerContribution
- targetID="#ClassFileEditorContext"
- id="org.eclipse.jdt.debug.ui.CFPopupActions">
- <visibility>
- <and>
- <systemProperty
- name="org.eclipse.jdt.debug.ui.debuggerActive"
- value="true">
- </systemProperty>
- <systemProperty
- name="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
- value="true">
- </systemProperty>
- <objectClass
- name="org.eclipse.jface.text.ITextSelection">
- </objectClass>
- </and>
- </visibility>
- <action
- class="org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionActionDelegate"
- definitionId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
- enablesFor="*"
- helpContextId="step_into_selection_action_context"
- id="org.eclipse.jdt.debug.ui.cfPopup.StepIntoSelection"
- label="%stepIntoSelectionAction.label"
- menubarPath="additions">
- </action>
- </viewerContribution>
<objectContribution
objectClass="org.eclipse.jdt.core.IMethod"
id="org.eclipse.jdt.debug.ui.MethodBreakpointActions">
@@ -2607,10 +2599,11 @@
id="org.eclipse.jdt.debug.ui.commands.AddClassPrepareBreakpoint">
</command>
<command
- name="%ActionDefinition.stepIntoSelection.name"
- description="%ActionDefinition.stepIntoSelection.description"
categoryId="org.eclipse.debug.ui.category.run"
- id="org.eclipse.jdt.debug.ui.commands.StepIntoSelection">
+ description="%ActionDefinition.stepIntoSelection.description"
+ helpContextId="step_into_selection_action_context"
+ id="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
+ name="%ActionDefinition.stepIntoSelection.name">
</command>
<command
name="%ActionDefinition.execute.name"
@@ -3668,4 +3661,23 @@
type="org.eclipse.swt.widgets.Composite"
description="%descriptionSWTComposite"/>
</extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.jdt.internal.debug.ui.actions.StepIntoEditorSelectionHandler"
+ commandId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection">
+ <enabledWhen>
+ <and>
+ <systemTest
+ property="org.eclipse.jdt.debug.ui.debuggerActive"
+ value="true">
+ </systemTest>
+ <systemTest
+ property="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
+ value="true">
+ </systemTest>
+ </and>
+ </enabledWhen>
+ </handler>
+ </extension>
</plugin>
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java
index 4253c95..ee0db93 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.java
@@ -107,7 +107,6 @@
public static String StepIntoSelectionHandler_Execution_did_not_enter____0____before_the_current_method_returned__1;
public static String StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_top_stack_frame__3;
- public static String StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_Java_editor__4;
public static String StepIntoSelectionActionDelegate_4;
public static String ObjectActionDelegate_Unable_to_display_type_hierarchy__The_selected_source_element_is_not_contained_in_the_workspace__1;
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties
index 930a18c..f8256f1 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ActionMessages.properties
@@ -85,7 +85,6 @@
StepIntoSelectionHandler_Execution_did_not_enter____0____before_the_current_method_returned__1=Execution did not enter \"{0}\" before the current method returned.
StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_top_stack_frame__3=Step into selection only available in top stack frame.
-StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_Java_editor__4=Step into selection only available in Java editor.
StepIntoSelectionActionDelegate_4=An exception occurred attempting to run to the selected line.
ObjectActionDelegate_Unable_to_display_type_hierarchy__The_selected_source_element_is_not_contained_in_the_workspace__1=Unable to display type hierarchy. The selected source element is not contained in the workspace.
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoEditorSelectionHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoEditorSelectionHandler.java
new file mode 100644
index 0000000..648c66f
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoEditorSelectionHandler.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) Jan 14, 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.debug.ui.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Default handler for Step Into Editor Selection action
+ *
+ * @since 3.6.200
+ */
+public class StepIntoEditorSelectionHandler extends AbstractHandler {
+
+ IDebugEventSetListener listener = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IEditorPart editor = HandlerUtil.getActiveEditor(event);
+ if(editor != null) {
+ ISelection selection = editor.getEditorSite().getSelectionProvider().getSelection();
+ if(selection instanceof ITextSelection) {
+ StepIntoSelectionUtils.stepIntoSelection((ITextSelection) selection);
+ }
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java
deleted file mode 100644
index f4fa26b..0000000
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionActionDelegate.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Samrat Dhillon samrat.dhillon@gmail.com - Bug 356070 Step into selection does not work for generic types
- *******************************************************************************/
-package org.eclipse.jdt.internal.debug.ui.actions;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.ui.actions.IRunToLineTarget;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.debug.core.IJavaStackFrame;
-import org.eclipse.jdt.debug.core.IJavaThread;
-import org.eclipse.jdt.internal.debug.ui.EvaluationContextManager;
-import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IEditorActionDelegate;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * Steps into the selected method.
- */
-public class StepIntoSelectionActionDelegate implements IEditorActionDelegate, IWorkbenchWindowActionDelegate {
-
- private IEditorPart fEditorPart = null;
- private IWorkbenchWindow fWindow = null;
- private IRegion fTextRegion = null;
-
- /**
- * Default constructor
- */
- public StepIntoSelectionActionDelegate() {}
-
- /**
- * Constructor
- * @param region
- */
- public StepIntoSelectionActionDelegate(IRegion region) {
- fTextRegion = region;
- }
-
- /**
- * The name of the type being "run to".
- * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaStackFrame, IMethod)
- */
- private String fRunToLineType= null;
- /**
- * The line number being "run to."
- * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaStackFrame, IMethod)
- */
- private int fRunToLineLine= -1;
- /**
- * The debug event list listener used to know when a run to line has finished.
- * @see StepIntoSelectionActionDelegate#runToLineBeforeStepIn(ITextSelection, IJavaStackFrame, IMethod)
- */
- private IDebugEventSetListener listener= null;
-
- /**
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- IJavaStackFrame frame = getStackFrame();
- if (frame == null || !frame.isSuspended()) {
- // no longer suspended - unexpected
- return;
- }
- ITextSelection textSelection = getTextSelection();
- try {
- IEditorPart activeEditor = getActiveEditor();
- IJavaElement javaElement= StepIntoSelectionUtils.getJavaElement(activeEditor.getEditorInput());
- IMethod method = StepIntoSelectionUtils.getMethod(textSelection, javaElement);
- if (method == null) {
- method = StepIntoSelectionUtils.getFirstMethodOnLine(textSelection.getOffset(), activeEditor, javaElement);
- }
- IType callingType = getType(textSelection);
- if (method == null || callingType == null) {
- return;
- }
- int lineNumber = frame.getLineNumber();
- String callingTypeName = stripInnerNamesAndParameterType(callingType.getFullyQualifiedName());
- String frameName = stripInnerNamesAndParameterType(frame.getDeclaringTypeName());
- // debug line numbers are 1 based, document line numbers are 0 based
- if (textSelection.getStartLine() == (lineNumber - 1) && callingTypeName.equals(frameName)) {
- doStepIn(frame, method);
- } else {
- // not on current line
- runToLineBeforeStepIn(textSelection, frame.getThread(), method);
- return;
- }
- }
- catch (DebugException e) {
- showErrorMessage(e.getStatus().getMessage());
- return;
- }
- catch(JavaModelException jme) {
- showErrorMessage(jme.getStatus().getMessage());
- return;
- }
- }
-
- /**
- * Steps into the given method in the given stack frame
- * @param frame the frame in which the step should begin
- * @param method the method to step into
- * @throws DebugException
- */
- private void doStepIn(IJavaStackFrame frame, IMethod method) throws DebugException {
- // ensure top stack frame
- IStackFrame tos = frame.getThread().getTopStackFrame();
- if (tos == null) {
- return;
- }
- if (!tos.equals(frame)) {
- showErrorMessage(ActionMessages.StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_top_stack_frame__3);
- return;
- }
- StepIntoSelectionHandler handler = new StepIntoSelectionHandler((IJavaThread)frame.getThread(), frame, method);
- handler.step();
- }
-
- /**
- * When the user chooses to "step into selection" on a line other than
- * the currently executing one, first perform a "run to line" to get to
- * the desired location, then perform a "step into selection."
- */
- private void runToLineBeforeStepIn(ITextSelection textSelection, final IThread thread, final IMethod method) {
- fRunToLineType = getType(textSelection).getFullyQualifiedName();
- fRunToLineLine = textSelection.getStartLine() + 1;
- if (fRunToLineType == null || fRunToLineLine == -1) {
- return;
- }
- // see bug 65489 - get the run-to-line adapter from the editor
- IRunToLineTarget runToLineAction = null;
- IEditorPart ed = getActiveEditor();
- if (ed != null) {
- runToLineAction = (IRunToLineTarget) ed.getAdapter(IRunToLineTarget.class);
- if (runToLineAction == null) {
- IAdapterManager adapterManager = Platform.getAdapterManager();
- if (adapterManager.hasAdapter(ed, IRunToLineTarget.class.getName())) {
- runToLineAction = (IRunToLineTarget) adapterManager.loadAdapter(ed,IRunToLineTarget.class.getName());
- }
- }
- }
- // if no adapter exists, use the Java adapter
- if (runToLineAction == null) {
- runToLineAction = new RunToLineAdapter();
- }
- listener= new IDebugEventSetListener() {
- /**
- * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
- */
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- switch (event.getKind()) {
- case DebugEvent.SUSPEND :
- handleSuspendEvent(event);
- break;
- case DebugEvent.TERMINATE :
- handleTerminateEvent(event);
- break;
- default :
- break;
- }
- }
- }
- /**
- * Listen for the completion of the "run to line." When the thread
- * suspends at the correct location, perform a "step into selection"
- * @param event the debug event
- */
- private void handleSuspendEvent(DebugEvent event) {
- Object source = event.getSource();
- if (source instanceof IJavaThread) {
- try {
- final IJavaStackFrame frame= (IJavaStackFrame) ((IJavaThread) source).getTopStackFrame();
- if (isExpectedFrame(frame)) {
- DebugPlugin plugin = DebugPlugin.getDefault();
- plugin.removeDebugEventListener(listener);
- plugin.asyncExec(new Runnable() {
- public void run() {
- try {
- doStepIn(frame, method);
- } catch (DebugException e) {
- showErrorMessage(e.getStatus().getMessage());
- }
- }
- });
- }
- } catch (DebugException e) {
- return;
- }
- }
- }
- /**
- * Returns whether the given frame is the frame that this action is expecting.
- * This frame is expecting a stack frame for the suspension of the "run to line".
- * @param frame the given stack frame or <code>null</code>
- * @return whether the given stack frame is the expected frame
- * @throws DebugException
- */
- private boolean isExpectedFrame(IJavaStackFrame frame) throws DebugException {
- return frame != null &&
- fRunToLineLine == frame.getLineNumber() &&
- frame.getReceivingTypeName().equals(fRunToLineType);
- }
- /**
- * When the debug target we're listening for terminates, stop listening
- * to debug events.
- * @param event the debug event
- */
- private void handleTerminateEvent(DebugEvent event) {
- Object source = event.getSource();
- if (thread.getDebugTarget() == source) {
- DebugPlugin.getDefault().removeDebugEventListener(listener);
- }
- }
- };
- DebugPlugin.getDefault().addDebugEventListener(listener);
- try {
- runToLineAction.runToLine(getActiveEditor(), textSelection, thread);
- } catch (CoreException e) {
- DebugPlugin.getDefault().removeDebugEventListener(listener);
- showErrorMessage(ActionMessages.StepIntoSelectionActionDelegate_4);
- JDIDebugUIPlugin.log(e.getStatus());
- }
- }
-
- /**
- * Gets the current text selection from the currently active editor
- * @return the current text selection
- */
- private ITextSelection getTextSelection() {
- IEditorPart part = getActiveEditor();
- if (part instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor)part;
- if(fTextRegion != null) {
- IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
- if(document != null) {
- return new TextSelection(document, fTextRegion.getOffset(), fTextRegion.getLength());
- }
- }
- else {
- return (ITextSelection)editor.getSelectionProvider().getSelection();
- }
- }
- showErrorMessage(ActionMessages.StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_Java_editor__4);
- return null;
- }
-
- /**
- * Return the type containing the selected text, or <code>null</code> if the
- * selection is not in a type.
- */
- protected IType getType(ITextSelection textSelection) {
- IMember member= ActionDelegateHelper.getDefault().getCurrentMember(textSelection);
- IType type= null;
- if (member instanceof IType) {
- type = (IType)member;
- } else if (member != null) {
- type= member.getDeclaringType();
- }
- return type;
- }
-
- /**
- * Displays an error message in the status area
- *
- * @param message
- */
- protected void showErrorMessage(String message) {
- if (getActiveEditor() != null) {
- IEditorStatusLine statusLine= (IEditorStatusLine) getActiveEditor().getAdapter(IEditorStatusLine.class);
- if (statusLine != null) {
- statusLine.setMessage(true, message, null);
- }
- }
- JDIDebugUIPlugin.getStandardDisplay().beep();
- }
-
-
- /**
- * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
- */
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- fEditorPart = targetEditor;
- }
-
- /**
- * Returns the active editor or <code>null</code>.
- *
- * @return active editor or <code>null</code>
- */
- protected IEditorPart getActiveEditor() {
- if (fWindow != null) {
- // global action
- return fWindow.getActivePage().getActiveEditor();
- }
- // pop-up action
- return fEditorPart;
- }
-
- /**
- * Strips inner class names and parameterized type information from the given type name.
- *
- * @param fullyQualifiedName
- */
- private String stripInnerNamesAndParameterType(String fullyQualifiedName) {
- // ignore inner class qualification, as the compiler generated names and java model names can be different
- String sig = fullyQualifiedName;
- int index = sig.indexOf('$');
- if (index > 0) {
- sig = sig.substring(0, index);
- }
- //also ignore erasure
- index = sig.indexOf('<');
- if (index > 0){
- sig = sig.substring(0, index);
- }
- return sig;
- }
-
- /**
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- /**
- * Returns the current stack frame context, or <code>null</code> if none.
- *
- * @return the current stack frame context, or <code>null</code> if none
- */
- protected IJavaStackFrame getStackFrame() {
- return EvaluationContextManager.getEvaluationContext(getActiveEditor());
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {}
-
- /**
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- fWindow = window;
- }
-
-}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java
index a6cc67b..d1906b4 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionHyperlinkDetector.java
@@ -21,7 +21,9 @@
import org.eclipse.jdt.internal.debug.ui.JavaWordFinder;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
@@ -40,20 +42,20 @@
*/
class StepIntoSelectionHyperlink implements IHyperlink {
- private IRegion fRegion = null;
+ private ITextSelection fSelection = null;
/**
* Constructor
* @param region
*/
- public StepIntoSelectionHyperlink(IRegion region) {
- fRegion = region;
+ public StepIntoSelectionHyperlink(ITextSelection selection) {
+ fSelection = selection;
}
/**
* @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion()
*/
public IRegion getHyperlinkRegion() {
- return fRegion;
+ return new Region(fSelection.getOffset(), fSelection.getLength());
}
/**
* @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
@@ -71,9 +73,7 @@
* @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
*/
public void open() {
- StepIntoSelectionActionDelegate delegate = new StepIntoSelectionActionDelegate(fRegion);
- delegate.init(JDIDebugUIPlugin.getActiveWorkbenchWindow());
- delegate.run(null);
+ StepIntoSelectionUtils.stepIntoSelection(fSelection);
}
}
@@ -100,9 +100,10 @@
if(document != null) {
IRegion wregion = JavaWordFinder.findWord(document, offset);
if(wregion != null) {
- IMethod method = StepIntoSelectionUtils.getMethod(new TextSelection(document, wregion.getOffset(), wregion.getLength()), element);
+ ITextSelection selection = new TextSelection(document, wregion.getOffset(), wregion.getLength());
+ IMethod method = StepIntoSelectionUtils.getMethod(selection, element);
if (method != null) {
- return new IHyperlink[] {new StepIntoSelectionHyperlink(wregion)};
+ return new IHyperlink[] {new StepIntoSelectionHyperlink(selection)};
}
}
}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java
index 038fe4b..6c11ab0 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/StepIntoSelectionUtils.java
@@ -10,15 +10,31 @@
*******************************************************************************/
package org.eclipse.jdt.internal.debug.ui.actions;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.ui.actions.IRunToLineTarget;
import org.eclipse.jdt.core.ICodeAssist;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.compiler.IScanner;
import org.eclipse.jdt.core.compiler.ITerminalSymbols;
import org.eclipse.jdt.core.compiler.InvalidInputException;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.internal.debug.ui.EvaluationContextManager;
+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -26,7 +42,9 @@
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditor;
/**
@@ -134,4 +152,238 @@
return null;
}
+ /**
+ * Steps into the selection described by the given {@link IRegion}
+ *
+ * @param region the region of the selection or <code>null</code> if we should use the page's selection service to compute
+ * the selection
+ *
+ * @since 3.6.200
+ */
+ public static void stepIntoSelection(ITextSelection selection) {
+ IWorkbenchPage page = JDIDebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
+ if(page != null) {
+ IEditorPart editor = page.getActiveEditor();
+ if(editor instanceof ITextEditor) {
+ IJavaStackFrame frame = EvaluationContextManager.getEvaluationContext(editor);
+ if (frame == null || !frame.isSuspended()) {
+ // no longer suspended - unexpected
+ return;
+ }
+ if(selection == null) {
+ //grab it from the provider, either the passed region was null or we failed to get it
+ selection = (ITextSelection)editor.getEditorSite().getSelectionProvider().getSelection();
+ }
+ try {
+ IJavaElement javaElement= StepIntoSelectionUtils.getJavaElement(editor.getEditorInput());
+ IMethod method = StepIntoSelectionUtils.getMethod(selection, javaElement);
+ if (method == null) {
+ method = StepIntoSelectionUtils.getFirstMethodOnLine(selection.getOffset(), editor, javaElement);
+ }
+ IType callingType = getType(selection);
+ if (method == null || callingType == null) {
+ return;
+ }
+ int lineNumber = frame.getLineNumber();
+ String callingTypeName = stripInnerNamesAndParameterType(callingType.getFullyQualifiedName());
+ String frameName = stripInnerNamesAndParameterType(frame.getDeclaringTypeName());
+ // debug line numbers are 1 based, document line numbers are 0 based
+ if (selection.getStartLine() == (lineNumber - 1) && callingTypeName.equals(frameName)) {
+ doStepIn(editor, frame, method);
+ } else {
+ // not on current line
+ runToLineBeforeStepIn(editor, callingTypeName, selection, frame.getThread(), method);
+ return;
+ }
+ }
+ catch (DebugException e) {
+ showErrorMessage(editor, e.getStatus().getMessage());
+ return;
+ }
+ catch(JavaModelException jme) {
+ showErrorMessage(editor, jme.getStatus().getMessage());
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * When the user chooses to "step into selection" on a line other than
+ * the currently executing one, first perform a "run to line" to get to
+ * the desired location, then perform a "step into selection."
+ */
+ static void runToLineBeforeStepIn(final IEditorPart editor, final String typeName, ITextSelection textSelection, final IThread thread, final IMethod method) {
+ final int line = textSelection.getStartLine() + 1;
+ if (typeName == null || line == -1) {
+ return;
+ }
+ // see bug 65489 - get the run-to-line adapter from the editor
+ IRunToLineTarget runToLineAction = null;
+ if (editor != null) {
+ runToLineAction = (IRunToLineTarget) editor.getAdapter(IRunToLineTarget.class);
+ if (runToLineAction == null) {
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ if (adapterManager.hasAdapter(editor, IRunToLineTarget.class.getName())) {
+ runToLineAction = (IRunToLineTarget) adapterManager.loadAdapter(editor,IRunToLineTarget.class.getName());
+ }
+ }
+ }
+ // if no adapter exists, use the Java adapter
+ if (runToLineAction == null) {
+ runToLineAction = new RunToLineAdapter();
+ }
+ final IDebugEventSetListener listener = new IDebugEventSetListener() {
+ /**
+ * @see IDebugEventSetListener#handleDebugEvents(DebugEvent[])
+ */
+ public void handleDebugEvents(DebugEvent[] events) {
+ for (int i = 0; i < events.length; i++) {
+ DebugEvent event = events[i];
+ switch (event.getKind()) {
+ case DebugEvent.SUSPEND :
+ handleSuspendEvent(event);
+ break;
+ case DebugEvent.TERMINATE :
+ handleTerminateEvent(event);
+ break;
+ default :
+ break;
+ }
+ }
+ }
+ /**
+ * Listen for the completion of the "run to line." When the thread
+ * suspends at the correct location, perform a "step into selection"
+ * @param event the debug event
+ */
+ private void handleSuspendEvent(DebugEvent event) {
+ Object source = event.getSource();
+ if (source instanceof IJavaThread) {
+ try {
+ final IJavaStackFrame frame= (IJavaStackFrame) ((IJavaThread) source).getTopStackFrame();
+ if (isExpectedFrame(frame)) {
+ DebugPlugin plugin = DebugPlugin.getDefault();
+ plugin.removeDebugEventListener(this);
+ plugin.asyncExec(new Runnable() {
+ public void run() {
+ try {
+ doStepIn(editor, frame, method);
+ } catch (DebugException e) {
+ showErrorMessage(editor, e.getStatus().getMessage());
+ }
+ }
+ });
+ }
+ } catch (DebugException e) {
+ return;
+ }
+ }
+ }
+ /**
+ * Returns whether the given frame is the frame that this action is expecting.
+ * This frame is expecting a stack frame for the suspension of the "run to line".
+ * @param frame the given stack frame or <code>null</code>
+ * @return whether the given stack frame is the expected frame
+ * @throws DebugException
+ */
+ private boolean isExpectedFrame(IJavaStackFrame frame) throws DebugException {
+ return frame != null &&
+ line == frame.getLineNumber() &&
+ frame.getReceivingTypeName().equals(typeName);
+ }
+ /**
+ * When the debug target we're listening for terminates, stop listening
+ * to debug events.
+ * @param event the debug event
+ */
+ private void handleTerminateEvent(DebugEvent event) {
+ Object source = event.getSource();
+ if (thread.getDebugTarget() == source) {
+ DebugPlugin.getDefault().removeDebugEventListener(this);
+ }
+ }
+ };
+ DebugPlugin.getDefault().addDebugEventListener(listener);
+ try {
+ runToLineAction.runToLine(editor, textSelection, thread);
+ } catch (CoreException e) {
+ DebugPlugin.getDefault().removeDebugEventListener(listener);
+ showErrorMessage(editor, ActionMessages.StepIntoSelectionActionDelegate_4);
+ JDIDebugUIPlugin.log(e.getStatus());
+ }
+ }
+
+ /**
+ * Steps into the given method in the given stack frame
+ *
+ * @param editor
+ * @param frame the frame in which the step should begin
+ * @param method the method to step into
+ * @throws DebugException
+ */
+ static void doStepIn(IEditorPart editor, IJavaStackFrame frame, IMethod method) throws DebugException {
+ // ensure top stack frame
+ IStackFrame tos = frame.getThread().getTopStackFrame();
+ if (tos == null) {
+ return;
+ }
+ if (!tos.equals(frame)) {
+ showErrorMessage(editor, ActionMessages.StepIntoSelectionActionDelegate_Step_into_selection_only_available_in_top_stack_frame__3);
+ return;
+ }
+ StepIntoSelectionHandler handler = new StepIntoSelectionHandler((IJavaThread)frame.getThread(), frame, method);
+ handler.step();
+ }
+
+ /**
+ * Displays an error message in the status area
+ *
+ * @param editor
+ * @param message
+ */
+ static void showErrorMessage(IEditorPart editor, String message) {
+ if (editor != null) {
+ IEditorStatusLine statusLine= (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class);
+ if (statusLine != null) {
+ statusLine.setMessage(true, message, null);
+ }
+ }
+ JDIDebugUIPlugin.getStandardDisplay().beep();
+ }
+
+ /**
+ * Return the type containing the selected text, or <code>null</code> if the
+ * selection is not in a type.
+ */
+ static IType getType(ITextSelection textSelection) {
+ IMember member= ActionDelegateHelper.getDefault().getCurrentMember(textSelection);
+ IType type= null;
+ if (member instanceof IType) {
+ type = (IType)member;
+ } else if (member != null) {
+ type= member.getDeclaringType();
+ }
+ return type;
+ }
+
+ /**
+ * Strips inner class names and parameterized type information from the given type name.
+ *
+ * @param fullyQualifiedName
+ */
+ static String stripInnerNamesAndParameterType(String fullyQualifiedName) {
+ // ignore inner class qualification, as the compiler generated names and java model names can be different
+ String sig = fullyQualifiedName;
+ int index = sig.indexOf('$');
+ if (index > 0) {
+ sig = sig.substring(0, index);
+ }
+ //also ignore erasure
+ index = sig.indexOf('<');
+ if (index > 0){
+ sig = sig.substring(0, index);
+ }
+ return sig;
+ }
}
diff --git a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.java b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.java
index 84ba360..f8b7f17 100644
--- a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.java
+++ b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.java
@@ -65,7 +65,6 @@
public static String PrimitiveTypeImpl_Invalid_primitive_signature____1;
public static String PrimitiveTypeImpl___2;
public static String PrimitiveTypeImpl_A_PrimitiveType_does_not_have_modifiers_3;
- public static String PrimitiveValueImpl_Invalid_Primitive_Value_encountered_1;
public static String PrimitiveValueImpl_Invalid_Primitive_Value_tag_encountered___2;
public static String ReferenceTypeImpl_26;
diff --git a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.properties b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.properties
index 0e58b85..b82e4fd 100644
--- a/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.properties
+++ b/org.eclipse.jdt.debug/jdi/org/eclipse/jdi/internal/JDIMessages.properties
@@ -53,7 +53,6 @@
PrimitiveTypeImpl_Invalid_primitive_signature____1=Invalid primitive signature: "
PrimitiveTypeImpl___2="
PrimitiveTypeImpl_A_PrimitiveType_does_not_have_modifiers_3=A PrimitiveType does not have modifiers
-PrimitiveValueImpl_Invalid_Primitive_Value_encountered_1=Invalid Primitive Value encountered
PrimitiveValueImpl_Invalid_Primitive_Value_tag_encountered___2=Invalid Primitive Value tag encountered:
ReferenceTypeImpl_Obsolete_method_1=Obsolete method
ReferenceTypeImpl_Retrieved_a_different_number_of_values_from_the_VM_than_requested_3=Retrieved a different number of values from the VM than requested
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
index bea5198..61c254f 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
@@ -130,7 +130,6 @@
public static String StandardVMType_ok_2;
public static String StandardVMType_Standard_VM_3;
public static String StandardVMType_Not_a_JDK_root__System_library_was_not_found__1;
- public static String StandardVMType_Standard_VM_not_supported_on_MacOS__1;
public static String VMDefinitionsContainer_0;
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
index 0b05d47..8c12e0d 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
@@ -108,7 +108,6 @@
StandardVMType_ok_2=ok
StandardVMType_Standard_VM_3=Standard VM
StandardVMType_Not_a_JDK_root__System_library_was_not_found__1=Target is not a JDK root. System library was not found.
-StandardVMType_Standard_VM_not_supported_on_MacOS__1=Standard VM not supported on MacOS.
vmInstall_assert_idNotNull=id cannot be null
vmInstall_assert_typeNotNull=VM type cannot be null