Find all assignments to variable
Eclipse has an easy way to find all references to a variable, but is there a quick way to only look for assignments?
Solution 1:
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
).
Solution 2:
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.
Solution 3:
Ctrl+Alt+U
finds all the references within a class (local references) for a particular variable, on my ubuntu machine.