This edition of the Radar introduces two tools that search and replace code using an abstract syntax tree (AST) representation. They occupy a similar space as jscodeshift but contain parsers for a wide range of programming languages. Although they share some similarities, they also differ in several ways. One of these tools, Comby, is unique in its simple, command-line interface designed in the spirit of Unix tools such as awk
and sed
. While the Unix commands are based on regular expressions operating matching text, Comby employs a pattern syntax that is specific to programming language constructs and parses the code before searching. This helps developers search large code bases for structural patterns. Like sed
, Comby can replace the patterns it matches with new structures. This is useful for automating wholesale changes to large codebases or for making repetitive changes across a suite of microservice repositories. Since these tools are fairly new, we expect to see a range of creative uses that have yet to be discovered.