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
Introduce Efficient Node Localization in Syntax Tree for Unit Tests #2251
Comments
For the current needs, I've implemented unit tests to examine how the range of source code to highlight is calculated. The relevant tests can be found here: swift-syntax/Tests/SwiftDiagnosticsTest/SyntaxHighlightRangeCalculatorTests.swift Lines 76 to 90 in b6fcad4
swift-syntax/Tests/SwiftDiagnosticsTest/SyntaxHighlightRangeCalculatorTests.swift Lines 276 to 296 in b6fcad4
And this approach is far from optimal. |
Tracked in Apple’s issue tracker as rdar://116256883 |
Description
Currently, there is no mechanism to efficiently refer to specific node in syntax tree for the need of unit test. For example to create
Diagnostic.highlights
and attach them to a specific node in a syntax tree within diagnostic formatters unit tests. The absence of such a feature makes it cumbersome to identify and highlight syntax nodes for diagnostic or verification purposes.Proposed Solution by @ahoppen:
Introduce a
NodeLocator
struct to facilitate the process. Below is a proposed implementation idea:Note
Before starting implementation, let's discuss this approach here.
This feature could be a significant step towards enabling more precise and easier-to-write unit tests, especially those involving diagnostic highlights.
The text was updated successfully, but these errors were encountered: