3 ms·
> If a refactoring tool wants to rename “x”, it does it to the source, not the AST, no? A textual find and replace isn't sufficient because multiple variables
by hgs3 6y ago
> If a refactoring tool wants to rename “x”, it does it to the source, not the AST, no?
A textual find and replace isn't sufficient because multiple variables might be named ‘x’ and you wouldn't want to rename all of them, just the one you're interested in. The only way to know which occurrences of ‘x’ are your ‘x’ is by parsing the source into an AST and then performing analysis on it. Once you know the file locations, then the source itself can be modified. So to summarize, yes you are correct that the source is modified, but an AST + analysis is needed to find the correct locations.