Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Toggle Function Definition Feature(Problems/Enhancements Solution Request)
Toggle Function Definition Feature [message #1844340] Thu, 09 September 2021 21:23 Go to next message
Utsav Trivedi is currently offline Utsav TrivediFriend
Messages: 5
Registered: September 2021
Junior Member
Hello Eclipse Community,

I'm using Code composer studio which is built on top of eclipse and when I try to toggle function definition from .h to .cpp file I have these questions and problems below. I had a quick look through other forums as well as C/C++ forums and didn't find any related posts.

1. Implementation in .h file becomes a inline method in .h file first and then moves to .cpp. Is there a way to skip creating inline function?
2. I have to wait for a few seconds before each toggle command else it throws an error (Cannot work without definition)
3. I can't select multiple methods and apply this feature. I want to be able to click on a class and move all implementations in .h file to .cpp instead of selecting one at at time.

Here is an example with Visual Studio: docs.wholetomato.com/default.asp

Im using CCS version: 10.3.1.00003

Thanks,

Utsav

[Updated on: Sun, 12 September 2021 21:25]

Report message to a moderator

Re: Toggle Function Definition Feature [message #1844368 is a reply to message #1844340] Sat, 11 September 2021 09:20 Go to previous messageGo to next message
David VavraFriend
Messages: 1407
Registered: October 2012
Senior Member
You are asking about a third party modification of CDT.
You are more likely to get answers at their site.
Re: Toggle Function Definition Feature [message #1844395 is a reply to message #1844368] Sun, 12 September 2021 21:28 Go to previous messageGo to next message
Utsav Trivedi is currently offline Utsav TrivediFriend
Messages: 5
Registered: September 2021
Junior Member
Hello David,

Thanks for getting back. Ive asked in the third party forum before posting here. So far they dont know if it is possible and they checked these forums as well for an answer.

The base is pretty much eclipse and has a eclipse.ini file. How does one go about doing it in eclipse C/C++? It might give me a hint to change some of the behaviours listed in question.

Thanks,

Utsav

[Updated on: Sun, 12 September 2021 21:28]

Report message to a moderator

Re: Toggle Function Definition Feature [message #1844408 is a reply to message #1844395] Mon, 13 September 2021 10:35 Go to previous messageGo to next message
David VavraFriend
Messages: 1407
Registered: October 2012
Senior Member
Well, I'm really not sure what it is you are trying to do
and I would have to read the entire site at the link you provided.
which is titled "Documentation for Visual Assist" just to find
what I think you are doing. Maybe you could provide a more specific link?

FWIW: I usually keep the header and cpp files side by side when I'm editing
so I don't usually hunt for definitions or find myself switching editor views.

Quote:
Implementation in .h file becomes a inline method in .h file first and then moves to .cpp
and
Quote:
I want to be able to click on a class and move all implementations in .h file to .cpp instead of selecting one at at time.


Maybe I'm having a dense moment but I really have no idea what that means.
What do you mean by "moving" ?
Do you mean moving to a different file for viewing?
Or do you mean actually moving something between header and .cpp files?

If you mean physically moving, what's wrong with cut and paste?

Quote:
I have to wait for a few seconds before each toggle command else it throws an error

Do you mean the "Toggle Source/Header" menu item or something else?

Re: Toggle Function Definition Feature [message #1844428 is a reply to message #1844408] Mon, 13 September 2021 22:00 Go to previous messageGo to next message
Utsav Trivedi is currently offline Utsav TrivediFriend
Messages: 5
Registered: September 2021
Junior Member
Hello David,

Thanks for being patient. I realised I pasted the wrong link and that will cause frustation for people. Apologies. Here is the feature. I'm talking about.
Move Method Implementations to Source File: https://docs.wholetomato.com/default.asp?W684
Eclipse Equivalent but only limited to single method: https://rtist.hcldoc.com/help/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_toggle.htm

As for why cut and paste would not be an ideal approach or even recommended is because one might have to work on huge codebases created by others.
Definitions for C++ Class methods are .h or .hpp files where there are more than 50-70 definitions available. Cut and paste would take too much time and typing.
Currently eclipse base in Code Composer studio only has the option to move one method at a time.

One has to apply the refactoring feature twice in Code Composer Studio. From the second link in this reply, the definition is generated as a inline method directly in the .h or .hpp file and then moved to .cpp.

The delay and errors I face might only be limited to Code Composer Studio. I am not sure.

I just wanted some insight as to if it possible to refactor methods in .h/.hpp files the same way visual studio has.

Thanks,

Utsav






[Updated on: Mon, 13 September 2021 22:13]

Report message to a moderator

Re: Toggle Function Definition Feature [message #1844433 is a reply to message #1844428] Tue, 14 September 2021 00:48 Go to previous messageGo to next message
David VavraFriend
Messages: 1407
Registered: October 2012
Senior Member
OK. Makes more sense now.
Never used it. It's marginally useful IMO.

The Eclipse/CDT version doesn't seem to allow selecting a class
before refractoring. It moved the definition to inline in the header.
Selecting it again, moved it to the cpp file. I didn't encounter any
errors trying to move more than one in a few seconds.

I tried to move more than one definition by selecting some grouped
together in the header and it only affected the first while offering
to connect to CodeTogether (or something like that) which I declined.

Don't know if this answers your questions or not.

As for time, I don't know how much you want to do but you've just spent
four days not doing it.

As for doing this with a code base you didn't create yourself, changing
it seems to mean forsaking any hope of easily accepting future revisions.
Then you gotta wonder why they chose implementing things in the
header to begin with. There may be very good reasons for doing so that
you are ignoring.

To be honest, I'm always leery of allowing software to make massive
changes to my source. I've had problems in the past simply renaming
things that lead to a lot of grief. Cut and paste for something like this
might take a little more effort but at least I'm aware of what's
happening at every step. YMMV.

Re: Toggle Function Definition Feature [message #1844434 is a reply to message #1844433] Tue, 14 September 2021 01:47 Go to previous messageGo to next message
Utsav Trivedi is currently offline Utsav TrivediFriend
Messages: 5
Registered: September 2021
Junior Member
Hello David,

Thanks for putting the time in to look at this for me. Question number 2 has been answered. Ill try putting things in perspective.

Since Visual studio already has that feature and extensions, I've managed to get by copy pasting my header and source files seamlessly and quickly, but for that Ive had to create a new project in a different ide and move things over from Code Composer studio each time. I'd say its fair to declare this can be categorised as poor user experience and can be improved upon to provide a more "In-House" experience for developers :)

The motivation behind my post was to find out if there is a way to do this within eclipse and save even more time.

I'm unsure from your reply about question 1 and 3. So is right to assume this won't be possible? If you confirm I will close this post or whatever the procedure is. I have to look this up since I am a newcomer.

Thanks,

Utsav

[Updated on: Tue, 14 September 2021 03:12]

Report message to a moderator

Re: Toggle Function Definition Feature [message #1844437 is a reply to message #1844434] Tue, 14 September 2021 03:27 Go to previous messageGo to next message
David VavraFriend
Messages: 1407
Registered: October 2012
Senior Member
Quote:
I'm unsure from your reply about question 1 and 3


  • Q1: Implementation in .h file becomes a inline method in .h file first and then moves to .cpp.
    A: Eclipse seems to work the same way.
  • Q3: I can't select multiple methods and apply this feature
    Eclipse seems to move one function at a time.
    There doesn't appear to be any way to select multiple functions for a move

So, in general, what you want to do is not possible.
Re: Toggle Function Definition Feature [message #1844438 is a reply to message #1844437] Tue, 14 September 2021 04:59 Go to previous message
Utsav Trivedi is currently offline Utsav TrivediFriend
Messages: 5
Registered: September 2021
Junior Member
Hello David,

Makes sense now. So to conclude from your previous responses, this will not be an addtion in the future.

If developers want to, they have to rely on other IDEs to refactor which is not ideal but works for now. At least developers know where to look now. If demand increases this might change and be up for consideration as an enhancement to make user experience better.

Thanks,

Utsav

Previous Topic:error
Next Topic:Strange Extra Characters in Console Output
Goto Forum:
  


Current Time: Mon Dec 06 21:56:05 GMT 2021

Powered by FUDForum. Page generated in 0.02830 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top