Skip to content

Commit f2edd18

Browse files
committed
small bugfixes plugin explorer _ position for traversePlugins
SQUASHED: AUTO-COMMIT-demos-tom-TraceLogParser.js,AUTO-COMMIT-src-components-tools-lively-plugin-explorer.js,AUTO-COMMIT-src-components-tools-lively-plugin-explorer-playground.workspace,AUTO-COMMIT-src-components-tools-plugin-selector.js,
1 parent b6b47a4 commit f2edd18

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

demos/tom/TraceLogParser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class TraceLogParser {
1818
return this.trace._log;
1919
}
2020

21-
/* Parsing primitives */
21+
/*MD ## Parsing primitives MD*/
2222

2323
peek() {
2424
if(this.index < this.log.length) {
@@ -59,7 +59,7 @@ export default class TraceLogParser {
5959
return object.isEarlyReturn && object.type === type;
6060
}
6161

62-
/* Parse methods */
62+
/*MD ## Parse methods MD*/
6363

6464
instantiateEvent(entry) {
6565
const eventClass = eventTypes[entry.__type__];
@@ -129,6 +129,7 @@ export default class TraceLogParser {
129129
parseTraversePlugin(section, higherSections) {
130130
const entry = this.consume();
131131
const plugin = new TraceSection('TraversePlugin:' + entry.data);
132+
plugin.position = this.peek().position;
132133

133134
section.addEntry(plugin);
134135

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"source":"/src/components/tools/lively-ast-explorer-example-source.js","plugin":"https://lively-kernel.org/lively4/lively4-tom/demos/tom/playground.js","options":{"autoUpdateAST":true,"autoUpdateTransformation":true,"autoExecute":true,"systemJS":false,"autoRunTests":false,"autoSaveWorkspace":false},"pluginSelection":[{"url":"https://lively-kernel.org/lively4/lively4-tom/demos/tom/playground.js"}]}
1+
{"source":"/src/components/tools/lively-ast-explorer-example-source.js","plugin":"https://lively-kernel.org/lively4/lively4-tom/src/external/babel-plugin-locals.js","options":{"autoUpdateAST":true,"autoUpdateTransformation":true,"autoExecute":true,"systemJS":true,"autoRunTests":false,"autoSaveWorkspace":false},"pluginSelection":[{"url":"https://lively-kernel.org/lively4/lively4-tom/src/external/babel-plugin-locals.js"}]}

src/components/tools/lively-plugin-explorer.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ export default class PluginExplorer extends Morph {
136136
set systemJS(bool) {
137137
this.systemJSButton.classList.toggle("on", bool);
138138
}
139-
onToggleSystemJs() { this.toggleOption("systemJS"); }
139+
onToggleSystemJs() {
140+
this.toggleOption("systemJS");
141+
this.updateAST();
142+
}
140143

141144
onDebug() {
142145
if (!this.getOption("systemJS")) {
@@ -376,7 +379,7 @@ export default class PluginExplorer extends Morph {
376379
this.transformedSourceLCM.value = code;
377380

378381
if (this.autoExecute) this.execute();
379-
if (this.autoRunTests) runTests();
382+
if (this.autoRunTests) this.runTests();
380383
}
381384

382385
async updateTransformation(ast) {
@@ -389,6 +392,7 @@ export default class PluginExplorer extends Morph {
389392
lively.error("lively4lastSystemJSBabelConfig missing");
390393
return;
391394
}
395+
const plugin = await this.getPlugin();
392396
let config = Object.assign({}, self.lively4lastSystemJSBabelConfig);
393397
let url = this.fullUrl(this.pluginURL) || "";
394398
let originalPluginURL = url.replace(/-dev/, ""); // name of the original plugin .... the one without -dev
@@ -409,6 +413,7 @@ export default class PluginExplorer extends Morph {
409413
const filename = 'tempfile.js';
410414
config.sourceFileName = filename
411415
config.moduleIds = false;
416+
config.sourceMaps = true;
412417

413418

414419
// here for documenting the babel hook
@@ -420,10 +425,9 @@ export default class PluginExplorer extends Morph {
420425
};
421426

422427
this.transformationResult = babel.transform(this.sourceText, config);
423-
424-
425-
this.updateAndExecute(this.transformationResult.code);
426428
}
429+
430+
this.updateAndExecute(this.transformationResult.code);
427431

428432

429433
} catch (e) {
@@ -499,14 +503,12 @@ export default class PluginExplorer extends Morph {
499503
}
500504

501505
mapEditorsFromToPosition(fromTextEditor, toTextEditor, backward) {
502-
if (backward == true) {
503-
var method = "originalPositionFor"
504-
} else {
505-
method = "generatedPositionFor"
506-
}
506+
debugger
507+
let positionFor = backward ? this["originalPositionFor"] : this["generatedPositionFor"];
508+
507509
var range = fromTextEditor.listSelections()[0]
508-
var start = this[method](range.anchor.line + 1, range.anchor.ch + 1)
509-
var end = this[method](range.head.line + 1, range.head.ch + 1)
510+
var start = positionFor.call(this, range.anchor.line + 1, range.anchor.ch + 1)
511+
var end = positionFor.call(this, range.head.line + 1, range.head.ch + 1)
510512

511513
//lively.notify(`start ${range.anchor.line} ch ${range.anchor.ch} -> ${start.line} ch ${start.column} / end ${range.head.line} ch ${range.head.ch} -> ${end.line} c ${end.column}`)
512514
if (!start || !end) return;

src/components/tools/plugin-selector.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export default class PluginSelector extends Morph {
5353

5454
this.selectedItems = this.workspace.pluginSelection;
5555
for (const { url } of (this.selectedItems || [])) {
56-
debugger
5756
const listElement = this.listElementTo(this.fileNameToName(url), list);
5857
const button = listElement.getElementsByClassName('toggle')[0];
5958
button.className += ' on';

0 commit comments

Comments
 (0)