Expand cursor documentation
Q: I have a case where I have one line in a method and need to insert say 5-6 lines replacing it. When I do it using visitMethodDecl I get the error that expected a template which will replace 1 statement with 1 but created 6 ..What is the workaround for it ?
Answer: Read this thread
From Tim:
one option is to return a block of statements { a; b; c; }.. and then call RemoveUnneededBlock right after
it's a creative way to solve this that I've used in the past as well.. works well enough for the code you already have most likely
the other option is to look up to the block that the variable declaration that you have is defined within, and replace the statements within that block with a new or mapped collection
both of those end up with the same result: your variable declaration replaced by multiple statements, but each only replacing one element of the LST with another
here's an example where I call RemoveUnneededBlock after a replacement
To help, we should expand on getCursor, updateCursor, and new Cursor as well as provide examples.
@timtebeek When you have time, would you mind assisting with examples here?
Specifically:
- I am not sure when you'd use the different cursor options (
getCursor,updateCursor,new Cursor).- For these, it would be swell to have an example with them.
- I'd love an example of some code that returns a block of statements and then calls the remove unneeded block to have some context as to why someone might do that.
Once I have some examples and more context, I'm happy to update the doc accordingly. ^_^