Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Move implementation to source file problem

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
eve Posted - Oct 24 2007 : 07:42:18 AM
Hi,

I have a problem with the 'Move implementation to source file' refactoring:

--- mytest_testclass.h ---
namespace MYTEST {
   class TestClass {
      int testFunction1();
      int testfunction2() {
         return 2;
      }
   }; 
}

--- mytest_testclass.cpp ---
#include "mytest_testclass.h"

namespace MYTEST {
   class SomeForwardDeclaration;
}
   
using namespace MYTEST;

int TestClass::testFunction1() {
   return 1;
}

If I now apply 'move implementation' on testFunction2, then this is the result:

--- mytest_testclass.cpp ---
#include "mytest_testclass.h"

namespace MYTEST {
   class SomeForwardDeclaration;

   int TestClass::testfunction2() {
      return 2;
   }
}
   
using namespace MYTEST;

int TestClass::testFunction1() {
   return 1;
}

and not

--- mytest_testclass.cpp ---

#include "mytest_testclass.h"

namespace MYTEST {
   class SomeForwardDeclaration;
}
   
using namespace MYTEST;

int MYTEST::TestClass::testFunction1() {
   return 1;
}

I suppose this could be desired functionality, but this makes this (rather handy) refactoring unusable for me.

regards,
eli
6   L A T E S T    R E P L I E S    (Newest First)
eve Posted - Oct 25 2007 : 01:33:50 AM
It's a feature...
Enabling format after paste indeed solves the formatting problem, even when using drag and drop.

thanks for your help feline,
eli
feline Posted - Oct 24 2007 : 1:47:20 PM
Try right click inside VA Outline -> Format

I am not sure if this is a bug or a feature, code formatting is a "tricky" area, so doing nothing is sometimes the best answer.

Did you drag and drop or cut and paste?
Do you have VA's format after paste turned on or off?
eve Posted - Oct 24 2007 : 08:51:39 AM
Nice, I did not know about that. Thanks!
It's still not perfect because my indentation is wrong:

before move:

namespace
   {
   void test {}
   }

someFunction()
   {
   }

after move:

namespace
   {
   }

   void test {}

someFunction()
   {
   }


Or maybe I should log that as a bug?
feline Posted - Oct 24 2007 : 08:45:51 AM
Are you using VA Outline? If so you can use VA Outline to drag (or use cut and paste) the new implementation to the required spot in the cpp file. You can also move several functions at one time.
eve Posted - Oct 24 2007 : 08:33:23 AM
It makes sense, but I don't intent to mutilate my code like that ;-)

Wouldn't it be possible to make that configurable? Maybe when you guys are working on the 'create implementation' order (case=2161), you could have a look at this at the same time...

thanks for the workaround though,
eli
feline Posted - Oct 24 2007 : 08:17:28 AM
This happens because VA is designed to place the implementation into the namespace block, if one exists. In this case there are two valid locations to place the implementation, and VA has no way of knowing which one you want to use.

Here the solution will be to "hide" the code:

namespace MYTEST {
   class SomeForwardDeclaration;
}


from VA. This should work, but it is slightly messy. Change the cpp file to read:

#define START_HIDDEN_NAMESPACE(x) namespace x {
#define END_HIDDEN_NAMESPACE }

START_HIDDEN_NAMESPACE(MYTEST)
   class SomeForwardDeclaration;
END_HIDDEN_NAMESPACE


And add the following code to VA's stdafx.h file:

#define START_HIDDEN_NAMESPACE(x)
#define END_HIDDEN_NAMESPACE


as explained here:

http://docs.wholetomato.com?W302

I have not actually tested this exact case, but I have used this approach before quite successfully. The idea is that VA does not see the namespace block, so it never uses it. Hopefully this makes sense.

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