Author |
Topic |
|
barryl72
Junior Member
15 Posts |
Posted - Jun 21 2012 : 09:42:53 AM
|
Hi,
I've had a search and I can't see this functionality existing but... in C#, for example it's possible to just type a class, resolve it, and the required 'using' is added to the top of the file.
I currently do this for C++
* 'Goto Implementation' for a symbol (e.g. by pressing alt+g) ** Choose header file, if necessary. * File opens - I then right click copy full path * Ctrl+tab back to file I was working on, * Add #include 'paste from clipboard' at the top of the file. * Replace '\\' with '/' * Delete off front of full path as appropriate.
Couldn't all but the last step be automated in VAX? It would be a nice feature, and everything seems to be in place for it.
Apologies if this is a repost.
Thanks,
- Barry.
|
Edited by - barryl72 on Jun 21 2012 09:43:22 AM |
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
|
barryl72
Junior Member
15 Posts |
Posted - Jun 21 2012 : 10:47:09 AM
|
Marvellous! I just couldn't find that, and thought it should exist. I was looking in the wrong place.
I have just tried it, and it works about 75% of the time: sometimes we have the situation where we forward declare smart-pointer typedefs, and it seems the 'Add Include' just picks a random header from the list (but alt+g on the same symbol gives a choice of headers).
Is it possible to show a drop down when there is more than one place the symbol is defined? |
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jun 21 2012 : 4:50:04 PM
|
Would you be able to post a simple code sample, to show me the sort of thing you are having problems with? Add Include is designed to work out the correct header as often as possible. |
zen is the art of being at one with the two'ness |
|
|
barryl72
Junior Member
15 Posts |
Posted - Jun 26 2012 : 02:58:16 AM
|
quote: Originally posted by feline
Would you be able to post a simple code sample, to show me the sort of thing you are having problems with? Add Include is designed to work out the correct header as often as possible.
I guess the simplest example would be to have something like:
-- header1.h #pragma once class Widget; typedef boost::shared_ptr<Widget> WidgetPtr;
-- header2.h #pragma once class Widget; typedef boost::shared_ptr<Widget> WidgetPtr;
-- Widget.h #pragma once class Widget { // definitions }; typedef boost::shared_ptr<Widget> WidgetPtr;
and then 'Add Include' seems to pick out 'header1.h' or 'header2.h', in preference to 'widget.h'. All three headers are presented if you do 'Goto' symbol - it would be nice for 'Add Include' to do the same.
|
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jun 26 2012 : 2:15:51 PM
|
Thank you for the clear sample code, I can see why this might confuse things. I have created a simple VS2010 solution, with this test code in it, and uploaded it here:
http://forum.wholetomato.com/colin/forumimages/topic_10775_add_include_duplicate_test.zip
If you can download and open this solution, I am not sure which IDE you are using, so I just guessed, the test and my results are described in the file "add_include_duplicate_test.cpp"
Can you check and see if you get the same results please? I am seeing 3 entries for Alt-g, as expected, but Add Include is picking up the correct header file for me. So I am wondering if you will see the same results. Add Include is trying to work out the correct header to use, so it would be useful to work out what is confusing it in your main solution. |
zen is the art of being at one with the two'ness |
|
|
barryl72
Junior Member
15 Posts |
Posted - Jun 29 2012 : 02:54:00 AM
|
quote: Originally posted by feline
Thank you for the clear sample code, I can see why this might confuse things. I have created a simple VS2010 solution, with this test code in it, and uploaded it here:
http://forum.wholetomato.com/colin/forumimages/topic_10775_add_include_duplicate_test.zip
If you can download and open this solution, I am not sure which IDE you are using, so I just guessed, the test and my results are described in the file "add_include_duplicate_test.cpp"
Can you check and see if you get the same results please? I am seeing 3 entries for Alt-g, as expected, but Add Include is picking up the correct header file for me. So I am wondering if you will see the same results. Add Include is trying to work out the correct header to use, so it would be useful to work out what is confusing it in your main solution.
Hi - I've opened the code in vs2010 (yes that's my IDE), and the alt+g behaviour is fine. Doing 'add include' automatically and repeatably inserts 'header1.h'.
Whilst this is ok, it's not right: I would like VAX to offer me the choice. The convoluted situation we have is the following:
widget.h: class Widget { /* stuff */ }; typedef boost::shared_ptr<Widget> WidgetPtr;
forward_definitions.h: class Widget; typedef boost::shared_ptr<Widget> WidgetPtr;
some_massive_header_with_lots_build_time_overhead.h #include "massive_other_header.h" class Widget; typedef boost::shared_ptr<Widget> WidgetPtr; // ... other stuff
lazy_developer_header.h // can't be bothered to include 'forward_definitions.h' class Widget; typedef boost::shared_ptr<Widget> WidgetPtr; // ... other stuff
What I have seen in our code base is that 'Add Include' can add 'some_massive_header_with_lots_build_time_overhead.h' rather than, say, 'foward_definitions.h' or 'widget.h'.
It's not a huge issue, but it would be a nice addition.
|
|
|
feline
Whole Tomato Software
United Kingdom
19021 Posts |
Posted - Jun 29 2012 : 5:02:41 PM
|
The same test project as me, but Add Include is doing something different for you, and today, re-testing the same project, Add Include is now adding "header2.h"
It looks like the initial correct behaviour on my test system was more luck than judgement, so I have put in a feature request to have Add Include prompt the user when it is unclear, so you can make the final choice of which header to use:
case=67573 |
zen is the art of being at one with the two'ness |
|
|
barryl72
Junior Member
15 Posts |
Posted - Jul 03 2012 : 03:36:39 AM
|
quote: Originally posted by feline
The same test project as me, but Add Include is doing something different for you, and today, re-testing the same project, Add Include is now adding "header2.h"
It looks like the initial correct behaviour on my test system was more luck than judgement, so I have put in a feature request to have Add Include prompt the user when it is unclear, so you can make the final choice of which header to use:
case=67573
Thanks. |
|
|
|
Topic |
|