Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a toJSON function to SymbolTable #655

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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