I am using the latest Juno CDT release and I am trying to explore the CDT refactoring tools in it.
More often than not, when trying to extract a piece of code into a separate function I see the error:
“Too many declarations in selection.” and I don’t know how to proceed.
What seems to characterize such occurrences is having many object creations on the stack (maybe also dynamic allocations – I’m not sure).
Does anybody know why would the refactoring mechanism care if there are more than x object declarations?
What is a best practice for refactoring such code?
I guess you’re confusing heap with stack in your question, the latter makes more sense.
Any stack variables that are seen before the piece of code you want to extract will be changed to parameters of the extracted function. I think if there are too many of them you’ll get this error message. It’s questionable if one want’s to have a function with more than 5 parameters.