org.eclipse.debug.core.model.IValue Java Examples

The following examples show how to use org.eclipse.debug.core.model.IValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScriptModelPresentation.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the expression display name
 * 
 * @param expression
 * @return
 * @throws DebugException
 */
private String getExpressionText( IExpression expression )
		throws DebugException
{
	StringBuffer buff = new StringBuffer( );
	IValue javaValue = expression.getValue( );

	buff.append( '"' + expression.getExpressionText( ) + '"' );

	if ( javaValue != null )
	{
		String valueString = getValueText( javaValue );
		if ( valueString.length( ) > 0 )
		{
			buff.append( "= " ); //$NON-NLS-1$
			buff.append( valueString );
		}
	}
	return buff.toString( );
}
 
Example #2
Source File: PyWatchExpressionDelegate.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void commandComplete(AbstractDebuggerCommand cmd) {
    try {
        String payload = ((EvaluateExpressionCommand) cmd).getResponse();
        PyVariable[] variables = XMLUtils.XMLToVariables((AbstractDebugTarget) context.getDebugTarget(),
                ((PyStackFrame) context).getExpressionLocator(), payload);
        IValue value = newValue(variables);
        synchronized (sync) {
            this.value = value;
        }

    } catch (CoreException e) {
        addError("Evaluation of " + this.getExpressionText() + " failed: " + e.getMessage());
        PydevDebugPlugin.log(IStatus.ERROR, "Error fetching a variable", e);
    }

    listener.watchEvaluationFinished(this);
}
 
Example #3
Source File: ScriptModelPresentation.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void computeDetail( IValue value, IValueDetailListener listener )
{
	// show the string when mouse hover at the value in the watch view.
	String detail = ""; //$NON-NLS-1$
	try
	{
		detail = value.getValueString( );
	}
	catch ( DebugException e )
	{
	}
	listener.detailComputed( value, detail );
}
 
Example #4
Source File: EvalExpressionAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    });
}
 
Example #5
Source File: PyDebugModelPresentation.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * We've got some work to do to replicate here, because we can't return null, and have LazyModel presentation do the
 * default
 */
@Override
public void computeDetail(IValue value, IValueDetailListener listener) {
    if (value instanceof PyVariable) {
        try {
            ((PyVariable) value).getVariables();
            listener.detailComputed(value, ((PyVariable) value).getDetailText());
        } catch (DebugException e) {
            PydevDebugPlugin.errorDialog("Unexpected error fetching variable", e);
        }
    }
}
 
Example #6
Source File: PyWatchExpressionDelegate.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getValueString() throws DebugException {
    boolean first = true;
    StringBuilder sb = new StringBuilder().append("{");
    for (IVariable variable : variables) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        IValue val = variable.getValue();
        sb.append(variable.getName()).append(": ").append(val == null ? "<error>" : val.getValueString());
    }
    return sb.append("}").toString();
}
 
Example #7
Source File: PyWatchExpressionDelegate.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private IValue newValue(PyVariable[] variables) {
    if (null == variables || variables.length == 0) {
        addError("Evaluation of " + this.getExpressionText() + " failed: no variables.");
        return null; // see #getValue(), implies evaluation failure.
    }
    if (variables.length == 1) {
        return variables[0];
    }
    return new WatchExpressionValue(this.context, variables);
}
 
Example #8
Source File: CurrentExceptionViewContentProvider.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean hasChildren(Object element) {
    if (element instanceof List) {
        List list = (List) element;
        return list.size() > 0;
    }
    if (element instanceof IValue) {
        try {
            return ((IValue) element).hasVariables();
        } catch (DebugException e) {
            Log.log(e);
        }
    }
    return true;
}
 
Example #9
Source File: ScriptModelPresentation.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param value
 * @return
 * @throws DebugException
 */
private String getValueText( IValue value ) throws DebugException
{

	String refTypeName = value.getReferenceTypeName( );
	String valueString = value.getValueString( );
	boolean isString = false;

	// boolean isObject = true;
	// boolean isArray = value instanceof IJavaArray;
	StringBuffer buffer = new StringBuffer( );
	// Always show type name for objects & arrays (but not Strings)
	if ( !isString && ( refTypeName.length( ) > 0 ) )
	{
		String qualTypeName = refTypeName;
		buffer.append( qualTypeName );
		buffer.append( ' ' );

	}

	// Put double quotes around Strings
	if ( valueString != null && ( isString || valueString.length( ) > 0 ) )
	{
		if ( isString )
		{
			buffer.append( '"' );
		}
		buffer.append( valueString );
		if ( isString )
		{
			buffer.append( '"' );
		}
	}

	return buffer.toString( );
}
 
Example #10
Source File: ScriptVariable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public boolean verifyValue( IValue value ) throws DebugException
{
	return false;
}
 
Example #11
Source File: PyVariable.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IValue getValue() throws DebugException {
    return this;
}
 
Example #12
Source File: PyVariable.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void setValue(IValue value) throws DebugException {
}
 
Example #13
Source File: PyVariable.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean verifyValue(IValue value) throws DebugException {
    return false;
}
 
Example #14
Source File: PyWatchExpressionDelegate.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IValue getValue() {
    synchronized (sync) {
        return value;
    }
}
 
Example #15
Source File: ScriptVariable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void setValue( IValue value ) throws DebugException
{
	// don't support
}
 
Example #16
Source File: ScriptVariable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IValue getValue( ) throws DebugException
{
	return value;
}
 
Example #17
Source File: ScriptVariable.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**Sets the ori value
 * @param value
 */
public void setOriVale( IValue value )
{
	this.value = value;
}
 
Example #18
Source File: CloudSdkDebugTargetPresentation.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void computeDetail(IValue value, IValueDetailListener listener) {
}