Page 1 of 1

Smart goto

Posted: Sat Jan 31, 2015 12:47 am
by foxmuldr
In Visual Assist X (VAX, an augment plugin made by Whole Tomato for Visual Studio), there is a feature connected by default to the Alt+G key combo, which goes to the symbol under the caret. If you're in the middle of arbitrary code and there's more than one potential destination, it prompts a little menu showing all references of that symbol in definition and its implementation. If there's only one target, it just goes there. But, if you're already on the definition it will automatically jump to the implementation, and if you're already on the implementation will jump to its definition without prompting you.

I'd like to add this functionality for a type of smart goto ability.

What's the class structure in Codelite for accessing / knowing tokens that have been parsed project/workspace-wide, as well as those for the current line?

-----
Another similar feature would be "find all references" which in VAX Shift+Alt+F which finds all references for the token (given its full context) under the caret, which then shows up in an immediate find window. And a refactoring ability Shift+Alt+R which finds all references, and replaces the token name with its new name.

Re: Smart goto

Posted: Sat Jan 31, 2015 10:33 am
by eranif
foxmuldr wrote:Another similar feature would be "find all references" which in VAX Shift+Alt+F which finds all references for the token (given its full context) under the caret, which then shows up in an immediate find window. And a refactoring ability Shift+Alt+R which finds all references, and replaces the token name with its new name.
Right click a symbols -> search -> find references
foxmuldr wrote:In Visual Assist X (VAX, an augment plugin made by Whole Tomato for Visual Studio), there is a feature connected by default to the Alt+G key combo, which goes to the symbol under the caret. If you're in the middle of arbitrary code and there's more than one potential destination, it prompts a little menu showing all references of that symbol in definition and its implementation. If there's only one target, it just goes there. But, if you're already on the definition it will automatically jump to the implementation, and if you're already on the implementation will jump to its definition without prompting you.

I'd like to add this functionality for a type of smart goto ability
You can have multiple ways of achieving this:

(codelite 7.0) select text Ctrl-Shift-R

OR

right click on a symbol->Goto definition/declaration

OR

select a symbol (from the menu bar) search -> find symbol

Eran

Re: Smart goto

Posted: Mon Feb 02, 2015 3:40 am
by foxmuldr
VAX: Alt-G. Displays a context menu (right below the location of the symbol) if more than one potential target. If only one target it goes right to it.
eranif wrote:
foxmuldr wrote:I'd like to add this functionality for a type of smart goto ability
You can have multiple ways of achieving this:
(codelite 7.0) select text Ctrl-Shift-R
Codelite: Ctrl-Left, Shift-Ctrl-Right, Ctrl-Shift-R. Displays an "Open Resource" dialog (which is empty on my project -- Codelite 6.1).
OR
right click on a symbol->Goto definition/declaration
Codelite: Leave keyboard, move mouse pointer to symbol, right-click, move to goto definition or goto declaration after determining which one it is I need manually.
OR
select a symbol (from the menu bar) search -> find symbol
Codelite: Ctrl-Left, Shift-Ctrl-Right, leave keyboard, move mouse pointer to menu, click search, move to find symbol, click.

The functionality already exists to some extent, though not exactly (because a manual goto exists, but not a smart goto). But even in that context, it's a convenience feature I'm wanting to add -- a single operation which will do the work of determining the destinations of the Goto Definition and Goto Implementation, and determining if we're already sitting on one of them, and if so then go to the other, and if not and both are valid (or if you have an overloaded function and multiple targets are possible) display a context menu for selection.

You can download and try a free version of Visual Assist X to use with Visual Studio. Look at the Alt-G functionality on a function that has a prototype and implementation, as well as a function that is overloaded. That's what I'm after.

http://www.wholetomato.com/downloads/

Re: Smart goto

Posted: Mon Feb 02, 2015 3:44 am
by foxmuldr
eranif wrote:
foxmuldr wrote:Another similar feature would be "find all references" which in VAX Shift+Alt+F which finds all references for the token (given its full context) under the caret, which then shows up in an immediate find window. And a refactoring ability Shift+Alt+R which finds all references, and replaces the token name with its new name.
Right click a symbols -> search -> find references
Eran
I use that feature. I'll see about assigning it to a keystroke.

Where is there a rename symbol feature? The ones I've tried are different for local symbols, and other kinds. It seems to go through several confusing dialogs and then either comes up asking for the new name, or doesn't come up at all.

If you download Visual Assist X, you can see the Shift-Alt-R for rename functionality. It provides a list and lets a person choose which entries on which lines they want to rename from that list. And their Shift-Alt-F find symbol functionality brings up a list that has everything with syntax highlighting.

http://www.wholetomato.com/downloads/

These are some of the features I'd like to add.

Re: Smart goto

Posted: Mon Feb 02, 2015 10:17 am
by eranif
foxmuldr wrote:If you download Visual Assist X, you can see the Shift-Alt-R for rename functionality. It provides a list and lets a person choose which entries on which lines they want to rename from that list. And their Shift-Alt-F find symbol functionality brings up a list that has everything with syntax highlighting.

http://www.wholetomato.com/downloads/
Thanks but I don't have VS installed (and don't plan on installing one)

Eran

Re: Smart goto

Posted: Tue Feb 03, 2015 2:04 am
by Gibbon1
Maybe foxmuldr could take a few screen shots of VS rename solution and post them.

PS: I use VS for writing really crappy configuration tools. It's pretty good. I use codelite mostly for the embedded stuff because all the other options are weak (text editors) or cancer (eclipse)

Re: Smart goto

Posted: Wed Feb 04, 2015 3:06 am
by foxmuldr
Gibbon1 wrote:Maybe foxmuldr could take a few screen shots of VS rename solution and post them.
This one http://www.libsf.org/images/codelite/sh ... rename.png shows the Shift-Alt-R rename dialog. In this case I was on the "color" member of the SBgra structure and pressed Shift-Alt-R. This is a oft-used member. VAX searchd through the entire project and found all of the references, along with some it wasn't sure about, such as within the contents of the macro. You'll note those are not checked by default, but are avaialble for auto-replace. There are also options to replace those names in comments and strings.

This one http://www.libsf.org/images/codelite/al ... t_goto.png shows the Alt-G smart goto. I was on the instance of the name iComps_combineAllBetween2() directly above the popup dialog, and pressed Alt-G. VAX searched and saw two destinations and displayed them in the context window. Note that all members are shown allowing me to see the target by parameters, and not just name.

Re: Smart goto

Posted: Wed Feb 04, 2015 3:21 am
by foxmuldr
One other screen of note in Visual Studio in general is this one: http://www.libsf.org/images/codelite/co ... window.png

In this screen, it constantly tracks with the caret to find the symbol under it and then display the source code around that symbol's definition. In this case, it ties back to the structure definition of the nextComp member I was one for that structure. It typically tracks behind about a second as the processing is handled in a background thread so as to not slow down normal navigation. But, it is a huge time saver because you can see the code around the function you've just typed in, reminding yourself of the parameters, seeing nearby comments, etc.

Note: I added the black line to show the correlation of where I was in the source code, to what it displayed.