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

项目: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();
    }
  };
}
项目:chromedevtools    文件:DialogLogic.java   
@Override
public void run() {
  Expression.SetCallback callback = new Expression.SetCallback() {
    @Override
    public void done(final String errorMessage) {
      if (errorMessage == null) {
        if (addWatchExpression) {
          IExpressionManager expressionManager =
              DebugPlugin.getDefault().getExpressionManager();
          IWatchExpression watchExpression =
              expressionManager.newWatchExpression(expression.getWatchExpression());
          expressionManager.addExpression(watchExpression);
        }
      } else {
        parentShell.getDisplay().asyncExec(new Runnable() {
          @Override
          public void run() {
            MessageBox messageBox = new MessageBox(parentShell);
            messageBox.setText(Messages.LogicImpl_RESULT_FAILURE_TITLE);
            messageBox.setMessage(errorMessage);
            messageBox.open();
          }
        });
      }
    }
  };

  expression.execute(previewContext, callback);
}
项目:chromedevtools    文件:WatchPropertyDescriptor.java   
@Override
protected Runnable createRunnable(VariableWrapper wrapper) {
  if (wrapper == null) {
    return null;
  }
  Variable variable = wrapper.getVariable();
  if (variable == null) {
    return null;
  }

  Variable.Real realVariable = variable.asRealVariable();

  if (realVariable == null) {
    return null;
  }

  final JsVariable jsVariable = realVariable.getJsVariable();

  final String qualifiedName = realVariable.createHolderWatchExpression();
  if (qualifiedName == null) {
    return null;
  }

  return new Runnable() {
    @Override
    public void run() {
      String expression = "Object.getOwnPropertyDescriptor(" + qualifiedName + ", \"" +
          jsVariable.getName() + "\")";

      IExpressionManager expressionManager = DebugPlugin.getDefault().getExpressionManager();
      IWatchExpression watchExpression = expressionManager.newWatchExpression(expression);
      expressionManager.addExpression(watchExpression);
    }
  };
}
项目:Pydev    文件:PyVariableContentProviderHack.java   
@Override
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);
}
项目:Pydev    文件:PyVariableContentProviderHack.java   
@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);
}
项目:Pydev    文件:EvalExpressionAction.java   
/**
 * This hack just creates a Watch expression, gets result and removes the watch expression. 
 * This is simple, since the watch functionality is already there.
 * 
 * @see WatchExpressionAction#createExpression
 */
private void eval(final String expr) {
    final IWatchExpression expression = createWatchExpression(expr);

    final Shell shell = PydevDebugPlugin.getActiveWorkbenchWindow().getShell();
    Display display = PydevDebugPlugin.getDefault().getWorkbench().getDisplay();
    final Point point = display.getCursorLocation();

    Display.getDefault().asyncExec(new Runnable() {
        @Override
        public void run() {
            expression.evaluate();
            waitForExpressionEvaluation(expression);
            try {
                IValue value = expression.getValue();
                String result = null;
                if (value != null) {
                    result = expr + "\n" + value.getValueString();
                    DisplayPopup popup = new DisplayPopup(shell, point, result);
                    popup.open();
                }
            } catch (DebugException e) {
                DebugPlugin.log(e);
                return;
            } catch (Throwable t) {
                DebugPlugin.log(t);
            }
        }
    });
}
项目:watchdog    文件:DebugEventListener.java   
private static boolean isWatchExpression(Object source) {
    return source instanceof IWatchExpression;
}