Is there a package or tool available that allows to automate the semantic analysis and modification of Julia code, e.g., in a file or in an entire module? I am thinking about use cases like where we have lots of code with both variables and functions prefixed with
foo_ and I want to change this prefix to
bar_ but only for variables. Or, e.g, I would like to find out how many local variables are defined that start with
Is there something available that already fits the bill (or to a large degree, at least) and if not, what would be a good way to do this? I realize that this is probably too complex a question to be answered in a Discourse thread, but I’d appreciate any pointers to similar packages or some keywords I can be looking for to figure it out myself.
The Julia VSCode plugin has something like this in the “Rename Symbol” command, which does a semantic rename. Its not always perfect but usually surprises me how good it is, e.g. it gets this totally right regardless what you rename:
foo = 2
and works across multiple included files in a module.
Thanks for this hint. Would you happen to know how the plugin does this internally and whether it relies on a dedicated package or whether it’s deeply integrated in the plugin code somewhere?
the VSCode plugin uses CSTParser.jl, which is also used by Vimes.jl that does some mutation like you mention an interest in (although I don’t know if that package is maintained, unfortunately). JuliaFormatter.jl also uses CSTParser.jl, by the way.
Sorry for the late answer, but thanks a lot for the information on
CSTParser.jl, I will look into it!