Skip to content

Improve debug description of syntax nodes #1503

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

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 7, 2023

This improves the description generated by the debugDescription function to something like the following which is easier to read IMO

SourceFileSyntax
├─CodeBlockItemListSyntax
│ ╰─CodeBlockItemSyntax
│   ╰─MacroExpansionExprSyntax
│     ├─pound
│     ├─identifier("stringify")
│     ├─leftParen
│     ├─TupleExprElementListSyntax
│     │ ╰─TupleExprElementSyntax
│     │   ╰─InfixOperatorExprSyntax
│     │     ├─IntegerLiteralExprSyntax
│     │     │ ╰─integerLiteral("2")
│     │     ├─BinaryOperatorExprSyntax
│     │     │ ╰─binaryOperator("+")
│     │     ╰─IntegerLiteralExprSyntax
│     │       ╰─integerLiteral("3")
│     ╰─rightParen
╰─eof

Since we now have this nice representation, it also removes the conformances to CustomReflectable (deleting 3000 lines of code 🎉 ) and doing some new CustomReflectable hackery to make the debugger just print debugDescription and not try to print the node’s children itself. This way you an now do po node in the debugger to get the debug description from above, instead of having to do e print(node.recursiveDescription)

@DougGregor
Copy link
Member

Beautiful!

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

−3,206

Aw yeah, that's what I like to see!

@ahoppen ahoppen force-pushed the ahoppen/better-debug-description branch from 2836eec to 4eb805c Compare April 8, 2023 00:07
@ahoppen
Copy link
Member Author

ahoppen commented Apr 8, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 8, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 12, 2023

swiftlang/swift#65118

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 12, 2023

swiftlang/swift#65118

@swift-ci Please test Windows

This improves the description generated by the `debugDescription` function to something like the following which is easier to read IMO

```
SourceFileSyntax
├─CodeBlockItemListSyntax
│ ╰─CodeBlockItemSyntax
│   ╰─MacroExpansionExprSyntax
│     ├─pound
│     ├─identifier("stringify")
│     ├─leftParen
│     ├─TupleExprElementListSyntax
│     │ ╰─TupleExprElementSyntax
│     │   ╰─InfixOperatorExprSyntax
│     │     ├─IntegerLiteralExprSyntax
│     │     │ ╰─integerLiteral("2")
│     │     ├─BinaryOperatorExprSyntax
│     │     │ ╰─binaryOperator("+")
│     │     ╰─IntegerLiteralExprSyntax
│     │       ╰─integerLiteral("3")
│     ╰─rightParen
╰─eof
```

Since we now have this nice representation, it also removes the conformances to `CustomReflectable` (deleting 3000 lines of code :hooray:) and doing some new `CustomReflectable` hackery to make the debugger just print `debugDescription` and not try to print the node’s children itself. This way you an now do `po node` in the debugger to get the debug description from above, instead of having to do `e print(node.recursiveDescription)`
@ahoppen ahoppen force-pushed the ahoppen/better-debug-description branch from 7a02b13 to e618702 Compare April 13, 2023 00:44
@kimdv
Copy link
Contributor

kimdv commented Apr 13, 2023

@swift-ci please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 13, 2023

swiftlang/swift#65118

@swift-ci Please test macOS

@ahoppen
Copy link
Member Author

ahoppen commented Apr 13, 2023

swiftlang/swift#65118

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 7aacf50 into swiftlang:main Apr 13, 2023
@ahoppen ahoppen deleted the ahoppen/better-debug-description branch April 13, 2023 23:30
meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request Apr 14, 2023
ahoppen added a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 2023
…escription

Improve debug description of syntax nodes
ahoppen added a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 2023
…escription

Improve debug description of syntax nodes
ahoppen added a commit to ahoppen/swift that referenced this pull request Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants