T O P I C R E V I E W |
barryl72 |
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.
|
8 L A T E S T R E P L I E S (Newest First) |
barryl72 |
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. |
feline |
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 |
barryl72 |
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 |
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. |
barryl72 |
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 |
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. |
barryl72 |
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 |
Posted - Jun 21 2012 : 10:32:52 AM VA has the C++ refactoring command Add Include for exactly this type of situation:
http://www.wholetomato.com/products/features/autoUsing.asp |
|
|