Talk - Creating Refactoring Transformations for Swift

May 27, 2018

Creating Refactoring Transformations for Swift - Xi Ge

A talk by Xi Ge, a software engineer working in the Swift team at Apple.

I'd like to talk about the design goals of libSyntax, like comparing it with the existing infrastructure of the Swift compiler. Existing infrastructure, as I mentioned, has source information loss, whereas in the libSyntax world, we provide full trivia preservation, including comments and whitespace. Actually, you can round-trip. You can print the libSyntax nodes to its original source file. Existing infrastructure has implicit nodes for other actions in the compiler pipeline, like our generation, but in the libSyntax world, what you'll see is what you'll get. In the existing infrastructure, to implement code transformation, we have to manipulate strings manually, while libSyntax will provide us structured edits APIs and tree manipulation APIs. Existing infrastructure requires us to work in C++, while libSyntax will ship equally functional APIs in both C++ and Swift.
Thirdly, stay tuned for the latest development of libSyntax. When it's ready, we can use our favorite programming language to generate and to modify our favorite programming language. You can find the documentation of libSyntax API in the Swift repository. You can check out my colleague Harlan Haskins' presentation in try! Swift NYC, where he will give you more details about the implementation of libSyntax.

Header photo credit: unsplash-logoMarkus Spiske