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
 Feature Requests
 Refactor suggestion: implement interface
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

hal
Junior Member

11 Posts

Posted - Feb 25 2009 :  02:56:31 AM  Show Profile  Reply with Quote
Hi. Thanks for this very useful software.

Suggestion:
lets make new refactor feature - "Implement Interface".
Like same in VS2005 C# refactoring, but for C++.

For example:

class SomeClass : public ISomeInterface
{
};


when select "Implement Interface" in "refactor" context menu on ISomeInterface symbol - all virtual functions declarations will appear in class scope.

Put'em all (pure and not), because unused declarations programmer cut off manually. Only one: don't repeat same virtual function declarations when declaration already in scope.

drac
Senior Member

Germany
49 Posts

Posted - Feb 25 2009 :  07:09:42 AM  Show Profile  Reply with Quote
I really second this. I suggested "Create implementation" for more than one function (http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=8524) which would help in this regard.

But "Implement Interface" would take that to the next level, no need for me to copy the interface manually.

It would be nice also to have this a code snippet, to be able to change what goes inside that empty function:

throw std::exception("not implemented");
or
assert(!"not implemented");

Cheers.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Feb 26 2009 :  09:22:27 AM  Show Profile  Reply with Quote
We are considering allowing you to trigger Create Implementation on several functions at once via VA Outline:

case=7787

We are also considering a command to implement the interface / override all virtual functions that have been inherited:

case=1505
If this used the existing VA Snippet "Refactor Create Implementation" (I don't know if it will, but this seems reasonable) then you could simply edit this snippet to give the new functions a default implementation.

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

hal
Junior Member

11 Posts

Posted - Feb 27 2009 :  01:24:20 AM  Show Profile  Reply with Quote
I found it will be convinient implement this feature in that way:

for example:

class IInterface1
{public:
    virtual void Func1() = 0;
    virtual void Func2() = 0;
 protected:
    virtual int Func3() = 0;
};
class IInterface2
{public:
    virtual Func4() const = 0;
};

class Example : public IInterface1, public IInterface2
{
};


When select "Implement interface" from "Refactor context menu":

1) on "Example" symbol - then VA inserts in class scope all public and protected declarations of virtual and pure virtual function for all base classes.
In result class scope may look like this:

class Example : public IInterface1, public IInterface2
{public:
    virtual void Func1();
    virtual void Func2();
    virtual void Func4() const;
 protected:
    virtual int Func3();
};


2)on "IInterface1" or "IInterface2" symbols separately - then VA inserts in class scope all public and protected declarations of virtual and pure virtual functions for selected base class.

In result class scope may look like this (with selection of IInterface2, for example):

class Example : public IInterface1, public IInterface2
{public:
    virtual void Func4() const;
};


Insertion of functions declaration is enough. Programmer may select "Create Implementation" on used functions, and linker will swearing on not implemented functions.

It will be also convinient to have two possibilities in "Refactor context menu":
1)"Implement interface" - with full interface declaration insertion.
2)"Implement interface..." - with a dialog like in "Rename" feature,
tree of functions selection may look like this (with full selection by default):

+ IInterface1
  + public
    - void Func1()
    - void Func2()
  + protected
    - int Func3()
+ IInterface2
  + public
    - void Func4() const


Thanks. Best regards.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Feb 27 2009 :  09:05:20 AM  Show Profile  Reply with Quote
I am not sure how this will be done, but remember the interface may be coming from a class 3 or 4 "steps" deep in the inheritance hierarchy, so it is quite possible that you cannot just trigger the command on the interface name, since it is not present in the current file.

Some form of dialog with check boxes has been suggested for this feature, to give control over which bits are implemented. Grouping the items by class makes sense and is a good suggestion, thank you.

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

hal
Junior Member

11 Posts

Posted - Apr 02 2009 :  07:46:26 AM  Show Profile  Reply with Quote
Very useful feature...
Please, tell when it may be done?

up
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Apr 03 2009 :  10:14:27 AM  Show Profile  Reply with Quote
We are considering this, and hoping to do it sooner rather than later, but unfortunately I don't have any form of estimate on when this will be done.

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

support
Whole Tomato Software

5566 Posts

Posted - Jan 24 2011 :  4:03:35 PM  Show Profile  Reply with Quote
case=1505 is implemented in build 1840

Whole Tomato Software, Inc.
Go to Top of Page

hal
Junior Member

11 Posts

Posted - Jan 26 2011 :  01:42:19 AM  Show Profile  Reply with Quote
Thanks! Great feature for C++!
Must have and must use! Its very useful!

I use C# as second programming language.
It seems that in C# this feature does not work.
Do you planning to add this feature for C# too?

Cheers.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Jan 27 2011 :  11:28:26 AM  Show Profile  Reply with Quote
Using VS2005 and VA 1840 I have added the following code to a .cs file:

abstract class test_implement_parent
{
    protected abstract string getNameOfClass();
}

class test_implement_child : test_implement_parent
{
}

VA is offering me the command "Implement Virtual Methods..." on the class "test_implement_child", and this works for me when I trigger it.

Can you try this test on your system please, and see if you get the same results?

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

hal
Junior Member

11 Posts

Posted - Feb 01 2011 :  2:33:35 PM  Show Profile  Reply with Quote
It seems that you right. Thanks.

But I found one subtle thing in C#.
For my test I write class:

class SomeDisposable : IDisposable
{
}

Next I use "Refactor Context Menu" on IDisposable interface and select "Implement Interface" item. Interface implemented for me. Its ok.
Next I clear implemented interface from class.
Next I again use "Refactor Context Menu" and select "Implement Interface". Now I see Visual Assist dialogue box with "No methods implemented" message. Class body remains empty. This is strange.
Next I again use "Refactor Context Menu" and select "Implement Interface". Now again ok - interface implemented.

I can reproduce this many times. I don't know if it a bug?

Cheers.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 02 2011 :  10:26:02 AM  Show Profile  Reply with Quote
You have to wait up to a few seconds (depending on the file size) before you right click on the base class so Visual Assist can catch up the changes. If I do your steps without waiting a sec or two (in a very small file), I got the same result as you, which is kind of normal. It works fine for me when I wait a moment before re-doing the refactoring.

Edited by - accord on Feb 02 2011 10:37:55 AM
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