Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Organize includes

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
jensa Posted - Mar 26 2012 : 04:12:32 AM
Hi,

In our company, we have a rule on how to organize include statements in files. However, when people use the IDE to automatically add include statements, they get just appended after the last include in the file. It would be great if you implemented an autoamtic sorting of include statement based on path prefixes, such that I can specify which includes get grouped and where.

Best regards,
Jens
5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Mar 27 2012 : 1:56:30 PM
You might find this macro an interesting start point:

http://support.wholetomato.com?W445

it does not attempt to sort anything, but it does scan over a block of selected lines, and look at each line in turn, before updating it. So you should be able to use the same logic to look at each selected #include line in turn, to work out how you want to sort them in memory, before replacing the selected code with the sorted lines.

For the Eclipse feature, the first good search result I found for this was this:

http://www.vasanth.in/2008/11/18/eclipse-tip-organize-imports-and-java-import-style/

which seems to be describing a concept that simply does not apply to C++, using wild cards to group import / include statements.
jensa Posted - Mar 27 2012 : 11:39:20 AM
Thanks for the idea, I will certainly try out an IDE macro. I've never done that before, so it is a good start to learn something new.

Just for the records, I came to the idea when I remembered using Eclipse some time ago. They had a feature "Organize imports" for Java source code which worked quite well. Maybe you could have a look at their functionality to get a glimpse.
feline Posted - Mar 27 2012 : 10:52:09 AM
Clearly this is going to get quite complex quite quickly, and it is also very specific to your situation, so it is unlikely we are going to try and add a feature like this to VA.

Have you considered using an IDE macro to do this? Since you can hard code the sorting rules you should be able to do this in a relatively simple manor, since you don't need to allow for all of the settings required to set and edit these rules.
jensa Posted - Mar 27 2012 : 03:08:51 AM
I think it has to be more complex than a simple alphabetical sort. What I am thinking of is a set of rules where I can configure that
0. for a file file.cpp, place the file.h header at the top
1. standard headers
2. some library headers
3. some other library headers

Basically, there should be a list of prefixes for includes which I can configure that defines the sort order.
feline Posted - Mar 26 2012 : 2:35:30 PM
Are you aware of VA's sort lines command:

http://www.wholetomato.com/products/features/sort.asp

Automatically sorting the #include lines is one thing, but you seem to be asking for something quite a bit more complex, and thus requiring a lot more rules, than a simple sort of a block of lines.

Will simply sorting the #include statements with the sort lines command be enough, or do your company guidelines call for something more complex?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000