[GSoC 2023] Implement Incremental Re-Parsing in SwiftParser

Hey guys! My name is Ziyang Huang. I am currently a student from South China University of Technology majoring in Computer Science. I've been using Swift since my internship at ByteDance, and it's been about a year now.

I pretty enjoy the development experience with the nice syntax highlighting and code navigation in Xcode, which are supported by the parser. And that's why I'm especially interested in this year's GSoC project Implement Incremental Re-Parsing in SwiftParser. In the past month, I have opened two simple PRs(1, 2) to get myself familiar with the swift-syntax codebase and I will keep making contributions to this awesome project.

Recently, I made a draft proposal for the project and wrote some demos(very rough early version, many details not considered) based on my understanding. I would like to ask @ahoppen whether I'm on the right track? Any information would be greatly appreciated!

1 Like

Thanks for sending me the draft proposal @StevenWong12. I just read through it and it looks good. I’ve got two comments I’d like to share with you.

Since SyntaxProtocol conforms to CustomDebugStringConvertible, we could just compare description string of the old AST and the new AST to determine whether the file is correctly parsed.

We would also need to check that the layout of the tree is the same not just that their descriptions match because you can form multiple trees that represent the same source. We should be able to use SubtreeMatcher or something similar to compare the tree layouts.

To test the parsing performance at different scales, I plan to make use of SwiftSyntaxBuilder to generate a branch of testcases of different sizes and view the parsing performance on these cases.

I’m a little worried about creating these synthetic test cases that will be mostly repetetive. Instead, I’d suggest to test performance on real-world Swift projects.

– Alex


Thanks for your comments!

I'll revised my proposal according to your suggestions while making it more detailed.

1 Like