Skip to content

Commit c069ef0

Browse files
committed
AEDebugging_ Add event data to gutter info
SQUASHED: AUTO-COMMIT-src-components-widgets-lively-code-mirror.js,
1 parent b042506 commit c069ef0

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

src/components/widgets/lively-code-mirror.js

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { loc, range } from 'utils';
3131
import indentationWidth from 'src/components/widgets/indent.js';
3232
import { DependencyGraph } from 'src/client/dependency-graph/graph.js';
3333
import { getDependencyMapForFile } from 'src/client/reactive/active-expression-rewriting/active-expression-rewriting.js';
34+
import { AExprRegistry } from 'src/client/reactive/active-expression/active-expression.js';
3435
import ContextMenu from 'src/client/contextmenu.js';
3536

3637
import _ from 'src/external/lodash/lodash.js';
@@ -1410,7 +1411,7 @@ export default class LivelyCodeMirror extends HTMLElement {
14101411
}
14111412
// this.showAExprTextMarkers();
14121413
await this.showAExprDependencyGutter();
1413-
const dependencyMap = await this.allDependencies();
1414+
const dependencyMap = await this.allDependenciesByLine();
14141415
this.showAExprDependencyGutterMarkers(dependencyMap);
14151416
}
14161417

@@ -1480,27 +1481,14 @@ export default class LivelyCodeMirror extends HTMLElement {
14801481
}
14811482

14821483
async showAExprDependencyGutterMarkers(dependencyMap) {
1483-
const lines = [];
1484-
14851484
await this.editor;
14861485

1487-
for (const [statement, aExprs] of dependencyMap.entries()) {
1488-
const line = statement.node.loc.start.line - 1;
1489-
if (!lines[line]) {
1490-
lines[line] = [];
1491-
}
1492-
for (let aExpr of aExprs) {
1493-
lines[line].push(aExpr);
1494-
}
1486+
for (const [line, aExprs] of dependencyMap.entries()) {
1487+
this.drawAExprGutter(line, aExprs);
14951488
}
1496-
1497-
this.editor.doc.clearGutter('activeExpressionGutter');
1498-
lines.forEach((deps, line) => {
1499-
this.drawAExprGutter(line, deps);
1500-
});
15011489
}
15021490

1503-
async allDependencies() {
1491+
async allDependenciesByLine() {
15041492
const dict = new Map();
15051493

15061494
await this.editor;
@@ -1509,27 +1497,46 @@ export default class LivelyCodeMirror extends HTMLElement {
15091497
const dependencies = dependencyGraph.resolveDependencies(path.get("arguments")[0]);
15101498

15111499
dependencies.forEach(statement => {
1512-
if (!dict.get(statement)) {
1513-
dict.set(statement, []);
1500+
const line = statement.node.loc.start.line-1;
1501+
if (!dict.get(line)) {
1502+
dict.set(line, []);
15141503
}
1515-
dict.get(statement).push({ location: path.node.loc, source: path.get("arguments.0.body").getSource() });
1504+
dict.get(line).push({ location: path.node.loc, source: path.get("arguments.0.body").getSource(), events: 0 });
15161505
});
15171506
});
15181507
const map = getDependencyMapForFile(this.fileURL());
15191508
map.forEach((aes, dependency) => {
15201509
if(aes.length > 0) {
15211510
const memberName = dependency.contextIdentifierValue()[1];
15221511
let deps = dependencyGraph.resolveDependenciesForMember(memberName);
1512+
15231513
deps.forEach(path => {
1524-
if (!dict.get(path)) {
1525-
dict.set(path, []);
1514+
const line = path.node.loc.start.line-1;
1515+
if (!dict.get(line)) {
1516+
dict.set(line, []);
15261517
}
15271518
for (const ae of aes) {
1528-
dict.get(path).push({ location: ae._annotations._annotations[0].location, source: ae._annotations._annotations[1].sourceCode });
1519+
var valueChangedEvents = ae.meta().get("events").filter(event => event.type === "changed value");
1520+
const relatedEvents = valueChangedEvents.filter(event => event.value.trigger.source.includes(this.fileURL()) && event.value.trigger.line - 1 === line);
1521+
dict.get(line).push({ location: ae._annotations._annotations[0].location, source: ae._annotations._annotations[1].sourceCode, events: relatedEvents.length });
15291522
}
15301523
});
1531-
}
1524+
}
15321525
});
1526+
1527+
/*let dynamicAES = AExprRegistry.allAsArray();
1528+
dynamicAES.forEach(ae => {
1529+
var valueChangedEvents = ae.meta().get("events").filter(event => event.type === "changed value");
1530+
valueChangedEvents.forEach(event => {
1531+
if(event.value.trigger.source.includes(this.fileURL())) {
1532+
const line = event.value.trigger.line - 1;
1533+
if (!dict.get(line)) {
1534+
dict.set(line, []);
1535+
}
1536+
dict.get(line).push({ location: ae._annotations._annotations[0].location, source: ae._annotations._annotations[1].sourceCode });
1537+
}
1538+
});
1539+
});*/
15331540

15341541
return dict;
15351542
}
@@ -1581,7 +1588,7 @@ export default class LivelyCodeMirror extends HTMLElement {
15811588
lively.openBrowser(path, true, start, true);
15821589
}
15831590
menu.remove();
1584-
}, '→', fa(inThisFile ? 'location-arrow' : 'file-code-o')]);
1591+
}, dep.events + " event" + (dep.events===1?"":"s"), fa(inThisFile ? 'location-arrow' : 'file-code-o')]);
15851592
});
15861593

15871594
const menu = await ContextMenu.openIn(document.body, { clientX: markerBounds.left, clientY: markerBounds.bottom }, undefined, document.body, menuItems);

0 commit comments

Comments
 (0)