step
instructions in the script source code before creating a debug session, allowing to execute the debugging session in the context of the calling program, and even if the scripting language does not support "standard" debugging.
public class ScriptContext |
---|
Modifier and Type | Method and Description |
---|---|
void | step(int lineNumber, Object... args)
Call the step instruction with the specified line number in the original script and the values of all the variables which are accessible in the associated line
|
step
instruction has the following arguments:public interface Script { public int execute(); }And the script which implements this interface in Groovy:
public int execute() { int a = 10; a = a + 1; return a; }The code of the script after inserting the boilerplate code will be:
import org.scripthelper.context.ScriptContext; import org.scripthelper.context.ScriptHelper; import org.scripthelper.context.DefaultScriptContext; import org.scripthelper.groovy.debug.parser.Script; class GroovyClass implements org.scripthelper.groovy.debug.parser.Script, org.scripthelper.context.ContextListener { DefaultScriptContext context; public void init(ScriptContext ctx) { context = (DefaultScriptContext)ctx; } public int execute() { int a = 10; a = a + 1; return a; } }And after inserting
step
instructions:import org.scripthelper.context.ScriptContext; import org.scripthelper.context.ScriptHelper; import org.scripthelper.context.DefaultScriptContext; import org.scripthelper.groovy.debug.parser.Script; class GroovyClass implements org.scripthelper.groovy.debug.parser.Script, org.scripthelper.context.ContextListener { DefaultScriptContext context; public void init(ScriptContext ctx) { context = (DefaultScriptContext)ctx; } public int execute() { context.__step__(1,this.context); int a = 10; context.__step__(2,a,this.context); a = a + 1; context.__step__(3,a,this.context); return a; } }
Copyright 2019-2020 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence