Java Eclipse 可以用于查找所有已弃用的方法调用吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/233593/
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
Can Eclipse Be Used To Find All Deprecated Method Calls?
提问by John Topley
Does Eclipse have a feature that lets you search a project to find all calls to deprecated methods?
Eclipse 是否具有让您搜索项目以查找对已弃用方法的所有调用的功能?
采纳答案by matt b
You can set the compiler to generate errors or warnings (your choice) for any usage of deprecated API.
您可以将编译器设置为针对已弃用 API 的任何使用生成错误或警告(您的选择)。
Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted APIsection.
首选项 -> Java -> 编译器 -> 错误/警告 ->弃用和受限 API部分。
Then, each use of a deprecated method or API will show up as an error/warning in the Problems view.
然后,每次使用已弃用的方法或 API 都会在问题视图中显示为错误/警告。
回答by Alan
You can always use the grep facilities under 'Search -> File'. Eclipse can do a recursive search for @deprecated
after you check on the 'consider derived resources' option box.
您始终可以使用“搜索 -> 文件”下的 grep 工具。@deprecated
选中“考虑派生资源”选项框后,Eclipse 可以进行递归搜索。
回答by Andy Thomas
[Updating eight years later, for current versions of Eclipse, with screenshots.]
[八年后更新,针对当前版本的 Eclipse,并附有屏幕截图。]
First, build your projects.Once you've built your projects, the Problems view includes deprecations by default. You can group all the deprecations together.
首先,构建您的项目。构建项目后,问题视图默认包含弃用。您可以将所有弃用组合在一起。
To show the Problems view,use Window>Show View>Problems.
要显示问题视图,请使用Window>Show View>Problems。
If deprecations don't appear after the next step, you can configure them in Preferences under Java>Compiler>Errors/Warnings.
如果在下一步之后没有出现弃用,您可以在Java>Compiler>Errors/Warnings下的 Preferences 中配置它们。
Group deprecations togetherusing the Problem view menu. Start by clicking the control circled below.
使用问题视图菜单将弃用组合在一起。首先单击下面圈出的控件。
Once you've done that, open the "Deprecation" subtree. For example:
完成后,打开“弃用”子树。例如: