Ian Branch 127 Posted November 10, 2022 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
dummzeuch 1505 Posted November 10, 2022 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
Ian Branch 127 Posted November 10, 2022 Hi Thomas, That will do nicely.. Tks for the pointer. Regards, Ian Share this post Link to post
Pat Foley 51 Posted November 10, 2022 Shift-Ctrl-F select current unit puts clickable lines in Messages view. Would that be a solution, Pat Share this post Link to post
Ian Branch 127 Posted November 10, 2022 Hi Pat, Only works for/on Components. Ian Share this post Link to post
Stano 143 Posted November 10, 2022 Static code analyzers can do that. PAL for sure. Share this post Link to post
Brian Evans 105 Posted November 10, 2022 (edited) 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. Edited November 10, 2022 by Brian Evans 1 Share this post Link to post
haley 2 Posted November 10, 2022 Sounds exactly like the CodeLens feature in Visual Studio. I know, I wish Delphi had it too 😂 Share this post Link to post
Anders Melander 1783 Posted November 11, 2022 (edited) 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... or right-click and select Find, Find local references to... Edited November 11, 2022 by Anders Melander 1 Share this post Link to post
Ian Branch 127 Posted November 11, 2022 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
Vandrovnik 214 Posted November 11, 2022 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
Anders Melander 1783 Posted November 11, 2022 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
Vandrovnik 214 Posted November 11, 2022 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
Pat Foley 51 Posted November 11, 2022 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. Share this post Link to post