public void evaluate(String expression, InvocationResult listener) { IExpressionManager expressionManager = DebugPlugin.getDefault().getExpressionManager(); StackFrameModel stackFrame = getTopFrame(); IWatchExpressionDelegate delegate = expressionManager.newWatchExpressionDelegate(stackFrame.getStackFrame().getModelIdentifier()); delegate.evaluateExpression(expression, stackFrame.getStackFrame(), new IWatchExpressionListener() { public void watchEvaluationFinished(IWatchExpressionResult result) { listener.valueReturn(result.getValue()); // setChanged(); // notifyObservers(new Event<IStackFrameModel>(Event.Type.EVALUATION, getTopFrame())); // try { // evaluationNotify(); // } catch (DebugException e) { // e.printStackTrace(); // } } }); }
public void invoke(String methodName, InvocationResult listener, String ... args) { IExpressionManager expressionManager = DebugPlugin.getDefault().getExpressionManager(); StackFrameModel stackFrame = getRuntimeModel().getTopFrame(); IWatchExpressionDelegate delegate = expressionManager.newWatchExpressionDelegate(stackFrame.getStackFrame().getModelIdentifier()); // List<String> refPaths = getRuntimeModel().findReferencePaths(this); // if(refPaths.isEmpty()) // return; ReferencePath refPath = getRuntimeModel().findReferencePaths(this); if(refPath == null) return; // String exp = refPaths.get(0) + "." + methodName + "(" + String.join(", ", args) + ")"; String exp = refPath.referencePath + "." + methodName + "(" + String.join(", ", args) + ")"; // IStackFrame context = getRuntimeModel().getFirstVisibleFrame().getStackFrame(); delegate.evaluateExpression(exp, refPath.context, new ExpressionListener(exp, listener)); }
/** * Render a selected variable. * * @param selection * the selection object * @param element * the variable element * @throws DebugException */ private void displayVariable(IStructuredSelection selection, IDebugElement element) throws DebugException { IValue value = ((IVariable) element).getValue(); if (value instanceof IJavaPrimitiveValue) { setBrowserTextToPrimitive((IJavaPrimitiveValue) value); } else { TreePath firstElementTreePath = ((TreeSelection) selection).getPaths()[0]; String watchExpression = generateWatchExpression(firstElementTreePath); String messageExpression = generateMessageExpression(watchExpression); // Iterate all threads and run our rendering // expression in them in the hopes that we can find // the relevant selection in only one thread // FIXME find a better way to derive the correct thread! IWatchExpressionDelegate delegate = DebugPlugin.getDefault().getExpressionManager() .newWatchExpressionDelegate(element.getModelIdentifier()); for (IThread thread : element.getDebugTarget().getThreads()) { delegate.evaluateExpression(messageExpression, thread, this); } } }