From 01829b04d7af9323104dd18e2aeafb7c4959fec1 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sun, 25 Apr 2021 12:22:17 +0200 Subject: [PATCH] Using include to start the debugger --- oxygen/js-debugger-importer/commons.js | 25 ++++------------------- oxygen/js-debugger-importer/debugger.js | 21 +++++++++++++++++++ oxygen/js-debugger-importer/sdf.framework | 6 +++++- 3 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 oxygen/js-debugger-importer/debugger.js diff --git a/oxygen/js-debugger-importer/commons.js b/oxygen/js-debugger-importer/commons.js index fe23003..baf70f8 100644 --- a/oxygen/js-debugger-importer/commons.js +++ b/oxygen/js-debugger-importer/commons.js @@ -1,26 +1,9 @@ -startDebugger = function () { - - var runnable = { - run: function () { - main.dispose(); - } - } - - - var context = Packages.org.mozilla.javascript.Context.getCurrentContext(); // Within the current context... - var contextFactory = context.getFactory(); - var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__); // and the scope of the runnable variable's parent ... - var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger'); // start a debugging session ... - main.setExitAction(java.lang.Runnable(runnable)); // , clean the resources at exit time... - main.setVisible(true); // and make it visible/ - -} - include = function (filepath, isAbsolute) { if (isAbsolute === undefined || isAbsolute == false) { filepath = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath); - } - var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths.get('/home/vdv/projects/tea/dyomedea/ramblings/oxygen/js-debugger-importer/test.js'))); + } + Packages.java.lang.System.out.println('filepath: ' + filepath ); + var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath)))); text = String(text); eval(text); -} \ No newline at end of file +} diff --git a/oxygen/js-debugger-importer/debugger.js b/oxygen/js-debugger-importer/debugger.js new file mode 100644 index 0000000..e011f65 --- /dev/null +++ b/oxygen/js-debugger-importer/debugger.js @@ -0,0 +1,21 @@ +startDebugger = function () { + + var runnable = { + run: function () { + main.dispose(); + } + } + + + var context = Packages.org.mozilla.javascript.Context.getCurrentContext(); + // Within the current context... + var contextFactory = context.getFactory(); + var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__); + // and the scope of the runnable variable's parent ... + var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger'); + // start a debugging session ... + main.setExitAction(java.lang.Runnable(runnable)); + // , clean the resources at exit time... + main.setVisible(true); + // and make it visible/ +} diff --git a/oxygen/js-debugger-importer/sdf.framework b/oxygen/js-debugger-importer/sdf.framework index 5043baf..a72353d 100644 --- a/oxygen/js-debugger-importer/sdf.framework +++ b/oxygen/js-debugger-importer/sdf.framework @@ -794,7 +794,11 @@ script - doOperation = startDebugger; + doOperation = function () { + include('debugger.js'); + startDebugger(); +} +