Skip to content

Commit

Permalink
Add a toJSON function to SymbolTable (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Aug 2, 2022
1 parent a31e1be commit 13df25b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/SymbolTable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Range } from 'vscode-languageserver';
import type { BscType } from './types/BscType';


/**
* Stores the types associated with variables and functions in the Brighterscript code
* Can be part of a hierarchy, so lookups can reference parent scopes
Expand Down Expand Up @@ -110,6 +109,22 @@ export class SymbolTable {
}
}
}

/**
* Serialize this SymbolTable to JSON (useful for debugging reasons)
*/
private toJSON() {
return {
parent: this.parent?.toJSON(),
symbols: [
...new Set(
[...this.symbolMap.entries()].map(([key, symbols]) => {
return symbols.map(x => x.name);
}).flat().sort()
)
]
};
}
}

export interface BscSymbol {
Expand Down

0 comments on commit 13df25b

Please sign in to comment.