Skip to content

Redo the Folding Range Request on top of the Syntax Tree #652

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
Oct 20, 2022
Merged

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Oct 16, 2022

Building upon the infrastructure that requests the lexical structure of the document from SwiftSyntax, redo the folding ranges request using the tree directly. This corrects a number of inconsistencies in the tests mostly due to incorrect SourceLocations in the semantic ASTs and the line comment merging logic.

To extract folding ranges, we were previously opening a temporary document to issue a syntactic structure request to SourceKit.

This change is not NFC - there are a number of quirks of the C++ version of the structure walkers that I think were incorrect and are fixed here. For example, the folding range for the guard in the FoldingRangeBase test occurs before the actual {! However, this PR does try to recreate the adjacent line comment merging behavior in the C++, but does also correct some bogus source ranges as a result.

Built upon #651

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 16, 2022

@swift-ci test

@CodaFi CodaFi force-pushed the folderol branch 3 times, most recently from eee1726 to 1139c22 Compare October 20, 2022 06:36
Building upon the infrastructure that requests the lexical structure of the document from SwiftSyntax, redo the folding ranges request using the tree directly. This corrects a number of inconsistencies in the tests mostly due to incorrect SourceLocations in the semantic ASTs and the line comment merging logic.
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 20, 2022

@swift-ci test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thank you, looks good to me and it’s great to see us get rid of another sourcekitd request.

@CodaFi CodaFi merged commit bf4c67b into main Oct 20, 2022
@CodaFi CodaFi deleted the folderol branch October 20, 2022 14:53
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.

3 participants