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

The following examples show how to use org.eclipse.debug.core.model.IVariable. 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: JavaDebugElementCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected RGB getRGB(IVariable variable) throws DebugException {
	IJavaValue v = (IJavaValue) variable.getValue();
	if ("org.eclipse.swt.graphics.RGB".equals(v.getJavaType().toString())) {
		Integer red = null, blue = null, green = null;
		for (IVariable field : v.getVariables()) {
			if ("red".equals(field.getName().toString())) {
				red = Integer.parseInt(field.getValue().getValueString());
			} else if ("green".equals(field.getName().toString())) {
				green = Integer.parseInt(field.getValue().getValueString());
			} else if ("blue".equals(field.getName().toString())) {
				blue = Integer.parseInt(field.getValue().getValueString());
			}
		}
		if (red != null && green != null && blue != null) {
			return new RGB(red, green, blue);
		}
	}
	return null;
}
 
Example #2
Source File: ReferrersViewContentProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean hasChildren(Object element) {
    try {
        if (element instanceof XMLToReferrersInfo) {
            return true;
        }
        if (element instanceof IVariable) {
            Object[] objects = childrenCache.get(element);
            if (objects != null && objects.length > 0) {
                return true;
            }
            IVariable iVariable = (IVariable) element;
            return iVariable.getValue().hasVariables();
        }
    } catch (Exception e) {
        Log.log(e);
    }
    return false;

}
 
Example #3
Source File: ContainerOfVariables.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
PyVariable[] setVariables(PyVariable[] newVars) {
    IVariable[] oldVars = this.variables;
    if (newVars == oldVars) {
        return newVars;
    }
    IVariablesContainerParent p = this.parent.get();
    if (p == null) {
        return newVars;
    }
    this.variables = newVars;
    AbstractDebugTarget target = p.getTarget();

    if (!gettingInitialVariables && target != null) {
        RunInUiThread.async(() -> {
            target.fireEvent(new DebugEvent(p, DebugEvent.CHANGE, DebugEvent.CONTENT));
        });
    }
    return newVars;
}
 
Example #4
Source File: ContainerOfVariables.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public IVariable[] getVariables() throws DebugException {
    if (onAskGetNewVars) {
        synchronized (lock) {
            //double check idiom for accessing onAskGetNewVars.
            if (onAskGetNewVars) {
                gettingInitialVariables = true;
                try {
                    PyVariable[] vars = variablesLoader.fetchVariables();

                    setVariables(vars);
                    // Important: only set to false after variables have been set.
                    onAskGetNewVars = false;
                } finally {
                    gettingInitialVariables = false;
                }
            }
        }
    }
    return this.variables;
}
 
Example #5
Source File: AbstractDebugVariableCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Update the debug mining label with the debug variable value.
 *
 * @param variableName the variable name
 */
private void updateLabel(String variableName) {
	try {
		IVariable variable = findVariable(variableName);
		if (variable != null) {
			fRgb = getRGB(variable);
			super.setLabel(DebugElementHelper.getLabel(variable));
		} else {
			super.setLabel(""); //$NON-NLS-1$
		}
	} catch (DebugException e) {
		super.setLabel(""); //$NON-NLS-1$
	}
}
 
Example #6
Source File: PyWatchExpressionDelegate.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IVariable[] getVariables() throws DebugException {
    if (hasVariables()) {
        return Arrays.copyOf(variables, variables.length);
    }
    return PyVariable.EMPTY_IVARIABLE_ARRAY;
}
 
