Eclipse - 如何“将包声明更改为....”跨越整个项目 [英] Eclipse - How to "Change package declaration to ...." across an entire project

查看:593
本文介绍了Eclipse - 如何“将包声明更改为....”跨越整个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将大量的源代码导入到Eclipse中,基本上该包名称已不再有效(代码已被移动到文件夹中)。有没有办法选择包资源管理器中的所有源代码,并点击热键,以便我的所有包声明都被正确解决?我知道您可以通过选择源代码并点击ctl-shift-o来进行导入,但是也可以在包声明中使用导入?

I've just imported a large amount of source code into Eclipse and basically the package name is no longer valid (the code has been moved folders). Is there a way to select all the source code in the Package Explorer and hit a hotkey so that all package declarations are correctly resolved for me? I know you can do this with imports by selecting the source and hitting ctl-shift-o, but is also possible for the package declaration?

更新: / strong>重新构建包不起作用,因为我不想更改包的名称或位置,我只需要在Java源代码中调整包声明。

推荐答案

如果包声明不再有效,那么所有这样的无效声明都会出现在 Problems 在Eclipse中查看。如果您没有看到此视图,您可以从Window-> Show View - > Other ... - > Problems(在General选项卡下)打开它。

If the package declarations are no longer valid, then all such invalid declarations would appear in the Problems view in Eclipse. If you do not see this view, you can open it from Window-> Show View -> Other... -> Problems (under the General tab).

您可以通过在上下文菜单(右键单击)中选择快速修复选项来过滤问题视图中的问题并更正容易修正的问题。在你的情况下,你应该看到类似于下面的截图:

You can filter on problems in the Problems view and correct easily correctable ones, by choosing the Quick fix option in the context menu (available on a right-click). In your case you should see something similar to the screenshot posted below:

应用快速修复选项是微不足道的,只要你知道哪一个是正确的 - 你将不得不更改类中的包声明,或类本身的位置。不幸的是,没有任何选择可以一次性跨多个单位解决问题;您将不得不为每个问题应用快速修复。

Applying the quick fix options is trivial, as long as you know which one is correct - you would either have to change the package declaration in the class, or the location of the class itself. Unfortunately there is no option to fix the issue across multiple units at one go; you will have to apply the quick fix for every problem.

如果您想过滤仅有这些品种的问题,请考虑配置问题视图以显示所有错误错误文本中的文本内容与预期的包不匹配,如以下屏幕截图所示:

If you want to filter on problems of only this variety, consider configuring the Problems view to show all errors that have the text content "does not match the expected package" in the error text, as demonstrated in the following screenshots:

这篇关于Eclipse - 如何“将包声明更改为....”跨越整个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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