Eclipse - 记录并应用移动和重命名重构到另一个工作区 [英] Eclipse - record and apply move and rename refactorings to another workspace

查看:179
本文介绍了Eclipse - 记录并应用移动和重命名重构到另一个工作区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在一个大型的java项目中工作,有很多不同团队工作的子模块。其中一些团队正在构建框架,其他的则是基于框架构建应用程序。



当框架移动或重命名类时,应用程序无论他们使用重构的框架类,他们都会收到编译错误。有没有办法在 Eclipse Galileo Release )中记录更改并更新其他工作区中的引用?



目前为止,我所尝试的是在重命名重构期间创建一个重构脚本,但是当我尝试将该脚本应用到另一个工作区时,它会以重构重命名类型(org.eclipse)。 jdt.ui.rename.type)不能执行,因为它的输入'xxx.TestClass'不存在。那么它不存在(不再)了,但是我想要的是所有引用对于我的项目中的 xxx.TestClass 要更改为 xxx.MyRenamedTestClass 。在Eclipse中有一种方法来做到这一点内置功能或现有的插件,或者我必须自己写一个?



感谢您的帮助!



编辑:到目前为止,我发现Migrate JAR-Plugin提供了我正在寻找的功能,尽管我们用Maven而不是Eclipse来构建JAR,我要去现在通过源代码找出可以重用的部分。

解决方案

回答我自己的问题,在这里得到一些关闭。 / p>

最简单的方法是使用 Migrate JAR File ... 重构,它使用重构脚本 META-INF 调用 REFACTORINGS.XML 。您可以在Eclipse中使用 Export JAR 自动获取包含此内容的JAR。我们使用Maven构建,因此只需执行重构 - >创建脚本... 并将其放入JAR中的适当位置。



迁移JAR执行的JDT内部代码为临时源文件夹中的源类创建存根,因此它首先执行重构,然后更新引用。用户永远不会看到这些临时文件。


I'm currently working in a big java project with quite a few submodules that are worked on by different teams. Some of these teams are building the "framework", others are building the "application" based on the framework.

When the framework guys move or rename a class, the applications guys get compile errors wherever they are using a refactored framework class. Is there a way in Eclipse (Galileo Release) to record the change and update the references in another workspace?

What I've tried so far is creating a refactoring script during the rename refactoring, but when I try to apply that script to another workspace, it fails with The refactoring 'Rename Type' (org.eclipse.jdt.ui.rename.type) cannot be performed, since its input 'xxx.TestClass" does not exists. Well, it does not exist (anymore) alright, but what I want is for all references for xxx.TestClass in my project to be changed to xxx.MyRenamedTestClass. Is there a way in Eclipse to do this with built-in functionality or an existing plugin or do I have to write one myself?

Thanks for your help!

EDIT: By now I found out that the "Migrate JAR"-Plugin provides the functionality I am looking for, although we build our JARs with Maven, not Eclipse. I'm going through the source code now to find out what parts I can reuse.

解决方案

Answering my own question to get some closure here.

The easiest way to do it is to use the Migrate JAR File... refactoring which uses a refactoring script in META-INF called REFACTORINGS.XML. You can get a JAR with this included automatically by using Export JAR in Eclipse. We build with Maven and thus just do Refactoring->Create Script... and put it into the appropriate position in the JAR.

The JDT-internal code that Migrate JAR executes creates Stubs for the source classes in a temporary source folder, so it actually executes the refactoring first and then updates the references. The user never gets to see these temporary files.

这篇关于Eclipse - 记录并应用移动和重命名重构到另一个工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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