So I have a project I'm working on and it will require an LLM to update existing code and write it back to the editor,where I'm having issues is finding a good way to update anywhere within the code without Messing up unchanged ones, I know converting the source code to AST can help when doing function/class wide updates it has easy as transversing the nodes and identifying which function or classes require change. But for use cases where the updates are limited to few lines of code or for code that are just scripts with no classes and functions,I can't really come up with a good solution to update the code with messing up other lines that aren't affected, I've tried searching on Google to see similar implementations or articles on it but all of them only talk about how to parse and transverse AST. EDIT: I do not mean AST can't parse code without functions and classes,there are few ways I can currently implement this,first is having the LLM rewrite the entire file and add updates where needed but I start facing issues like token limit if I follow this approach, the second way is to localized changes to functions/classes so that if it needs to make changes to any class/function the LLM can make those changes and all I have to do is find the function/class and over write it completely with the updated implementation but like I pointed out earlier I start running into issues when the code being changed is not contained within a class or function and I can also run into token limit errors if the class or function is too long. so I need to figure out how to make these updates regardless of where the updates are made that's what I'm having issues with. Continue reading...