Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Introduce Variable for getter function

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
DBlake Posted - Jun 08 2025 : 02:38:33 AM
It happens very often, while refactoring someone else's code, when you need to simplify the expression for debugging and put the function value into the variable

 if (getParent()) {
   assert(!getParent()->findChildById(newId) ||| getParent()->findChildById(newId) == this);

Previously, a few years ago, when you selected the first getParent() statement and chose Introduce Variable, the VA offered the choice of
`Replace selection` or `Replace 3 occurencess`, and then I replaced them all to get this:

 Node* parent = getParent();
 if (parent) {
   assert(! parent->findChildById(newId) || parent->findChildById(newId) == this); 

This was very handy because I know that my getParent always returns the same value.
Now VA doesn't offer to replace them all, but only one value, and that's annoying.

As a workaround I found a way out, I select only `getParent` without brackets (), and then it replaces them all, but I have to remove extra brackets in the code manually, which is not very convenient.
I would like you to return the ability to cache the return value of functions into a variable.
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Jun 10 2025 : 1:10:14 PM
Introduce Variable offers to replace all instances in some situations, but not in this situation. But as you say, go back to an old version of VA, and it did offer.

Seems like a bug to me, so I have put in a bug report for this:

case=165858

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000