Bug 511086 - [Feature request] Implement batch 'Toggle function' for cases where you need to toggle multiply functions.
Summary: [Feature request] Implement batch 'Toggle function' for cases where you need ...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: Next   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2017-01-26 08:12 EST by soman namos CLA
Modified: 2020-09-04 15:27 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description soman namos CLA 2017-01-26 08:12:29 EST
Sometimes when you change the code you can decide to make some certain class templated i.e. class A {}; becomes template<typename T> class A{}; In such cases if you have all funcs' implementations in a.cpp file you need to manually move the implementation to header which could be annoying if you have many functions. The same is true for constexpr functions. It would be good to see some automatic function which moves (or maybe copies for safety) implementation from source to header.

Little example:

1) We have two files
=====A.HPP=====
// ifdefs, includes, etc.

class A {
public:
  void foo();
};

// ...
===============

=====A.CPP=====
// idefs, includes, etc.
void A::foo() {
  // Do something
}
===============

2) Then we use Eclipse Refactoring somehow like 'Refactor => Move implementation to header' and get changed header file:

=====A.HPP=====
class A {
public:
  void foo() {
    // Do something
  }
};

a.cpp could be left unchanged (for safety) or deleted.

Additional information of possible implementation conditions:
1) We should have 'Preview' button.
2) It would be very nice if function order and entire header file structure won't be changed (sorted, formatted, etc.)
3) It should work both with class members and free functions.
4) We should be able to choose which functions to move (for example I want to move only 1 of 5 functions which I made a constexpr. In this case cpp file shouldn't be deleted or unchanged after operation. It still should has 4 functions.
Comment 1 Marc-André Laperle CLA 2017-01-26 21:25:15 EST
I think the "Toggle Function" refactoring already does something similar. Have you tried it out?
Comment 2 soman namos CLA 2017-01-27 00:54:55 EST
(In reply to Marc-André Laperle from comment #1)
> I think the "Toggle Function" refactoring already does something similar.
> Have you tried it out?

This is exactly what I need, thanks. But I interested is there exist any way to run it multiply times for multiply functions? The user still should to press 'Shift + Alt + T' multiply times for every function even if he selects multiply functions in editor. I still want to request the feature to have a way to do it once for multiply functions. As possible gui solutions it should be done via selecting all the functions in the editor and/or via some window with checkboxes where you can check necessary functions to toggle. I'll rename this FR, but let me know if I should create a new Feature request for such feature.
Comment 3 Marc-André Laperle CLA 2017-01-27 09:43:52 EST
(In reply to soman namos from comment #2)
> (In reply to Marc-André Laperle from comment #1)
> > I think the "Toggle Function" refactoring already does something similar.
> > Have you tried it out?
> 
> This is exactly what I need, thanks. But I interested is there exist any way
> to run it multiply times for multiply functions?

Not currently, no.

> I'll rename this FR, but let me know if I should create a new Feature
> request for such feature.

I think we can keep this one, with the title updated it's pretty clear. Thanks!