[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Refactoring idea
|
Hi Alec
If I got it right, you don't want to change the scope the function is a member of, right?
Your suggestion seems to be very close to the "Toggle Function" feature (from the Refactor menu). Except that toggling a function does not send the implementation to the clipboard. It consists of two steps.
Starting with something like your Example:
//In S.h
struct S {
void foo() {
}
};
Having the caret somewhere in the member function foo and invoking the Toggle Function refactoring (through the menu or alt + shift + T) the first time results in the following:
//In S.h
struct S {
void foo();
};
inline void S::foo() {
}
This would allow you to cut the function definition for having it in the clipboard. You can also toggle once more to move the function implementation to a corresponding .cpp file. Which is the place you most likely want to have your function defined. Result:
//S.h
struct S {
void foo();
};
//S.cpp (new file if it did not exist)
#include "S.h"
void S::foo() {
}
Kind regards
Thomas
-----Original Message-----
From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Alec Teal
Sent: Dienstag, 26. November 2013 23:50
To: cdt-dev@xxxxxxxxxxx
Subject: [cdt-dev] Refactoring idea
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