蚀能发现具有特定注释的方法签名的出现吗? [英] Can eclipse find occurences of a method signature having a particular annotation?

查看:48
本文介绍了蚀能发现具有特定注释的方法签名的出现吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我的许多类都有一个 getEntity()访问器,可以通过指定搜索字符串 getEntity()和Search For来通过Java Search找到该访问器.方法.但我需要将此范围缩小到仅具有注释 @OneToOne 的方法.

For example, many of my classes have a getEntity() accessor, which can be found via Java Search by specfiying the Search string getEntity(), and Search For Method. But I need to narrow this to only the methods that have the annotation @OneToOne.

我在搜索字符串中尝试了一些疯狂的猜测,但没有成功.例如: getFoobar()@OneToOne @OneToOne getFoobar().反正有这样做吗?

I tried a few wild guesses in the Search string to no avail. For example: getFoobar() @OneToOne and @OneToOne getFoobar(). Is there a anyway to do this?

(对正则表达式搜索进行排序似乎容易出错,因为注释语法使用所有与方法定界的相同字符.)

(Resorting to a regular expression search seems error prone because annotation syntax uses all the same characters that delimit methods.)

推荐答案

与实际解决方案相比,这更像是(部分)解决方法,但是您可以使用References-search来显示项目(或工作区)中的所有位置)使用注释的位置.请注意,这将列出所选项目的所有实例(类,方法,成员变量或注释),而不仅是方法中的实例:

This is more like a (partial) workaround than actual solution, but you could use the References-search to show you all the places in your project (or workspace) where the annotation is used. Note that this will list all occurrences of the selected item (class, method, member variable or annotation), not only those occurring in methods:

通过双击某个事件来选择注释(或使用Shift +箭头键或使用鼠标绘制"注释),然后在上下文菜单中选择引用"->项目"(右键单击).Shift + Ctrl + G是搜索整个工作空间(所有打开的项目)的默认快捷方式,您还可以在Window-> Preferences-> General-> Keys中设置自己的快捷方式,以进行项目范围内的搜索(如果您愿意保留,只需在键盘上进行操作,并且只需要在整个项目范围内进行搜索即可.

Select the annotation by double-clicking on an occurrence (or "paint" it with shift+arrow keys or with mouse) and select References->Project in the context menu (right-click). Shift+Ctrl+G is the default short cut to search entire workspace (all open projects), you can also set your own short cut for project-wide search in Window->Preferences->General->Keys (if you prefer to keep your hands on the keyboard and need only project-wide search).

这篇关于蚀能发现具有特定注释的方法签名的出现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