我刚刚在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?
更新: 重构包不起作用,因为我不想更改包的名称或位置,我只需要调整 Java 源中的包声明代码.
如果包声明不再有效,那么所有这些无效声明都会出现在 Eclipse 的 Problems
视图中.如果您没有看到此视图,您可以从 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).
您可以在问题"视图中过滤问题并纠正容易纠正的问题,方法是在上下文菜单中选择 Quick fix
选项(右键单击可用).在您的情况下,您应该会看到类似于下面发布的屏幕截图的内容:
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 - 如何“将包声明更改为 ...."在整个项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!