public Object getAdapter(Class adapter) { AdapterDebug.print(this, adapter); if (adapter.equals(ILaunch.class)) { return target.getAdapter(adapter); } else if (adapter.equals(org.eclipse.debug.ui.actions.IRunToLineTarget.class)) { return this.target.getRunToLineTarget(); } else if (adapter.equals(IPropertySource.class) || adapter.equals(ITaskListResourceAdapter.class) || adapter.equals(org.eclipse.ui.IContributorResourceAdapter.class) || adapter.equals(org.eclipse.ui.IActionFilter.class) || adapter.equals(org.eclipse.ui.model.IWorkbenchAdapter.class) || adapter.equals(org.eclipse.debug.ui.actions.IToggleBreakpointsTarget.class) || adapter.equals(IResource.class) || adapter.equals(org.eclipse.core.resources.IFile.class)) return super.getAdapter(adapter); // ongoing, I do not fully understand all the interfaces they'd like me to support // so I print them out as errors if (adapter.equals(IDeferredWorkbenchAdapter.class)) { 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); }
/** Gets the completions at the passed offset. */ public ICompletionProposal[] getCompletions(String text, String actTok, int offset) throws Exception { this.text = text; this.actTok = actTok; this.offset = offset; PyStackFrame stackFrame = getCurrentSuspendedPyStackFrame(null); if (stackFrame != null) { AbstractDebugTarget target = (AbstractDebugTarget) stackFrame.getAdapter(IDebugTarget.class); if (target != null) { GetCompletionsCommand cmd = new GetCompletionsCommand( target, actTok, stackFrame.getLocalsLocator().getPyDBLocation()); cmd.setCompletionListener(this); target.postCommand(cmd); } return waitForCommand(); } return EMPTY_COMPLETION_PROPOSALS; }
/** * @return the currently selected / suspended frame. If the console is passed, it will only return * a frame that matches the passed console. If no selected / suspended frame is found or the * console doesn't match, null is returned. */ protected static PyStackFrame getCurrentSuspendedPyStackFrame(IConsole console) { IAdaptable context = DebugUITools.getDebugContext(); if (context instanceof PyStackFrame) { PyStackFrame stackFrame = (PyStackFrame) context; if (!stackFrame.isTerminated() && stackFrame.isSuspended()) { if (console != null) { // If a console is passed, we must check if it matches the console from the selected // frame. AbstractDebugTarget target = (AbstractDebugTarget) stackFrame.getAdapter(IDebugTarget.class); if (DebugUITools.getConsole(target.getProcess()) != console) { return null; } } return stackFrame; } } return null; }
public ILaunch getLaunch() { return target.getLaunch(); }
public String getModelIdentifier() { return target.getModelIdentifier(); }
/** * This method is called when some value has to be changed to some other expression. * * <p>Note that it will (currently) only work for changing local values that are in the topmost * frame. -- python has no way of making it work right now (see: pydevd_vars.changeAttrExpression) */ public void setValue(String expression) throws DebugException { ChangeVariableCommand changeVariableCommand = getChangeVariableCommand(target, expression); target.postCommand(changeVariableCommand); this.value = expression; target.fireEvent(new DebugEvent(this, DebugEvent.CONTENT | DebugEvent.CHANGE)); }