[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[Dltk-dev] The Console plugins..
|
Hi,
i quickly build my own scripting console where you can just execute (eval) strings to a running debug session (if a break point is hit)
But i also looked at the org.eclipse.dltk.console.* plugins
But that thing completely doesnt work for me at alle (and i get null pointer errors) because at first it tries to do this:
private _javascript_Console createConsoleInstance(IScriptInterpreter interpreter, String id) {
if (interpreter == null) {
try {
id = "default";
interpreter = new _javascript_Interpreter();
// _javascript_ConsoleUtil
// .runDefaultTclInterpreter((_javascript_Interpreter) interpreter);
} catch (Exception e) {
return null;
}
}
return makeConsole((_javascript_Interpreter) interpreter, id);
}
And then the 2 lines that are commented now..
in that call this happens:
ScriptConsoleServer server = ScriptConsoleServer.getInstance();
String id = server.register(interpreter);
String port = Integer.toString(server.getPort());
String[] args = new String[] { "
127.0.0.1", port, id };
// TODO: Add environments support
IExecutionEnvironment exeEnv = (IExecutionEnvironment) EnvironmentManager
.getLocalEnvironment().getAdapter(IExecutionEnvironment.class);
IFileHandle scriptFile = _javascript_LaunchingPlugin.getDefault()
.getConsoleProxy(exeEnv);
ScriptLaunchUtil.runScript(_javascript_Nature.NATURE_ID, scriptFile,
null, null, args, null);
but that is really not working for our case..
Because that just tries to run a script.. That cant happen for us because our scripts are already running in a rhino debug environment (remotely)
So my question is why is it this way? Why isnt it just connection to the active suspended IScriptThread/ScriptFrame ?
i just do it in one simple method:
private String execute(String txt)
{
IScriptThread scriptThread = getActiveScriptThread();
if (scriptThread != null)
{
IScriptStackFrame frame = null;
try
{
IStackFrame[] stackFrames = scriptThread.getStackFrames();
if (stackFrames.length == 0) return null;
frame = (IScriptStackFrame) stackFrames[stackFrames.length-1];
}
catch (DebugException ex1)
{
ex1.printStackTrace();
}
IScriptEvaluationResult syncEvaluate = scriptThread.getEvaluationEngine().syncEvaluate(txt, frame);
if (syncEvaluate.getValue() != null)
{
try
{
return syncEvaluate.getValue().getValueString();
}
catch (DebugException ex)
{
return ex.toString();
}
}
return syncEvaluate.getException().toString();
}
return null;
}
and that works great.. Through the dbgp protocol and debug connection..
But i get a very itchy feeling now that for many parts i am now duplicating code :( (History/Code completion)
So why does the current ScriptConsole implementation not go through the dbgp protocol?
I just enable my view based on a SUSPEND and disable it again on a RESUME event from the DebugPlugin..
One little problem if there where 2 launches that both are suspended. I have no idea what is the selected one is (but that should be a listener somewhere i guess)
Are there any plans to rewrite the console so that i works through the protocol and with an existing debugging session?
johan