@@ -30,7 +30,7 @@ let loadPromise = undefined;
3030import { loc , range } from 'utils' ;
3131import indentationWidth from 'src/components/widgets/indent.js' ;
3232import { DependencyGraph } from 'src/client/dependency-graph/graph.js' ;
33- import { getDependencyTriplesForFile } from 'src/client/reactive/active-expression-rewriting/active-expression-rewriting.js' ;
33+ import { getDependencyTriplesForFile , registerFileForAEDebugging } from 'src/client/reactive/active-expression-rewriting/active-expression-rewriting.js' ;
3434import { AExprRegistry } from 'src/client/reactive/active-expression/active-expression.js' ;
3535import ContextMenu from 'src/client/contextmenu.js' ;
3636
@@ -223,6 +223,7 @@ export default class LivelyCodeMirror extends HTMLElement {
223223
224224 await lively . sleep ( 0 ) ;
225225 this . editor . refresh ( ) ;
226+ this . updateAExprDependencies ( ) ;
226227 }
227228
228229 async editorLoaded ( ) {
@@ -1411,10 +1412,15 @@ export default class LivelyCodeMirror extends HTMLElement {
14111412 }
14121413 // this.showAExprTextMarkers();
14131414 await this . showAExprDependencyGutter ( ) ;
1414- const [ depToAE , AEToDep ] = await this . allDependenciesByLine ( ) ;
1415- this . editor . doc . clearGutter ( 'activeExpressionGutter' )
1416- this . showAExprDependencyGutterMarkers ( depToAE , false ) ;
1417- this . showAExprDependencyGutterMarkers ( AEToDep , true ) ;
1415+
1416+
1417+ registerFileForAEDebugging ( this . fileURL ( ) , this , ( triplets ) => {
1418+ this . allDependenciesByLine ( triplets ) . then ( ( [ depToAE , AEToDep ] ) => {
1419+ this . editor . doc . clearGutter ( 'activeExpressionGutter' ) ;
1420+ this . showAExprDependencyGutterMarkers ( depToAE , false ) ;
1421+ this . showAExprDependencyGutterMarkers ( AEToDep , true ) ;
1422+ } ) ;
1423+ } ) ;
14181424 }
14191425
14201426 async showAExprTextMarkers ( ) {
@@ -1490,7 +1496,7 @@ export default class LivelyCodeMirror extends HTMLElement {
14901496 }
14911497 }
14921498
1493- async allDependenciesByLine ( ) {
1499+ async allDependenciesByLine ( depsMapInFile ) {
14941500 const depToAE = new Map ( ) ;
14951501 const AEToDep = new Map ( ) ;
14961502
@@ -1527,19 +1533,19 @@ export default class LivelyCodeMirror extends HTMLElement {
15271533 if ( ! depToAE . get ( dependencyLine ) ) {
15281534 depToAE . set ( dependencyLine , [ ] ) ;
15291535 }
1530- depToAE . get ( dependencyLine ) . push ( { location : AELocation , source : ae . meta ( ) . get ( "sourceCode" ) , events : relatedEvents . length } ) ;
1536+ // Group by AE to distinguish between mutltiple AE Objects in the same line?
1537+ depToAE . get ( dependencyLine ) . push ( { location : AELocation , source : ae . meta ( ) . get ( "sourceCode" ) , events : relatedEvents . length , aes : new Set ( [ ae ] ) } ) ;
15311538 }
15321539
15331540 if ( AELocation . file . includes ( this . fileURL ( ) ) ) {
15341541 // AE is in this file
15351542 if ( ! AEToDep . get ( AELine ) ) {
15361543 AEToDep . set ( AELine , [ ] ) ;
15371544 }
1538- AEToDep . get ( AELine ) . push ( { location : dependencyLoc , source : dependencySource , events : relatedEvents . length } ) ;
1545+ AEToDep . get ( AELine ) . push ( { location : dependencyLoc , source : dependencySource , events : relatedEvents . length , aes : new Set ( [ ae ] ) } ) ;
15391546 }
15401547 } ;
15411548
1542- const depsMapInFile = await getDependencyTriplesForFile ( this . fileURL ( ) ) ;
15431549 for ( const { hook, dependency, ae } of depsMapInFile ) {
15441550 const dependencyInfo = dependency . contextIdentifierValue ( ) ;
15451551 const locations = await hook . getLocations ( ) ;
@@ -1584,6 +1590,10 @@ export default class LivelyCodeMirror extends HTMLElement {
15841590 fileURL ( ) {
15851591 return lively . query ( this , "lively-container" ) . getURL ( ) . pathname ;
15861592 }
1593+
1594+ valid ( ) {
1595+ return ! ! lively . query ( this , "lively-container" ) ;
1596+ }
15871597
15881598 drawAExprGutter ( line , dependencies , isAE ) {
15891599 this . editor . doc . setGutterMarker ( line , 'activeExpressionGutter' , this . drawAExprGutterMarker ( dependencies , isAE ) ) ;
@@ -1627,6 +1637,7 @@ export default class LivelyCodeMirror extends HTMLElement {
16271637 if ( dep . location . end . column > lastDep . location . end . column ) {
16281638 lastDep . location . end = dep . location . end ;
16291639 }
1640+ lastDep . aes = new Set ( [ ...lastDep . aes , ...dep . aes ] ) ;
16301641 }
16311642 } ) ;
16321643
@@ -1636,7 +1647,7 @@ export default class LivelyCodeMirror extends HTMLElement {
16361647 } ;
16371648
16381649 return < div class = { "activeExpressionGutter-marker" + ( isAE ? "-ae" : "-dep" ) } click = { callback } >
1639- { accumulated . length }
1650+ { isAE ? < b > AE </ b > : < i class = "fa fa-share-alt" > </ i > }
16401651 </ div > ;
16411652 }
16421653
@@ -1664,7 +1675,7 @@ export default class LivelyCodeMirror extends HTMLElement {
16641675 lively . openBrowser ( path , true , { start, end} , false , undefined , true ) ;
16651676 }
16661677 menu . remove ( ) ;
1667- } , dep . events + " event" + ( dep . events === 1 ? "" : "s" ) , this . faIcon ( inThisFile ? 'location-arrow' : 'file-code-o' ) ] ) ;
1678+ } , dep . events + " event" + ( dep . events === 1 ? "" : "s" ) + ", " + dep . aes . size + " instance" + ( dep . aes . size === 1 ? "" : "s" ) , this . faIcon ( inThisFile ? 'location-arrow' : 'file-code-o' ) ] ) ;
16681679 } ) ;
16691680
16701681 const menu = await ContextMenu . openIn ( document . body , { clientX : markerBounds . left , clientY : markerBounds . bottom } , undefined , document . body , menuItems ) ;
0 commit comments