Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 60733 Details for
Bug 150652
[evaluation] Force early return
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
work in progress
force-return.patch (text/plain), 39.44 KB, created by
Darin Wright
on 2007-03-13 17:14:14 EDT
(
hide
)
Description:
work in progress
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2007-03-13 17:14:14 EDT
Size:
39.44 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug >Index: model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java,v >retrieving revision 1.175 >diff -u -r1.175 JDIThread.java >--- model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java 13 Mar 2007 19:00:59 -0000 1.175 >+++ model/org/eclipse/jdt/internal/debug/core/model/JDIThread.java 13 Mar 2007 21:12:33 -0000 >@@ -2669,12 +2669,13 @@ > return; > } > try { >- setRunning(true); >- setSuspendedQuiet(false); >- fireResumeEvent(DebugEvent.CLIENT_REQUEST); >- preserveStackFrames(); >+// setRunning(true); >+// setSuspendedQuiet(false); >+// fireResumeEvent(DebugEvent.CLIENT_REQUEST); >+// preserveStackFrames(); > fThread.forceEarlyReturn(((JDIValue)value).getUnderlyingValue()); >- fThread.resume(); >+// fThread.resume(); >+ stepReturn(); > } catch (VMDisconnectedException e) { > disconnected(); > } catch (InvalidTypeException e) { >@@ -2696,8 +2697,8 @@ > * @throws DebugException wrapping the given exception > */ > private void returnFailed(Exception e) throws DebugException { >- setRunning(false); >- fireSuspendEvent(DebugEvent.CLIENT_REQUEST); >+// setRunning(false); >+// fireSuspendEvent(DebugEvent.CLIENT_REQUEST); > targetRequestFailed(JDIDebugModelMessages.JDIThread_48, e); > } > >#P org.eclipse.debug.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.debug.ui/plugin.xml,v >retrieving revision 1.395 >diff -u -r1.395 plugin.xml >--- plugin.xml 12 Mar 2007 19:15:15 -0000 1.395 >+++ plugin.xml 13 Mar 2007 21:12:36 -0000 >@@ -164,20 +164,6 @@ > label="%BreakpointActionSet.label" > visible="false" > id="org.eclipse.debug.ui.breakpointActionSet"> >- <menu >- label="%RunMenu.label" >- path="additions" >- id="org.eclipse.ui.run"> >- <separator >- name="breakpointGroup"> >- </separator> >- <groupMarker >- name="lineBreakpointGroup"> >- </groupMarker> >- <groupMarker >- name="emptyBreakpointGroup"> >- </groupMarker> >- </menu> > <action > disabledIcon="$nl$/icons/full/dlcl16/rem_all_co.gif" > label="%RemoveAllBreakpointsAction.label" >@@ -242,26 +228,6 @@ > label="%DebugActionSet.label" > visible="false" > id="org.eclipse.debug.ui.debugActionSet"> >- <menu >- label="%RunMenu.label" >- path="additions" >- id="org.eclipse.ui.run"> >- <separator >- name="stepGroup"> >- </separator> >- <groupMarker >- name="stepIntoGroup"> >- </groupMarker> >- <groupMarker >- name="stepOverGroup"> >- </groupMarker> >- <groupMarker >- name="stepReturnGroup"> >- </groupMarker> >- <groupMarker >- name="emptyStepGroup"> >- </groupMarker> >- </menu> > <action > id="org.eclipse.debug.ui.actions.ToggleStepFilters" > hoverIcon="$nl$/icons/full/elcl16/stepbystep_co.gif" >@@ -356,23 +322,6 @@ > label="%LaunchActionSet.label" > visible="false" > id="org.eclipse.debug.ui.launchActionSet"> >- <menu >- label="%RunMenu.label" >- path="additions" >- id="org.eclipse.ui.run"> >- <separator >- name="relaunchGroup"> >- </separator> >- <separator >- name="runGroup"> >- </separator> >- <separator >- name="debugGroup"> >- </separator> >- <separator >- name="emptyLaunchGroup"> >- </separator> >- </menu> > <action > class="org.eclipse.debug.internal.ui.actions.OpenRunConfigurations" > definitionId="org.eclipse.debug.ui.commands.OpenRunConfigurations" >@@ -476,17 +425,6 @@ > label="%ProfileActionSet.label" > visible="false" > id="org.eclipse.debug.ui.profileActionSet"> >- <menu >- label="%RunMenu.label" >- path="additions" >- id="org.eclipse.ui.run"> >- <separator >- name="relaunchGroup"> >- </separator> >- <separator >- name="profileGroup"> >- </separator> >- </menu> > <action > id="org.eclipse.debug.internal.ui.actions.ProfileDropDownAction" > toolbarPath="org.eclipse.debug.ui.launchActionSet/debug" >@@ -1490,10 +1428,11 @@ > id="org.eclipse.debug.ui.commands.OpenDebugConfigurations"> > </command> > <command >- name="%ActionDefinition.debugLast.name" > categoryId="org.eclipse.debug.ui.category.run" > description="%ActionDefinition.debugLast.description" >- id="org.eclipse.debug.ui.commands.DebugLast"> >+ helpContextId="debug_last_action_context" >+ id="org.eclipse.debug.ui.commands.DebugLast" >+ name="%ActionDefinition.debugLast.name"> > </command> > <command > name="%ActionDefinition.runLast.name" >@@ -2297,6 +2236,74 @@ > </wizard> > </extension> > <extension >+ point="org.eclipse.ui.menus"> >+ <menuContribution >+ locationURI="menu:org.eclipse.ui.main.menu"> >+ <menu >+ id="org.eclipse.ui.run" >+ label="%RunMenu.label" >+ mnemonic="R" >+ tooltip="The main run menu"> >+ <separator >+ name="stepGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="stepIntoGroup" >+ visible="false"> >+ </separator> >+ <separator >+ name="stepOverGroup" >+ visible="false"> >+ </separator> >+ <separator >+ name="stepReturnGroup" >+ visible="false"> >+ </separator> >+ <separator >+ name="emptyStepGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="relaunchGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="debugGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="runGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="profileGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="emptyLaunchGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="breakpointGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="lineBreakpointGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="emptyBreakpointGroup" >+ visible="true"> >+ </separator> >+ <separator >+ name="additions"> >+ </separator> >+ >+ </menu> >+ </menuContribution> >+ </extension> >+ <extension > point="org.eclipse.ui.exportWizards"> > <wizard > category="org.eclipse.ui.Basic" >#P org.eclipse.jdt.debug.ui >Index: ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java,v >retrieving revision 1.134 >diff -u -r1.134 JDIDebugUIPlugin.java >--- ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java 21 Feb 2007 19:13:57 -0000 1.134 >+++ ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java 13 Mar 2007 21:12:39 -0000 >@@ -114,6 +114,11 @@ > public static final String COMMAND_INSPECT = "org.eclipse.jdt.debug.ui.commands.Inspect"; //$NON-NLS-1$ > > /** >+ * Whether this plug-in is in debug mode. >+ */ >+ public static boolean DEBUG = false; >+ >+ /** > * Java Debug UI plug-in instance > */ > private static JDIDebugUIPlugin fgPlugin; >@@ -333,6 +338,7 @@ > */ > public void start(BundleContext context) throws Exception { > super.start(context); >+ DEBUG = "true".equals(Platform.getDebugOption("org.eclipse.jdt.debug.ui/debug")); //$NON-NLS-1$//$NON-NLS-2$ > JavaDebugOptionsManager.getDefault().startup(); > ResourcesPlugin.getWorkspace().addSaveParticipant(this, new ISaveParticipant() { > public void doneSaving(ISaveContext context) {} >Index: ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java,v >retrieving revision 1.78 >diff -u -r1.78 JavaDebugOptionsManager.java >--- ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java 12 Mar 2007 16:23:48 -0000 1.78 >+++ ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java 13 Mar 2007 21:12:39 -0000 >@@ -60,6 +60,7 @@ > import org.eclipse.jdt.internal.debug.core.logicalstructures.JavaLogicalStructures; > import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget; > import org.eclipse.jdt.internal.debug.ui.actions.JavaBreakpointPropertiesAction; >+import org.eclipse.jdt.internal.debug.ui.evaluation.EvaluationContextManager2; > import org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookLauncher; > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.util.IPropertyChangeListener; >@@ -199,6 +200,7 @@ > debugPlugin.getLaunchManager().addLaunchListener(this); > debugPlugin.getBreakpointManager().addBreakpointListener(this); > EvaluationContextManager.startup(); >+ EvaluationContextManager2.startup(); > } > > /** >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.xml,v >retrieving revision 1.441 >diff -u -r1.441 plugin.xml >--- plugin.xml 13 Mar 2007 18:04:00 -0000 1.441 >+++ plugin.xml 13 Mar 2007 21:12:39 -0000 >@@ -113,32 +113,6 @@ > label="%JDTDebugActionSet.label" > visible="false" > id="org.eclipse.jdt.debug.ui.JDTDebugActionSet"> >- <menu >- label="%RunMenu.label" >- path="additions" >- id="org.eclipse.ui.run"> >- <separator >- name="jdtGroup"> >- </separator> >- </menu> >- <action >- definitionId="org.eclipse.jdt.debug.ui.commands.AddClassPrepareBreakpoint" >- label="%classPrepareAction.label" >- icon="$nl$/icons/full/obj16/class_obj.gif" >- helpContextId="add_class_prepare_action_context" >- class="org.eclipse.jdt.internal.debug.ui.breakpoints.AddClassPrepareBreakpointAction" >- menubarPath="org.eclipse.ui.run/breakpointGroup" >- id="org.eclipse.jdt.debug.ui.actions.AddClassPrepareBreakpoint"> >- </action> >- <action >- definitionId="org.eclipse.jdt.debug.ui.commands.AddExceptionBreakpoint" >- label="%exceptionAction.accel.label" >- icon="$nl$/icons/full/elcl16/exc_catch.gif" >- helpContextId="add_exception_action_context" >- class="org.eclipse.jdt.internal.debug.ui.breakpoints.AddExceptionAction" >- menubarPath="org.eclipse.ui.run/breakpointGroup" >- id="org.eclipse.jdt.debug.ui.actions.AddExceptionBreakpoint"> >- </action> > <action > definitionId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection" > label="%stepIntoSelectionAction.label" >@@ -158,6 +132,24 @@ > </objectClass> > </and> > </enablement> >+ </action> >+ <action >+ definitionId="org.eclipse.jdt.debug.ui.commands.AddClassPrepareBreakpoint" >+ label="%classPrepareAction.label" >+ icon="$nl$/icons/full/obj16/class_obj.gif" >+ helpContextId="add_class_prepare_action_context" >+ class="org.eclipse.jdt.internal.debug.ui.breakpoints.AddClassPrepareBreakpointAction" >+ menubarPath="org.eclipse.ui.run/breakpointGroup" >+ id="org.eclipse.jdt.debug.ui.actions.AddClassPrepareBreakpoint"> >+ </action> >+ <action >+ definitionId="org.eclipse.jdt.debug.ui.commands.AddExceptionBreakpoint" >+ label="%exceptionAction.accel.label" >+ icon="$nl$/icons/full/elcl16/exc_catch.gif" >+ helpContextId="add_exception_action_context" >+ class="org.eclipse.jdt.internal.debug.ui.breakpoints.AddExceptionAction" >+ menubarPath="org.eclipse.ui.run/breakpointGroup" >+ id="org.eclipse.jdt.debug.ui.actions.AddExceptionBreakpoint"> > </action> > <action > id="org.eclipse.jdt.debug.ui.actions.Execute" >@@ -2288,6 +2280,12 @@ > description="%ActionDefinition.breakpointproperties.description" > id="org.eclipse.jdt.debug.ui.breakpoint.properties" > name="%CommandDefinition.breakpointproperties.name"> >+ </command> >+ <command >+ categoryId="org.eclipse.debug.ui.category.run" >+ description="%Command.description.ForceReturn" >+ id="org.eclipse.jdt.debug.ui.commands.ForceReturn" >+ name="%Command.name.ForceReturn"> > </command> > </extension> > <extension point="org.eclipse.ui.bindings"> >@@ -2653,6 +2651,11 @@ > name="%ActionContext.breakpointsview.name" > parentId="org.eclipse.ui.contexts.window"> > </context> >+ <context >+ id="org.eclipse.jdt.debug.ui.evaluation" >+ name="Java Debug Expression Evaluation" >+ > >+ </context> > </extension> > <extension > point="org.eclipse.debug.ui.debugModelContextBindings"> >@@ -2982,6 +2985,30 @@ > </updater> > </extension> > <extension >+ point="org.eclipse.ui.menus"> >+ <menuContribution >+ locationURI="menu:org.eclipse.ui.run?after=profileGroup"> >+ <separator >+ name="jdtGroup" >+ visible="true"> >+ </separator> >+ </menuContribution> >+ <menuContribution >+ locationURI="menu:org.eclipse.debug.ui.DebugView?after=basic"> >+ <separator >+ name="javaActions" >+ visible="true"> >+ </separator> >+ </menuContribution> >+ <menuContribution >+ locationURI="menu:org.eclipse.ui.run?after=jdtGroup"> >+ <command >+ commandId="org.eclipse.jdt.debug.ui.commands.ForceReturn" >+ style="push"> >+ </command> >+ </menuContribution> >+ </extension> >+ <extension > point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors"> > <hyperlinkDetector > activate="true" >@@ -2993,5 +3020,47 @@ > targetId="org.eclipse.jdt.ui.javaCode"> > </hyperlinkDetector> > </extension> >+ <extension >+ point="org.eclipse.ui.handlers"> >+ <handler >+ class="org.eclipse.jdt.internal.debug.ui.evaluation.ForceReturnHandler" >+ commandId="org.eclipse.jdt.debug.ui.commands.ForceReturn"> >+ <activeWhen> >+ <with >+ variable="activePartId"> >+ <not> >+ <equals >+ value="org.eclipse.jdt.debug.ui.SnippetEditor"> >+ </equals> >+ </not> >+ </with> >+ </activeWhen> >+ <enabledWhen> >+ <and> >+ <with variable="activeContexts"> >+ <test >+ property="org.eclipse.jdt.debug.ui.contains" >+ value="org.eclipse.jdt.debug.ui.evaluation"> >+ </test> >+ </with> >+ <with variable="selection"> >+ <instanceof >+ value="org.eclipse.jface.text.ITextSelection"> >+ </instanceof> >+ </with> >+ </and> >+ </enabledWhen> >+ </handler> >+ </extension> >+ <extension >+ point="org.eclipse.core.expressions.propertyTesters"> >+ <propertyTester >+ class="org.eclipse.jdt.internal.debug.ui.evaluation.EvaluationPropertyTester" >+ id="org.eclipse.jdt.debug.ui.evaluationPropertyTester" >+ namespace="org.eclipse.jdt.debug.ui" >+ properties="contains" >+ type="java.lang.Object"> >+ </propertyTester> >+ </extension> > > </plugin> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/plugin.properties,v >retrieving revision 1.202 >diff -u -r1.202 plugin.properties >--- plugin.properties 13 Mar 2007 18:04:00 -0000 1.202 >+++ plugin.properties 13 Mar 2007 21:12:38 -0000 >@@ -29,6 +29,9 @@ > Display.label=Displa&y > Display.tooltip=Display Result of Evaluating Selected Text > >+Command.name.ForceReturn=&Force Return >+Command.description.ForceReturn=Returns the value of the selected expression from the current method >+ > editStepFiltersAction.label=Edit Ste&p Filters... > editStepFiltersAction.tooltip=Manage the set of defined step filters > >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.16 >diff -u -r1.16 MANIFEST.MF >--- META-INF/MANIFEST.MF 18 Sep 2006 15:26:39 -0000 1.16 >+++ META-INF/MANIFEST.MF 13 Mar 2007 21:12:39 -0000 >@@ -17,6 +17,7 @@ > org.eclipse.jdt.internal.debug.ui.console;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.contentassist;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.display;x-internal:=true, >+ org.eclipse.jdt.internal.debug.ui.evaluation;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.heapwalking;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.jres;x-internal:=true, > org.eclipse.jdt.internal.debug.ui.launcher;x-internal:=true, >Index: .options >=================================================================== >RCS file: .options >diff -N .options >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .options 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,2 @@ >+org.eclipse.jdt.debug.ui/debug=false >+org.eclipse.jdt.debug.ui/debug/evaluation/contextManager=false >Index: ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationContextManager2.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationContextManager2.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationContextManager2.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationContextManager2.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,232 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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.evaluation; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.contexts.DebugContextEvent; >+import org.eclipse.debug.ui.contexts.IDebugContextListener; >+import org.eclipse.debug.ui.contexts.IDebugContextProvider; >+import org.eclipse.jdt.debug.core.IJavaStackFrame; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchPartSite; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.contexts.IContextActivation; >+import org.eclipse.ui.contexts.IContextService; >+import org.eclipse.ui.progress.UIJob; >+ >+/** >+ * @since 3.3 >+ */ >+public class EvaluationContextManager2 implements IDebugContextListener { >+ >+ /** >+ * Context that is enabled when there is a valid context for performing >+ * an expression evaluation. >+ */ >+ private static final String EVALUATION_CONTEXT_ID = "org.eclipse.jdt.debug.ui.evaluation"; //$NON-NLS-1$ >+ >+ /** >+ * Debug flag for tracing information >+ */ >+ private static boolean DEBUG_EVALUATION_CONTEXT_MANAGER = false; >+ >+ static { >+ DEBUG_EVALUATION_CONTEXT_MANAGER = JDIDebugUIPlugin.DEBUG && "true".equals( //$NON-NLS-1$ >+ Platform.getDebugOption("org.eclipse.jdt.debug.ui/debug/evaluation/contextManager")); //$NON-NLS-1$ >+ } >+ >+ class UpdateJobFamily { >+ public UpdateJobFamily(IWorkbenchWindow window) { >+ fWindow = window; >+ } >+ public IWorkbenchWindow fWindow; >+ } >+ >+ class UpdateContextJob extends Job { >+ >+ private DebugContextEvent fEvent; >+ private IWorkbenchWindow fWindow; >+ >+ /** >+ * @param name >+ */ >+ public UpdateContextJob(DebugContextEvent event, IWorkbenchWindow window) { >+ super("Update expression evaluation context"); //$NON-NLS-1$ >+ fEvent = event; >+ fWindow = window; >+ setSystem(true); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) >+ */ >+ public boolean belongsTo(Object family) { >+ if (family instanceof UpdateJobFamily) { >+ UpdateJobFamily ujf = (UpdateJobFamily) family; >+ return ujf.fWindow.equals(fWindow); >+ } >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected IStatus run(IProgressMonitor monitor) { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("[Evaluation] Updating enablement"); //$NON-NLS-1$ >+ } >+ boolean activate = false; >+ if (!monitor.isCanceled()) { >+ ISelection context = fEvent.getContext(); >+ if (context instanceof IStructuredSelection) { >+ IStructuredSelection ss = (IStructuredSelection) context; >+ Object firstElement = ss.getFirstElement(); >+ if (firstElement instanceof IAdaptable) { >+ IAdaptable adaptable = (IAdaptable) firstElement; >+ Object adapter = adaptable.getAdapter(IJavaStackFrame.class); >+ if (adapter != null) { >+ // TODO: scrap book >+ activate = true; >+ } >+ } >+ } >+ } >+ IContextService service = (IContextService) fWindow.getService(IContextService.class); >+ if (service != null) { >+ if (activate) { >+ if (!service.getActiveContextIds().contains(EVALUATION_CONTEXT_ID)) { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("[Evaluation]\tSchedule activation"); //$NON-NLS-1$ >+ } >+ Job job = new PerformActivation(service); >+ job.schedule(); >+ } else { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("[Evaluation]\tStill enabled"); //$NON-NLS-1$ >+ } >+ } >+ } else { >+ IContextActivation activation = (IContextActivation) fActivations.remove(service); >+ if (activation != null) { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("[Evaluation]\tSchedule deactivation"); //$NON-NLS-1$ >+ } >+ Job job = new PerformDeactivation(activation); >+ job.schedule(); >+ } else { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("[Evaluation]\tStill deactivated"); //$NON-NLS-1$ >+ } >+ } >+ } >+ } >+ return Status.OK_STATUS; >+ } >+ >+ } >+ >+ /** >+ * Map of context activations per service >+ */ >+ private Map fActivations = new HashMap(); >+ >+ class PerformActivation extends UIJob { >+ >+ private IContextService fService; >+ >+ /** >+ * @param name >+ */ >+ public PerformActivation(IContextService service) { >+ super("Activate evaluation context"); //$NON-NLS-1$ >+ fService = service; >+ setSystem(true); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("[Evaluation] Activate " + EVALUATION_CONTEXT_ID); //$NON-NLS-1$ >+ } >+ IContextActivation activation = fService.activateContext(EVALUATION_CONTEXT_ID); >+ fActivations.put(fService, activation); >+ return Status.OK_STATUS; >+ } >+ >+ } >+ >+ class PerformDeactivation extends UIJob { >+ >+ private IContextActivation fActivation; >+ >+ /** >+ * @param name >+ */ >+ public PerformDeactivation(IContextActivation activation) { >+ super("Deactivate evaluation context"); //$NON-NLS-1$ >+ fActivation = activation; >+ setSystem(true); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ if (DEBUG_EVALUATION_CONTEXT_MANAGER) { >+ System.out.println("Evaluation] Deactivate " + EVALUATION_CONTEXT_ID); //$NON-NLS-1$ >+ } >+ fActivation.getContextService().deactivateContext(fActivation); >+ return Status.OK_STATUS; >+ } >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent) >+ */ >+ public void debugContextChanged(DebugContextEvent event) { >+ if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { >+ IDebugContextProvider provider = (IDebugContextProvider) event.getSource(); >+ IWorkbenchPart part = provider.getPart(); >+ if (part != null) { >+ IWorkbenchPartSite site = part.getSite(); >+ if (site != null) { >+ IWorkbenchWindow window = site.getWorkbenchWindow(); >+ if (window != null) { >+ Job.getJobManager().cancel(new UpdateJobFamily(window)); >+ Job job = new UpdateContextJob(event, window); >+ job.schedule(100); >+ } >+ } >+ } >+ } >+ } >+ >+ public static void startup() { >+ EvaluationContextManager2 manager = new EvaluationContextManager2(); >+ DebugUITools.getDebugContextManager().addDebugContextListener(manager); >+ } >+ >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/evaluation/ForceReturnHandler.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/evaluation/ForceReturnHandler.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/evaluation/ForceReturnHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/evaluation/ForceReturnHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,252 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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.evaluation; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.expressions.EvaluationContext; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.debug.core.DebugEvent; >+import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.model.ISourceLocator; >+import org.eclipse.debug.core.model.IStackFrame; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.debug.ui.contexts.IDebugContextService; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.Signature; >+import org.eclipse.jdt.debug.core.IJavaDebugTarget; >+import org.eclipse.jdt.debug.core.IJavaStackFrame; >+import org.eclipse.jdt.debug.core.IJavaThread; >+import org.eclipse.jdt.debug.core.JDIDebugModel; >+import org.eclipse.jdt.debug.eval.IEvaluationEngine; >+import org.eclipse.jdt.debug.eval.IEvaluationListener; >+import org.eclipse.jdt.debug.eval.IEvaluationResult; >+import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; >+import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; >+import org.eclipse.jdt.internal.debug.ui.actions.ActionMessages; >+import org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.text.ITextSelection; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.ISources; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * @since 3.3 >+ */ >+public class ForceReturnHandler extends AbstractHandler implements IEvaluationListener { >+ >+ public ForceReturnHandler() { >+ System.out.println("CREATED"); >+ System.out.println(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ ISelection selection = getSelection(event); >+ if (selection instanceof ITextSelection) { >+ ITextSelection textSelection = (ITextSelection) selection; >+ Object debugContext = getDebugContext(event); >+ if (debugContext instanceof IAdaptable) { >+ IJavaStackFrame frame = (IJavaStackFrame) ((IAdaptable)debugContext).getAdapter(IJavaStackFrame.class); >+ if (frame != null) { >+ IJavaThread thread = (IJavaThread) frame.getThread(); >+ IJavaDebugTarget target = (IJavaDebugTarget) frame.getDebugTarget(); >+ try { >+ String signature = frame.getSignature(); >+ String returnType = Signature.getReturnType(signature); >+ if (Signature.SIG_VOID.equals(returnType)) { >+ thread.forceReturn(target.voidValue()); >+ } else { >+ evaluate(textSelection.getText(), frame, this); >+ } >+ } catch (DebugException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ } >+ } >+ return null; >+ } >+ >+ public void dispose() { >+ System.out.println("DISPOSED"); >+ super.dispose(); >+ } >+ >+ /** >+ * Returns the active debug context for the given execution event. >+ * >+ * @param event execution event >+ * @return active debug context or <code>null</code> >+ */ >+ protected Object getDebugContext(ExecutionEvent event) { >+ Object context = event.getApplicationContext(); >+ if (context instanceof EvaluationContext) { >+ EvaluationContext ec = (EvaluationContext) context; >+ Object variable = ec.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); >+ if (variable instanceof IWorkbenchWindow) { >+ IWorkbenchWindow window = (IWorkbenchWindow) variable; >+ IDebugContextService contextService = DebugUITools.getDebugContextManager().getContextService(window); >+ ISelection debugContext = contextService.getActiveContext(); >+ if (debugContext instanceof IStructuredSelection) { >+ IStructuredSelection ss = (IStructuredSelection) debugContext; >+ return ss.getFirstElement(); >+ } >+ } >+ } >+ return null; >+ } >+ >+ /** >+ * Returns the current selection for the given execution event or <code>null</code>. >+ * >+ * @param event execution event >+ * @return current selection or <code>null</code> >+ */ >+ protected ISelection getSelection(ExecutionEvent event) { >+ Object context = event.getApplicationContext(); >+ if (context instanceof EvaluationContext) { >+ EvaluationContext ec = (EvaluationContext) context; >+ Object variable = ec.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME); >+ if (variable instanceof ISelection) { >+ return (ISelection)variable; >+ } >+ } >+ return null; >+ } >+ >+ protected void reportError(String message) { >+ Status status= new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, message, null); >+ JDIDebugUIPlugin.statusDialog(status); >+ } >+ >+ protected void evaluate(final String expression, final IJavaStackFrame frame, final IEvaluationListener listener) { >+ if (frame == null) { >+ reportError(ActionMessages.Evaluate_error_message_stack_frame_context); >+ return; >+ } >+ >+ // check for nested evaluation >+ IJavaThread thread = (IJavaThread)frame.getThread(); >+ if (thread.isPerformingEvaluation()) { >+ reportError(ActionMessages.EvaluateAction_Cannot_perform_nested_evaluations__1); >+ return; >+ } >+ >+ IRunnableWithProgress runnable = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ if (frame.isSuspended()) { >+ IJavaElement javaElement= getJavaElement(frame); >+ if (javaElement != null) { >+ IJavaProject project = javaElement.getJavaProject(); >+ IEvaluationEngine engine = null; >+ try { >+ engine = JDIDebugPlugin.getDefault().getEvaluationEngine(project, (IJavaDebugTarget)frame.getDebugTarget()); >+ boolean hitBreakpoints= JDIDebugModel.getPreferences().getBoolean(JDIDebugModel.PREF_SUSPEND_FOR_BREAKPOINTS_DURING_EVALUATION); >+ engine.evaluate(expression, frame, listener, DebugEvent.EVALUATION, hitBreakpoints); >+ return; >+ } catch (CoreException e) { >+ throw new InvocationTargetException(e, EvaluateAction.getExceptionMessage(e)); >+ } >+ } >+ throw new InvocationTargetException(null, ActionMessages.Evaluate_error_message_src_context); >+ } >+ // thread not suspended >+ throw new InvocationTargetException(null, ActionMessages.EvaluateAction_Thread_not_suspended___unable_to_perform_evaluation__1); >+ } >+ }; >+ >+ IWorkbench workbench = JDIDebugUIPlugin.getDefault().getWorkbench(); >+ try { >+ workbench.getProgressService().busyCursorWhile(runnable); >+ } catch (InvocationTargetException e) { >+ String message = e.getMessage(); >+ if (message == null) { >+ message = e.getClass().getName(); >+ if (e.getCause() != null) { >+ message = e.getCause().getClass().getName(); >+ if (e.getCause().getMessage() != null) { >+ message = e.getCause().getMessage(); >+ } >+ } >+ } >+ reportError(message); >+ } catch (InterruptedException e) { >+ } >+ } >+ >+ protected IJavaElement getJavaElement(IStackFrame stackFrame) { >+ >+ // Get the corresponding element. >+ ILaunch launch = stackFrame.getLaunch(); >+ if (launch == null) { >+ return null; >+ } >+ ISourceLocator locator= launch.getSourceLocator(); >+ if (locator == null) >+ return null; >+ >+ Object sourceElement = locator.getSourceElement(stackFrame); >+ if (sourceElement instanceof IJavaElement) { >+ return (IJavaElement) sourceElement; >+ } else if (sourceElement instanceof IResource) { >+ IJavaProject project = JavaCore.create(((IResource)sourceElement).getProject()); >+ if (project.exists()) { >+ return project; >+ } >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.debug.eval.IEvaluationListener#evaluationComplete(org.eclipse.jdt.debug.eval.IEvaluationResult) >+ */ >+ public void evaluationComplete(IEvaluationResult result) { >+ // if plug-in has shutdown, ignore - see bug# 8693 >+ if (JDIDebugUIPlugin.getDefault() == null) { >+ return; >+ } >+ final Display display= JDIDebugUIPlugin.getStandardDisplay(); >+ if (display.isDisposed()) { >+ return; >+ } >+ >+ if (result.hasErrors()) { >+ >+ } else { >+ try { >+ result.getThread().forceReturn(result.getValue()); >+ } catch (DebugException e) { >+ // TODO Auto-generated catch block >+ e.printStackTrace(); >+ } >+ } >+ } >+} >Index: ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationPropertyTester.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationPropertyTester.java >diff -N ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationPropertyTester.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/debug/ui/evaluation/EvaluationPropertyTester.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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.evaluation; >+ >+import java.util.Collection; >+ >+import org.eclipse.core.expressions.PropertyTester; >+ >+/** >+ * @since 3.3 >+ */ >+public class EvaluationPropertyTester extends PropertyTester { >+ >+ /** >+ * Tests for containment in a collection >+ */ >+ public static final String PROP_CONTAINS = "contains"; //$NON-NLS-1$ >+ >+ public EvaluationPropertyTester() { >+ } >+ >+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { >+ if (PROP_CONTAINS.equals(property)) { >+ if (receiver instanceof Collection) { >+ Collection collection = (Collection) receiver; >+ return collection.contains(expectedValue); >+ } >+ } >+ return false; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 150652
:
59181
|
59310
| 60733