Eclipse 重命名不完全工作
好吧,我完全用谷歌搜索出来了。
我的 eclipse 工作区中有一些 java 项目(大约 25 个)。 大多数项目使用链接的源文件夹。
当我重命名 Project1 中的类时,其他项目中对该类的引用不会更新。项目内的参考文献已更新得很好。 最终结果是下次自动重新编译时出现编译错误。
我正在使用 Eclipse 3.5.1,但 3.4.0 和 3.4.2 显示了相同的行为
有关如何解决此问题的任何想法吗?
我当前的计划 - 在谷歌搜索 20 分钟之后 - 是编写一个脚本将链接的源文件夹转换为项目文件夹本身中的操作系统链接(我在 Linux 上)。 所以我不再使用链接的源文件夹。
Ok I'm completely googled-out.
I have a few java projects in my eclipse workspace (about 25). Most projects use linked source folders.
When I rename a class in Project1, the references to that class in the other projects are not updated. The references within the project are updated just fine. The net result is compilation errors on the next automatic recompile.
I'm using Eclipse 3.5.1, but the same behavior was shown by 3.4.0 and 3.4.2
Any ideas about how to fix this?
My current plan - after googling for 20 minutes - is to write a script to convert the linked source folders to be OS links (I'm on linux) in the project folders themselves. So then I'm no longer using linked source folders.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 Philippe Faes 所说,如果您的项目被设置为彼此依赖,那么效果会很好。确保您的项目的构建路径是这样设置的。
恕我直言,链接文件夹用于外部文件,而不是其他项目。
另一个问题是,如果您只是引用一个 jar 作为依赖项(即,在项目的类路径上),eclipse 将无法知道该 jar 是基于另一个项目的源代码构建的,因此将无法正确重构。
尝试向您的同事询问 Eclipse 项目文件(.project 和 .classpath),并根据需要编辑这些文件,然后检查您的重构是否仍然无法正常工作。我猜你的项目设置与你的同事不同。
Like Philippe Faes said, it works fine if your projects are set as a dependency on each other. Make sure that your project's build path are set up that way.
IMHO linked folders are for external files, not for another projects.
Another problem is that if you are just referencing a jar as a dependency (ie, on the project's class path), eclipse will not be able to know that the jar was build based on another project's source thus will not refactor properly.
Try to ask your colleagues for the eclipse project files (.project and .classpath) and edit the files if you need, then check if your refactor still doesn't work. I am guessing that your project is set up differently than your colleagues.
如果您的项目相互依赖,那么跨项目重命名就可以正常工作。
链接的源文件夹到底是什么意思:您是否多次链接到同一源文件夹?
Cross-project renames work just fine if your projects depend on each other.
What exactly do you mean with linked source folders: do you link to the same source folder more than once?
这是一个盲目的尝试,但请确保您的项目是一个 Java 项目。我不确定其他项目类型(如通用项目)是否可能无法正确重构。我以前从未见过这个问题,它总是按我的预期工作......
This is a shot in the dark, but make sure that your project is a Java project. I am not sure if other project types (like the generic Project) might not refactor properly. I have never seen this problem before and it has always worked as expected for me...