@@ -12,6 +12,7 @@ import { analyzeCode, analyzeCodeViaQuery } from "../parser";
1212function collectSymbolTables ( { id, get } : { id : string ; get : ( ) => MyState } ) {
1313 let pods = get ( ) . pods ;
1414 let pod = pods [ id ] ;
15+ // Collect from parent scope.
1516 if ( ! pod . parent ) return { } ;
1617 let allSymbolTables = pods [ pod . parent ] . children . map ( ( { id, type } ) => {
1718 // FIXME make this consistent, CODE, POD, DECK, SCOPE; use enums
@@ -25,6 +26,21 @@ function collectSymbolTables({ id, get }: { id: string; get: () => MyState }) {
2526 return Object . assign ( { } , ...tables ) ;
2627 }
2728 } ) ;
29+ // Collect from scopes by Arrows.
30+ const edges = get ( ) . edges ;
31+ edges . forEach ( ( { source, target } ) => {
32+ if ( target === pod . parent ) {
33+ if ( pods [ source ] . type === "CODE" ) {
34+ allSymbolTables . push ( pods [ target ] . symbolTable ) ;
35+ } else {
36+ let tables = ( pods [ source ] . children || [ ] )
37+ . filter ( ( { id } ) => pods [ id ] . ispublic )
38+ . map ( ( { id } ) => pods [ id ] . symbolTable ) ;
39+ allSymbolTables . push ( Object . assign ( { } , ...tables ) ) ;
40+ }
41+ }
42+ } ) ;
43+ // Combine the tables and return.
2844 let res = Object . assign ( { } , pods [ id ] . symbolTable , ...allSymbolTables ) ;
2945 return res ;
3046}
0 commit comments