Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Refactoring idea

Hi Lukas, (and Thomas),

I cannot believe that all that time it has been there. I assumed toggle function was accidentally placed in the refactoring menu and just folded a function. How daft of me!

Is there a cheat-sheet of refactorings? I've rarely used them with C++ because I don't trust them to understand/manage memory correctly. Having embraced them with Python and (urgh) Java (Android stuff) perhaps I ought to! I will spend some time tomorrow playing with it.

To add to the toggle function thing it would be nice if there was one along side it to remove variable names from prototypes. Some might say "Why would you want to do that?" I and some people I know believe a well-designed interface to be one where the types and function names are sufficient to infer the properties.

A "move to/from namespace" would also be nice, with a choice of a "using", absolute specifier and a relative specifier.

Eclipse plugins have always interested me, is the refactoring system "difficult"?

Forgive the barrage of questions, I am excited at the idea of being able to trust an IDE to do such things!

Alec

On 27/11/13 07:40, Lukas Felber wrote:
Hi Alec

What you describe is actually already there in CDT and is called "toggle function". Take your example bellow and call toggle-function from the refactoring menu (or with shift+alt+t) while the caret and you will get what you are looking for. Call it again and the definition of "f" will be moved to a source file (A.cpp if the class definiton is in A.h).

enjoy using it!

Lukas


Am 26.11.2013 23:50, schrieb Alec Teal:
Hey all,

A really simple yet really useful refactoring to offer would be to pull method definitions out of a class and stick them somewhere else (to clipboard for example).

How many times have you accidentally defined methods while writing the class, I'd love to just highlight a block and have it leave the declarations and put something I can just copy and paste into the code file for me. It'd be great if it could also remove variable names.

Example:

class A {
    U f(V x) {
        /*blah*/
    }
};

To:
class A {
    U f(V);
};

With:

U A::f(V x) {
    /*blah*/
}

On the clipboard (or something)

I think it'd be easy enough to do. Carry forward any surrounding tokens provided it's not "virtual" and such. Even constructor initialiser lists wouldn't be a problem.

I suggest this because it's a task could (almost) be accomplished by little more than a regex rule. It'd save me a lot of time.

Alec
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev



Back to the top