Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Goto definition for boost shared pointers

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
Frunobulax Posted - Feb 21 2011 : 05:45:47 AM
Hi,

consider the following Code, which is typical for our coding style:

    class _Run;
    typedef boost::shared_ptr<my_namespace::_Run> Run;
    typedef boost::shared_ptr<my_namespace::_Run const> RunConst;


If I have a Run somewhere and want to go to the definition, in 99% of all cases I want to see the definition of _Run and not the definition of the shared pointer. It also turned out to be practical to have the shared pointer definitions in a file that is separate from the definition of _Run, so Alt-G jumps to the wrong file.

Is it possible to extend the Alt-G feature in some way that it will offer to jump to the definition of the underlying code instead of the pointer? I would guess you don't want to hard-code a lot of boost specific stuff into VAX, but "always wrapping types in certain ways" is a pattern that is probably used in a lot of companies.

Regards, tv
6   L A T E S T    R E P L I E S    (Newest First)
Frunobulax Posted - Feb 23 2011 : 1:08:25 PM
quote:
Originally posted by accord
Anyway, personally I don't prefer using typedefs. I rather write down the pointer definition and avoid namespaces when it is possible, i.e. a generally used smartptr shouldn't be in a namespace and it's name shouldn't contain an underscore But it is my personal opinion. I know that company policies don't always allow to do things simple.




Perception of such things changes rapidly if you work in environments with 8-digit LOC numbers and several dozens developers

Actually it's quite sensible if you use shared pointers almost exclusively (and use explicit types only when referencing weak pointers and such). And namespaces are simply a matter of necessity.

But we digress

tv
accord Posted - Feb 23 2011 : 09:07:48 AM
>It's 3 actions instead of one
Yes, I just mentioned that this is the easiest way, currently, and I would do this so VA would switch between the files automatically.

Anyway, personally I don't prefer using typedefs. I rather write down the pointer definition and avoid namespaces when it is possible, i.e. a generally used smartptr shouldn't be in a namespace and it's name shouldn't contain an underscore But it is my personal opinion. I know that company policies don't always allow to do things simple. If I would want to avoid typing I would use VA snippets rather than typedefs. I also increases code readability. This is my approach but it may not viable in all circumstances, especially if it is against with a company policy Basic things should be always simple in my opinion, like "int" in C++ instead of basic_types::integer

The new feature which we are considering implementing would definitely help in your situation.
Frunobulax Posted - Feb 23 2011 : 12:36:50 AM
Well, yes. We are talking about the same thing. :)

It's minor, but it's an efficiency issue for two reasons:

  • It's 3 actions instead of one: Alt-G, choose template type, Alt-G again. For an action that is performed with a very high frequency that's annoying.

  • The second issue is a sideeffect of our project structure, which proved to be highly efficient otherwise: Have one header for each component that contains all classes as forward definitions, and all shared pointer typedefs. This allows other components to include only this definitions file and be able to reference all types from this component, without any problems of circular header inclusions.

    Now a problem when working with large solution is that the workspace is often cluttered with too many files. It's a constant struggle to have the files you are working on visible in the IDE. Now, assume that you are working on 3-4 components at a time (not unusual) and all are split in interface and implementation, then you'll have 6-8 header containing these shared pointer definitions. So each Alt-G will open one of these headers and add it to the list of open files.
accord Posted - Feb 22 2011 : 8:50:14 PM
Maybe we are talking about different things? I extended your code so I got this:

namespace my_namespace
{
	class _Run
	{

	};

}

typedef boost::shared_ptr<my_namespace::_Run> Run; // step 2: press alt+g over _Run
typedef boost::shared_ptr<my_namespace::_Run const> RunConst;

void testfunction()
{
	Run obj; // step 1: press alt+g over "Run"

}


In "testfunction" if I press Alt+G on Run, VA will take me to the typedef and selects "Run". Now, if I hold the left arrow until it arrives over "_Run", and I press alt+g again, it will go to the class definition of _Run. Is this makes sense?
Frunobulax Posted - Feb 22 2011 : 05:17:48 AM
quote:
Originally posted by accord


Currently, you have two alternatives:
1. You move the caret over "_Run" and press alt+g again (I do this in similar cases) so VA will travel you to the right file



The benefit of shared pointers is that you never, ever have to type "_Run", except once for the construction (which is often hidden in a service or factory and therefore not visible), so you'll have a hard time finding it to place the caret over it :-)

quote:

>It also turned out to be practical to have the shared pointer definitions in a file that is separate from the definition of _Run,
>so Alt-G jumps to the wrong file.

Just to clear up: I guess you mean "not the sensible file" by "wrong file"


Yep :-)

tv
accord Posted - Feb 21 2011 : 8:08:22 PM
We are considering to implement something like this:

case=9113

It is planned to be more general: will find types in variable definitions. Regarding templates, maybe it makes sense to look for types inside only the < and > because usually we are interested about the type inside the template.

It will be something like "go to type" and will be a separate command and/or presented in a listbox as an additional option after you press alt+g.

Currently, you have two alternatives:
1. You move the caret over "_Run" and press alt+g again (I do this in similar cases) so VA will travel you to the right file
2. You can use alt+shift+s which pops up the find symbol dialog, so you can type _Run to avoid two jumps.

>It also turned out to be practical to have the shared pointer definitions in a file that is separate from the definition of _Run,
>so Alt-G jumps to the wrong file.

Just to clear up: I guess you mean "not the sensible file" by "wrong file"

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