[Pydev-cvs] org.python.pydev.debug/src/org/python/pydev/debug/model PyVariableContentProviderHack.j
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-08-13 21:12:16
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8481/src/org/python/pydev/debug/model Modified Files: AbstractDebugTarget.java PyVariable.java Added Files: PyVariableContentProviderHack.java Log Message: Synching from mercurial: - Pydev debugger watch working in eclipse 3.4 - Pydev debugger breakpoint properties accept new lines and tabs - Incremental find backspace works correctly - Interactive console Fixed problem when more attempts to connect were needed - Launch icons: Transparent background (thanks to Radim Kubacki) - Creating workbench test for debugger Index: AbstractDebugTarget.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/AbstractDebugTarget.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractDebugTarget.java 9 May 2008 22:00:58 -0000 1.15 --- AbstractDebugTarget.java 13 Aug 2008 21:12:24 -0000 1.16 *************** *** 36,39 **** --- 36,40 ---- import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter; import org.python.pydev.core.ExtensionHelper; + import org.python.pydev.core.docutils.StringUtils; import org.python.pydev.core.log.Log; import org.python.pydev.debug.core.IConsoleInputListener; *************** *** 207,211 **** PyBreakpoint b = (PyBreakpoint)breakpoint; if (b.isEnabled() && !shouldSkipBreakpoints()) { ! SetBreakpointCommand cmd = new SetBreakpointCommand(debugger, b.getFile(), b.getLine(), b.getCondition(), b.getFunctionName()); debugger.postCommand(cmd); } --- 208,217 ---- PyBreakpoint b = (PyBreakpoint)breakpoint; if (b.isEnabled() && !shouldSkipBreakpoints()) { ! String condition = b.getCondition(); ! if(condition != null){ ! condition = StringUtils.replaceAll(condition, "\n", "@_@NEW_LINE_CHAR@_@"); ! condition = StringUtils.replaceAll(condition, "\t", "@_@TAB_CHAR@_@"); ! } ! SetBreakpointCommand cmd = new SetBreakpointCommand(debugger, b.getFile(), b.getLine(), condition, b.getFunctionName()); debugger.postCommand(cmd); } --- NEW FILE: PyVariableContentProviderHack.java --- package org.python.pydev.debug.model; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.core.model.IWatchExpression; import org.eclipse.debug.internal.ui.model.elements.VariableContentProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; /** * This class was created to bypass bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=238878 * * It should be removed when it's actually fixed. * @author Fabio */ public class PyVariableContentProviderHack extends VariableContentProvider{ protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { if(element instanceof IWatchExpression){ IWatchExpression watchExpression = (IWatchExpression) element; return super.hasChildren(watchExpression.getValue(), context, monitor); } if(element instanceof PyVariableCollection){ PyVariableCollection pyVariableCollection = (PyVariableCollection) element; return pyVariableCollection.hasVariables(); } return super.hasChildren(element, context, monitor); } @Override protected Object[] getAllChildren(Object parent, IPresentationContext context) throws CoreException { if(parent instanceof IWatchExpression){ IWatchExpression watchExpression = (IWatchExpression) parent; return super.getAllChildren(watchExpression.getValue(), context); } if(parent instanceof PyVariableCollection){ PyVariableCollection pyVariableCollection = (PyVariableCollection) parent; return pyVariableCollection.getVariables(); } return super.getAllChildren(parent, context); } } Index: PyVariable.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyVariable.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyVariable.java 10 Apr 2008 16:15:59 -0000 1.14 --- PyVariable.java 13 Aug 2008 21:12:24 -0000 1.15 *************** *** 14,17 **** --- 14,18 ---- import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IVariable; + import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider; import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; import org.eclipse.ui.views.properties.IPropertySource; *************** *** 149,152 **** --- 150,159 ---- return new DeferredWorkbenchAdapter(this); } + + //cannot check for the actual interface because it may not be available on eclipse 3.2 (it's only available + //from 3.3 onwards... and this is only a hack for it to work with eclipse 3.4) + if(adapter.toString().endsWith("org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider")){ + return new PyVariableContentProviderHack(); + } AdapterDebug.printDontKnow(this, adapter); return super.getAdapter(adapter); |