eclipse 查找变量的所有赋值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9333634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:55:14  来源:igfitidea点击:

Find all assignments to variable

eclipse

提问by jhourback

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

Eclipse 有一种简单的方法来查找对变量的所有引用,但是有没有一种仅查找赋值的快速方法?

回答by Hauke Ingmar Schmidt

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

快的?嗯...用Ctrl+ Shift+查找所有引用G,然后Search通过视图菜单(下拉三角形)在视图(结果)中过滤。您可以选择Reads在那里过滤这些。

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).

快捷方式:光标指向变量 menu Search > Write Access > Workspace。默认情况下未分配键绑定,但您可以照常执行此操作 ( Preferences > General > Keys)。

回答by Baldrick

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

Ctrl+ Shift+U显示了一个变量的所有用法,使用不同的图标来读取和写入引用。

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.

您还可以为所选变量的读取和写入出现设置不同的颜色(在编辑器的右侧)。这些颜色在 Eclipse 首选项中设置,在“常规 -> 编辑器 -> 文本编辑器 -> 注释”中。有“出现”和“写入出现”。我为“写入出现”设置了相同的颜色,稍微深一点,所以我可以轻松地发现写入出现,而无需任何击键。

回答by samsamara

Ctrl+Alt+Ufinds all the references within a class (local references) for a particular variable, on my ubuntu machine.

Ctrl+Alt+U在我的 ubuntu 机器上查找特定变量的类中的所有引用(本地引用)。