Java 类org.eclipse.debug.core.model.IDebugElement 实例源码

项目:chromedevtools    文件:VariableBasedAction.java   
@Override public VariableWrapper castElement(Object element) {
  if (element instanceof Variable == false) {
    return null;
  }
  final Variable variable = (Variable) element;
  return new VariableWrapper() {
    @Override public Value getValue() {
      return variable.getValue().asRealValue();
    }
    @Override public Variable getVariable() {
      return variable;
    }
    @Override public IDebugElement getDebugElement() {
      return variable;
    }
    @Override public ConnectedTargetData getConnectedTargetData() {
      return variable.getConnectedData();
    }
  };
}
项目:chromedevtools    文件:JsInspectExpression.java   
public void handleDebugEvents(DebugEvent[] events) {
  for (DebugEvent event : events) {
    switch (event.getKind()) {
      case DebugEvent.TERMINATE:
        if (event.getSource().equals(getDebugTarget())) {
          DebugPlugin.getDefault().getExpressionManager().removeExpression(this);
        }
        break;
      case DebugEvent.SUSPEND:
        if (event.getDetail() != DebugEvent.EVALUATION_IMPLICIT &&
            event.getSource() instanceof IDebugElement) {
          IDebugElement source = (IDebugElement) event.getSource();
          if (source.getDebugTarget().equals(getDebugTarget())) {
            DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {
                new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT) });
          }
        }
        break;
    }
  }
}
项目:chromedevtools    文件:SynchronizeBreakpoints.java   
public static ConnectedTargetData getConnectionTargetData(Object element) {
  IDebugTarget debugTarget;
  if (element instanceof ILaunch) {
    ILaunch launch = (ILaunch) element;
    debugTarget = launch.getDebugTarget();
  } else if (element instanceof IDebugElement) {
    IDebugElement debugElement = (IDebugElement) element;
    debugTarget = debugElement.getDebugTarget();
  } else {
    return null;
  }
  if (debugTarget instanceof DebugTargetImpl == false) {
    return null;
  }
  DebugTargetImpl debugTargetImpl = (DebugTargetImpl) debugTarget;
  return debugTargetImpl.getConnectedOrNull();
}
项目:vebugger    文件:VisualDetailPane.java   
/**
 * 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);
        }
    }
}
项目:Pydev    文件:PyWatchExpressionDelegate.java   
@Override
public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
    this.expression = expression;
    this.context = context;
    this.listener = listener;
    if (context instanceof PyStackFrame) {

        AbstractDebugTarget target = (AbstractDebugTarget) context.getDebugTarget();
        if (target == null) {
            return; //disposed
        }

        // send the command, and then busy-wait
        EvaluateExpressionCommand cmd = new EvaluateExpressionCommand(target, expression, ((PyStackFrame) context)
                .getLocalsLocator().getPyDBLocation(), false);
        cmd.setCompletionListener(this);
        target.postCommand(cmd);

    } else {
        addError("unknown expression context");
        listener.watchEvaluationFinished(this);
    }
}
项目:chromedevtools    文件:DebugElementImpl.java   
@Override
public Object getAdapter(Class adapter) {
  if (adapter == IDebugElement.class) {
    return this;
  }
  return super.getAdapter(adapter);
}
项目:chromedevtools    文件:VariableBasedAction.java   
@Override
public VariableWrapper castElement(Object element) {
  if (element instanceof IWatchExpression == false) {
    return null;
  }
  final IWatchExpression watchExpression = (IWatchExpression) element;
  return new VariableWrapper() {
    @Override
    public Value getValue() {
      IValue value = watchExpression.getValue();
      if (value instanceof Value == false) {
        return null;
      }
      Value chromiumValue = (Value) value;
      return chromiumValue;
    }
    @Override public Variable getVariable() {
      return null;
    }
    @Override public IDebugElement getDebugElement() {
      return watchExpression;
    }
    @Override
    public ConnectedTargetData getConnectedTargetData() {
      IDebugTarget debugTarget = watchExpression.getDebugTarget();
      if (debugTarget instanceof DebugTargetImpl == false) {
        return null;
      }
      DebugTargetImpl debugTargetImpl = (DebugTargetImpl) debugTarget;
      return debugTargetImpl.getConnectedOrNull();
    }
  };
}
项目:birt    文件:ScriptDebugElement.java   
public Object getAdapter( Class adapter )
{
    if ( adapter == IDebugElement.class || adapter==ScriptDebugElement.class)
    {
        return this;
    }
    else if ( adapter == IDebugTarget.class )
    {
        return getDebugTarget( );
    }
    return super.getAdapter( adapter );
}
项目:birt    文件:ScriptRunToLineAdapter.java   
public boolean canRunToLine( IWorkbenchPart part, ISelection selection,
        ISuspendResume target )
{
    if ( target instanceof ScriptDebugElement )
    {
        IDebugElement element = (IDebugElement) target;
        ScriptDebugTarget adapter = (ScriptDebugTarget) element.getDebugTarget( )
                .getAdapter( IDebugTarget.class );
        return adapter != null;
    }
    return false;
}
项目:vebugger    文件:VisualDetailPane.java   
@Override
public void display(IStructuredSelection selection) {
    try {
        // Clear the text for now
        browser.setText("");

        if (!selection.isEmpty() || !(selection instanceof TreeSelection)) {

            Object firstElement = selection.getFirstElement();
            if (firstElement != null && firstElement instanceof IDebugElement) {

                IDebugElement element = (IDebugElement) firstElement;

                if (element instanceof IVariable) {
                    displayVariable(selection, element);
                } else if (element instanceof IExpression) {
                    displayExpression(element);
                } else {
                    // FIXME we don't treat other selection types yet
                    throw new DebugException(null);
                }

            }
        }
    } catch (DebugException e) {
        setBrowserTextToString("Could not parse " + selection + "\n\n<pre>" + e.getMessage() + "</pre>", "Error");
        e.printStackTrace();
    }
}
项目:vebugger    文件:VisualDetailPane.java   
/**
 * Render a watch expression.
 * 
 * FIXME we don't treat watch expression yet, this will just render their
 * {@link String} value.
 * 
 * @param element
 *            the expression element
 */
