Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Automotically add #include or using directives!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

e1e0n
New Member

4 Posts

Posted - May 21 2008 :  3:32:27 PM  Show Profile  Reply with Quote
When I type complete varible declaration or otherwise use something from *.h file (ie, compiler will need class declaration or anything else which could be detected by VA) VA could include this file

ie:

#include "locatedIncludeFolder/MyCoolControl.h"

class A
{
...
private:

MyCoolControl m_MyCoolControl;
}

I type this: MyCoolControl m_MyCoolControl;
VA inserts this: #include "locatedIncludeFolder/MyCoolControl.h"

is it possible?

Thanks,
Leo

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - May 21 2008 :  5:34:36 PM  Show Profile  Reply with Quote
We are looking into a feature to suggest missing #include statements, but even that "simple" operation can be quite tricky in C++

case=226

There are some tricky template and macro code out there, so implementing such a feature is not as obvious as it may seems at first sight.

Edited by - accord on May 21 2008 5:54:57 PM
Go to Top of Page

Dans
Senior Member

Ukraine
45 Posts

Posted - May 22 2008 :  08:59:25 AM  Show Profile  Reply with Quote
I think this thing should have more interactive input.

When we add include:
1. We have "unknown identifier" error
2. We know that this include should be used

What expected:
1. Place carret on unknown identifier, press shortcut - VA suggests headers that contain this identifier

2. Place carret in empty space, press same shortcut - VA suggests list of availaible files that can be included (Project Include folders, VS Include folders, etc). It should be similar to "Open File in Workspace"

When user selects needful file you should search for last #include directive in file and insert #include keyword with selected header (when it's first just insert as first line). Current line position sould not be changed

TIA
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18951 Posts

Posted - May 22 2008 :  10:08:47 AM  Show Profile  Reply with Quote
VA suggesting possible header files for the symbol, this makes sense and may be the approach we end up taking.

The second idea, of sitting in some empty space, what is the advantage here? If you type a #include "" or #include <> line VA will already produce a listbox that you can filter, listing header files that are suitable.

The placing of the #include line, this is not automatically straight forward, what happens when #include lines are wrapped in #ifdef statements? What happens when the last #include line in the file is at line 500, since it is half way down the file, and there are a load of functions above it?

We will have to do something half sensible, but there are always edge cases to consider.

zen is the art of being at one with the two'ness
Go to Top of Page

Dans
Senior Member

Ukraine
45 Posts

Posted - May 23 2008 :  08:26:18 AM  Show Profile  Reply with Quote
quote:
VA suggesting possible header files for the symbol, this makes sense and may be the approach we end up taking.


It will be very useful. But not always you can suggest best file. For example with boost - for using boost::mutex you need to include <boost/thread/mutex.hpp> but there is more common include <boost/thread.hpp> It should be handled and suggested both includes.
quote:

The second idea, of sitting in some empty space, what is the advantage here? If you type a #include "" or #include <> line VA will already produce a listbox that you can filter, listing header files that are suitable.


I suggested this because, usually, i don't want to leave method that i currently changes. It just extension of suggesting include for "unknown identifier" but without filtering. IOW it's "nice to have" thing. Also i will use it to check that my project contain all needful or contain obsolete include directories
quote:

The placing of the #include line, this is not automatically straight forward, what happens when #include lines are wrapped in #ifdef statements? What happens when the last #include line in the file is at line 500, since it is half way down the file, and there are a load of functions above it?

We will have to do something half sensible, but there are always edge cases to consider.


Don't try to cover all exceptions, suggested algorithm works in 90% cases. If i know that my file contain sophisticated include scheme - i'll never use "smart" tool . Also we can increase algorithm strength: last #include up to current line, do not use #include that in method, etc.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000