Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 1731 Create from usage
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AshMcConnell
Junior Member

16 Posts

Posted - Aug 20 2009 :  05:49:29 AM  Show Profile  Reply with Quote
Hi Folks,

This looks like a fantastic addition to Visual Assist's refactorings.

However, I can't get this to work for methods and member variables (using Visual Studio 2008 SP1 with C++)

Any ideas what could be wrong? Enums appear to work (although it added an extra comma when I tried).


Thanks for your help
All the best,
Ash

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Aug 20 2009 :  1:22:38 PM  Show Profile  Reply with Quote
Can you post some sample code showing the problem? It works for me, in quite a few different situations. Also I am not seeing any extra unwanted comma's added when using this on an enum.

Using the following simple test code, VS2008, VA 1731 and C++ I added this to a header file:

class testCreateFromUsageCppClass
{
private:
	long m_nUsageMember;

public:
	enum UsageEnum { USE_CHOCOLATE, USE_BANANA, USE_ORANGE };

public:
	void usageMemberFunc();
	int constMemberMethod() const;
	void usageFuncWithParameter(CString argString);
};


and this to the matching cpp file:

void testCreateFromUsageCppClass::usageMemberFunc()
{
	countChocolateBars();
}


Create From Usage worked perfectly for me on the new function "countChocolateBars".

zen is the art of being at one with the two'ness
Go to Top of Page

AshMcConnell
Junior Member

16 Posts

Posted - Aug 20 2009 :  2:04:02 PM  Show Profile  Reply with Quote
Hi Feline,

Thanks for the reply, for the enum I started off with this

	enum BotClientState{
		BC_NOT_READY,
		BC_READY,
		BC_SENDING_GRIDPOS,
		BC_SENDING_PRELAP,
		BC_SENDING_DATA,
		BC_FINISHED
	};


I typed BotClientState::HELLO then did a create from usage refactor

The result was: -

	enum BotClientState{
		BC_NOT_READY,
		BC_READY,
		BC_SENDING_GRIDPOS,
		BC_SENDING_PRELAP,
		BC_SENDING_DATA,
		BC_FINISHED,,
		HELLO
	};


I think it may have something to do with namespaces. I typically have my code in a namespace of Sirocco, but I tried the refactor from the main.cpp which just "uses" the namespace rather than namespace Sirocco { ... }. When I tried a refactor from inside the class where the enum was defined it worked as expected.

As for the methods / variables, I was thinking it would work as follows (like eclipse iirc): -

myObject->myNewMethod(1, 2.0);


and then do a refactor on myNewMethod.

I tried your example and it worked as expected, I thought it might work from a pointer to an object, perhaps I'm asking too much from a beta :)

All the best,
Ash

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Aug 21 2009 :  12:16:48 PM  Show Profile  Reply with Quote
Your second point first, since it is easier, this does work for me. Using the class from earlier I added the following code to a cpp file:

static int testCreateFromUsage(CString argString)
{
	testCreateFromUsageCppClass *ptrTc;
	ptrTc->myNewMethod(1, 2.0);
}

trigger Create From Usage on this new method, and the class gained the new method:

void myNewMethod( int param1, double param2 );

Create From Usage works in my tests for both a class instance, a class pointer, and using:

testCreateFromUsageCppClass::methodOffClassName( 3.2 );

it is only a beta, but it is quite a well formed beta

If this is failing for you then we need to understand why.

The enum, I have just tried this test here, after placing your enum into my class in the .h file. When I added the new enum item into a class member function in the cpp file and triggered Create From Usage the enum item is added correctly to the header file, and all the commas are in the correct places.

Can you reproduce these problems on demand? Is so it would be very interesting and useful to see the code that is causing the problems. Namespaces can confuse VA sometimes, but this does not explain the enum. VA located the correct enum to update, so it should update it correctly.

zen is the art of being at one with the two'ness
Go to Top of Page

AshMcConnell
Junior Member

16 Posts

Posted - Aug 21 2009 :  12:49:19 PM  Show Profile  Reply with Quote
Hi Feline,

Forgot one thing, I am using boost::shared_ptr for my pointers, sorry I should have mentioned. I tried with a "normal" pointer and it worked as expected. I use boost so often I forget that i'm using it these days :)

I am heading out now, I'll try to get a small example that has the double comma problem in it tomorrow or Sunday hopefully.

Thanks for your help!
All the best,
Ash
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Aug 21 2009 :  3:27:51 PM  Show Profile  Reply with Quote
I've opened case=31318 to make Create From Usage available through overloaded operator ->.
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Sep 10 2009 :  3:10:24 PM  Show Profile  Reply with Quote
case=31318 is fixed in build 1734

Whole Tomato Software, Inc.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000