Jump to content
Ian Branch

Is there such a tool/functionality??

Recommended Posts

Hi Team,

I would like an IDE tool that works something like this..

1.  Select a variable anywhere in a Unit.

2.  Right Click or Hot-Key (becoming scarce) and get the option to show all occurrences of that variable in the Unit.

3.  The showing would be in a popup window showing each of the lines the variable is in.

4.  Double clicking on one of the lines will take me to that line in the Code and close the popup.

Why do I want this?

Many times I have caught myself out by redeclaring a variable in a function/procedure that had already been declared at the Unit level which has caused issue.  And vise-versa.

Just asking.  This is a personal thing, I don't expect others to have the same issue/problem.

Perhaps the tool/functionality already exists in one of the many 3rd party IDE add-ins??

 

Regards,

Ian

Share this post


Link to post
47 minutes ago, Ian Branch said:

1.  Select a variable anywhere in a Unit.

2.  Right Click or Hot-Key (becoming scarce) and get the option to show all occurrences of that variable in the Unit.

3.  The showing would be in a popup window showing each of the lines the variable is in.

4.  Double clicking on one of the lines will take me to that line in the Code and close the popup.

Sounds like a use case for GExperts Grep for the current file. Not quite as convenient as the functionality you describe, but certainly workable.

Share this post


Link to post

Shift-Ctrl-F select current unit puts clickable lines in Messages view. Would that be a solution, Pat

Share this post


Link to post

Static code analyzers can do that. PAL for sure.

Share this post


Link to post

MMX Code Explorer has next/previous occurrence off right mouse button menu with hotkeys that also brings up a list. Right mouse -> MMX Commands -> Navigate and Move -> Find Next Occurrence.

 

SHIFT-ALT-RIGHT ARROW (find next occurrence) or SHIFT-ALT-LEFT ARROW (previous occurrence) hotkeys. 

 

 

  

Occurences.png

Edited by Brian Evans
  • Like 1

Share this post


Link to post

Sounds exactly like the CodeLens feature in Visual Studio. I know, I wish Delphi had it too 😂

Share this post


Link to post

It's built right into the IDE. The only problem is that it seldom works 😞

[Edit: This is what @Pat Foley wrote about]

 

Right-Click and select Search for usages...

image.thumb.png.31fb706bf1d50f64c4418dcc38f106bd.png

image.thumb.png.07c72b8a52862c52d900fe09e40754f9.png

 

or right-click and select Find, Find local references to...

image.thumb.png.e295d9e123be7108cf766e6d6e281842.png

image.png.613ba3e3eda86f9c82ebf5217550f907.png

Edited by Anders Melander
  • Like 1

Share this post


Link to post

Hi Anders,

Just tried it in D11.2.  What a waste of effort.  For the variables I tried Gexperts Grep found all of the occurrences, Search & Find only found the declaration. :-(

Grep is exactly what I wanted.

 

Ian

Share this post


Link to post
17 minutes ago, Anders Melander said:

It's built right into the IDE. The only problem is that it seldom works 😞

 

... and it tooks quite a lot of time to initialize. "Search for usages" also does just partial job when you doubleclick found item - it display the file, it selects found item, but cursor is off-screen, sou you have to press for exampe an arrow to see that place.

Share this post


Link to post
10 minutes ago, Ian Branch said:

Grep is exactly what I wanted.

Doesn't Search, Find in files do the same thing?

 

7 minutes ago, Vandrovnik said:

... and it tooks quite a lot of time to initialize. "Search for usages" also does just partial job when you doubleclick found item - it display the file, it selects found item, but cursor is off-screen, sou you have to press for exampe an arrow to see that place.

My guess is that it's using the same engine as the broken-beyond-repair refactoring tools (which afaik is implemented in J#, LOL)... It's incredible that they didn't remove this turd of a feature many, many, many years ago.

https://docwiki.embarcadero.com/RADStudio/Sydney/en/Refactoring_Code

Quote

RAD Studio provides a set of refactoring operations that can help you re-architect your code in the most effective and efficient manner possible.

ROTFL

Share this post


Link to post
40 minutes ago, Anders Melander said:

Doesn't Search, Find in files do the same thing?

 

My guess is that it's using the same engine as the broken-beyond-repair refactoring tools (which afaik is implemented in J#, LOL)... It's incredible that they didn't remove this turd of a feature many, many, many years ago.

https://docwiki.embarcadero.com/RADStudio/Sydney/en/Refactoring_Code

ROTFL

I always cross my fingers before using refactoring (renaming)... And it sometimes works 🙂 Sometimes it even does rename the identifier at all places and does not forget some of them...

Share this post


Link to post
12 hours ago, Vandrovnik said:

I always cross my fingers before using refactoring (renaming)... And it sometimes works 🙂 Sometimes it even does rename the identifier at all places and does not forget some of them...

I was able to refactor in 32 for first time in the twenties and then refactor the refactor in 64 🙂.  While watching the runtime I selected the Class l.ookup and 232 warnings came up! I am running 11.1 on win 11 home.  

 

64bit release.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×