private void displayExpression(IDebugElement element) {
    IValue value = ((IExpression) element).getValue();
    if (value instanceof IJavaPrimitiveValue) {
        setBrowserTextToPrimitive((IJavaPrimitiveValue) value);
    } else if (value instanceof IJavaObject) {
        setBrowserTextToString(value.toString());
    } else if (value != null) {
        setBrowserTextToString(value.toString(), "Error!");
    }
}
项目:chromedevtools    文件:JsWatchExpressionDelegate.java   
public void evaluateExpression(final String expression, final IDebugElement context,
    final IWatchExpressionListener listener) {
  final DebugElementImpl contextImpl = (DebugElementImpl) context;
  if (!contextImpl.getDebugTarget().isSuspended()) {
    // can only evaluate while suspended. Notify empty result.
    listener.watchEvaluationFinished(new IWatchExpressionResult() {

      public String[] getErrorMessages() {
        return EMPTY_STRINGS;
      }

      public DebugException getException() {
        return null;
      }

      public String getExpressionText() {
        return expression;
      }

      public IValue getValue() {
        return null;
      }

      public boolean hasErrors() {
        return false;
      }
    });
    return;
  }

  final EvaluateContext evaluateContext =
      (EvaluateContext) contextImpl.getAdapter(EvaluateContext.class);
  if (evaluateContext == null) {
    listener.watchEvaluationFinished(new BadWatchExpressionResult(
        new DebugException(new Status(Status.ERROR,
            ChromiumDebugUIPlugin.PLUGIN_ID,"Bad debug context")), //$NON-NLS-1$
        expression));
    return;
  }

  evaluateContext.getJsEvaluateContext().evaluateAsync(
      expression, null,
      new JsEvaluateContext.EvaluateCallback() {
        @Override
        public void success(ResultOrException result) {
          ValueBase valueBase = result.accept(new ResultOrException.Visitor<ValueBase>() {
            @Override public ValueBase visitResult(JsValue value) {
              return Value.create(evaluateContext, value,
                  ExpressionTracker.createExpressionNode(expression));
            }
            @Override
            public ValueBase visitException(JsValue exception) {
              return new ValueBase.ErrorMessageValue(evaluateContext, "<abnormal return>",
                  exception);
            }
          });
          listener.watchEvaluationFinished(new GoodWatchExpressionResult(valueBase, expression));
        }

        @Override
        public void failure(Exception cause) {
          String message = cause.getMessage();
          listener.watchEvaluationFinished(new BadWatchExpressionResult(new DebugException(
              createErrorStatus(message == null
                  ? Messages.JsWatchExpressionDelegate_ErrorEvaluatingExpression
                  : message, null)), expression));
          return;
        }
      },
      null);
}
项目:chromedevtools    文件:VariableBasedAction.java   
IDebugElement getDebugElement();