Building an Elixir Refactoring Library with AST

150
clicks
Building an Elixir Refactoring Library with AST

Source: youtube.com

Type: Video

The content describes the journey of creating an Elixir library aimed at refactoring functions within an application, akin to the 'refactor function' feature found in IntelliJ IDE. Christian Koch explores how to parse Elixir code into its parsed representation to locate references to a function, investigating the use of Abstract Syntax Trees (AST) for code manipulation, and elaborating on the challenges of working with ASTs in Elixir. The library, named ExFactor, leverages Elixir's parsing capabilities to transform code into ASTs, subsequently facilitating the refactoring process, including finding function calls, moving functions to different modules, and updating references. Koch provides insights into the mechanics of Elixir's compilation process and how it impacts the ability to reverse-engineer code from ASTs. Although the process does not perfectly preserve aspects like comments and white space, the library aims to offer a practical solution for refactoring. The talk also introduces various core Elixir tools used in the project, such as the option parser and compiler tracing, and demonstrates a live example of the library in action.

© HashMerge 2024