Example #7
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 #8
Source File: DebuggerTestWorkbench.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void run() {
    try {
        currentStep = "launchEditorInDebug";
        //make a launch for debugging 
        debuggerTestUtils.launchEditorInDebug();

        //switch to debug perspective, because otherwise, when we hit a breakpoint it'll ask if we want to show it.
        debuggerTestUtils.switchToPerspective("org.eclipse.debug.ui.DebugPerspective");
        PyBreakpointRulerAction createAddBreakPointAction = debuggerTestUtils.createAddBreakPointAction(
                1);
        createAddBreakPointAction.run();

        currentStep = "waitForLaunchAvailable";
        ILaunch launch = debuggerTestUtils.waitForLaunchAvailable();
        PyDebugTarget target = (PyDebugTarget) debuggerTestUtils.waitForDebugTargetAvailable(launch);

        currentStep = "waitForSuspendedThread";
        IThread suspendedThread = debuggerTestUtils.waitForSuspendedThread(target);
        assertTrue(suspendedThread.getName().startsWith("MainThread"));
        IStackFrame topStackFrame = suspendedThread.getTopStackFrame();
        assertTrue("Was not expecting: " + topStackFrame.getName(),
                topStackFrame.getName().indexOf("debug_file.py:2") != 0);
        IVariable[] variables = topStackFrame.getVariables();

        HashSet<String> varNames = new HashSet<String>();
        for (IVariable variable : variables) {
            PyVariable var = (PyVariable) variable;
            varNames.add(var.getName());
        }
        HashSet<String> expected = new HashSet<String>();
        expected.add("Globals");
        expected.add("__doc__");
        expected.add("__file__");
        expected.add("__name__");
        expected.add("mod1");
        assertEquals(expected, varNames);

        assertTrue(target.canTerminate());
        target.terminate();

        finished = true;
    } catch (Throwable e) {
        debuggerTestUtils.failException = e;
    }
}
 
Example #9
Source File: PyVariableCollection.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IVariable[] getVariables() throws DebugException {
    return this.variableContainer.getVariables();
}
 
Example #10
Source File: PyStackFrame.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IVariable[] getVariables() throws DebugException {
    return variableContainer.getVariables();
}
 
Example #11
Source File: PyWatchExpressionDelegate.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public WatchExpressionValue(IDebugElement context, IVariable[] variables) {
    super(context.getDebugTarget());
    this.variables = variables;
}
 
Example #12
Source File: PyVariableGroup.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IVariable[] getVariables() throws DebugException {
    return this.variables;
}
 
Example #13
Source File: PyVariable.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IVariable[] getVariables() throws DebugException {
    return EMPTY_IVARIABLE_ARRAY;
}
 
Example #14
Source File: ContainerOfVariables.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public IVariable[] getInternalVariables() {
    return this.variables;
}
 
Example #15
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Gets the variables from the stack frame.
 * 
 * @param frame
 * @return
 */
public IVariable[] getVariables( ScriptStackFrame frame )
{
	VMVariable[] variables;
	try
	{
		VMStackFrame fm = reportVM.getStackFrame( frame.getIdentifier( ) );

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

		variables = fm.getVariables( );

		IVariable[] retValue = new IVariable[variables.length];

		for ( int i = 0; i < variables.length; i++ )
		{
			VMVariable variable = variables[i];
			ScriptVariable debugVariable = new ScriptVariable( frame,
					variable.getName( ),
					variable.getTypeName( ) );

			VMValue value = variable.getValue( );

			ScriptValue debugValue = new ScriptValue( frame, value );

			debugVariable.setOriVale( debugValue );

			retValue[i] = debugVariable;

		}

		return retValue;
	}
	catch ( VMException e )
	{
		logger.warning( e.getMessage( ) );
	}
	return null;
}
 
Example #16
Source File: ScriptStackFrame.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public IVariable[] getVariables( ) throws DebugException
{
	return ( (ScriptDebugTarget) getDebugTarget( ) ).getVariables( this );
}
 
Example #17
Source File: JavaDebugElementCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected IVariable findVariable(String variableName) throws DebugException {
	return getStackFrame().findVariable(variableName);
}
 
Example #18
Source File: AbstractDebugVariableCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the debug variable from the given name and <code>null</code>
 * otherwise.
 *
 * @param variableName the variable name.
 * @return the debug variable from the given variable name and <code>null</code>
 *         otherwise.
 * @throws DebugException
 */
protected abstract IVariable findVariable(String variableName) throws DebugException;
 
Example #19
Source File: AbstractDebugVariableCodeMining.java    From jdt-codemining with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the rgb value of the given variable and <code>null</code> otherwise.
 *
 * @param variable the debug variable.
 * @return the rgb value of the given variable and <code>null</code> otherwise.
 * @throws DebugException
 */
protected RGB getRGB(IVariable variable) throws DebugException {
	return null;
}