-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add debugging facilities to RuleNode/TokenNode exposed via N-API (#908)
Closes #466 ## JSON serialization Adds the `toJSON` method to the RuleNode/TokenNode classes with the comment stating that it's unstable and for debugging purposes only. I explicitly didn't type it (it's a string) as I didn't want to publicly encode any assumptions about the shape of the data. We can discuss further what we want to explore as part of having pure data external interface (JSON) for Slang, whether that's exporting or importing JSON, but I'd consider this a separate issue as it requires more thought and design; the original issue, from what I understand, was primarily about improving the debugging/inspection experience. ## Debugger Adds hidden getter properties that is only eagerly evaluated by debugger; since it's a getter function, it shouldn't add overhead to the runtime but I have to admit, I didn't double-check that with numbers. It adds both `__children` and `__text`, allowing to quickly explore the tree structure recursively and also the enclosing text scope of the node: ### vscode-js-debug (built-in to VS Code) ![image](https://github.com/NomicFoundation/slang/assets/3093213/193702fa-02b6-4853-9dcd-8af58469cf23) ### Chrome DevTools for Node ![image](https://github.com/NomicFoundation/slang/assets/3093213/a7b81836-ad7e-495c-aded-ebcc48f3bb6b)
- Loading branch information
Showing
11 changed files
with
171 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nomicfoundation/slang": minor | ||
--- | ||
|
||
Changed the cst.NodeType in TS to use more descriptive string values rather than 0/1 integers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nomicfoundation/slang": minor | ||
--- | ||
|
||
Add RuleNode/TokenNode::toJSON() in the TypeScript API |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 44 additions & 1 deletion
45
crates/solidity/outputs/cargo/slang_solidity/src/generated/napi_interface/cst.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
crates/solidity/outputs/npm/package/src/generated/index.d.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 44 additions & 1 deletion
45
crates/testlang/outputs/cargo/slang_testlang/src/generated/napi_interface/cst.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 10 additions & 2 deletions
12
crates/testlang/outputs/npm/package/src/generated/index.d.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.