Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all assignments to variable

Tags:

eclipse

Eclipse has an easy way to find all references to a variable, but is there a quick way to only look for assignments?

like image 934
jhourback Avatar asked Feb 17 '12 18:02

jhourback


2 Answers

Quick? Hm... Find all references with Ctrl+Shift+G, then filter in the Search view (results) via the View menu (dropdown triangle). You can select Reads there to filter these.

Shortcut: Cursor to the variable, menu Search > Write Access > Workspace. No keybinding assigned by default, but you can do this as usual (Preferences > General > Keys).

like image 198
Hauke Ingmar Schmidt Avatar answered Oct 06 '22 18:10

Hauke Ingmar Schmidt


Ctrl+Shift+U shows all usages of a variable, with different icons for read and write references.

You can also set different colors for read and write occurrences of the selected variable (in the right part of the editor). These colors are set in Eclipse preferences, in "General -> Editors -> Text editors -> Annotations". There is "Occurences" and "Write occurences". I set the same color, slightly darker for "Write occurence", so I can easily spot write occurences, without any key stroke.

like image 23
Baldrick Avatar answered Oct 06 '22 19:10

Baldrick