In those cases you can just do error recovery in the parser (truncating an erroring function for example) and then store out-of-band information necessary to reconstruct the original file
This is also necessary to deal with whitespace for example (if you just reformat the code, you didnt change the ast but you changed the file)
This is also necessary to deal with whitespace for example (if you just reformat the code, you didnt change the ast but you changed the file)