简体   繁体   English

Eclipse在具有依赖项的项目上重命名功能

[英]Eclipse renaming function on projects with dependencies

I have two eclipse project. 我有两个eclipse项目。 The second one depends on the first one. 第二个取决于第一个。 When I try to rename a java class of the first project (using the rename function on the java file on the project explorer) it correctly do the refactor of that project but it doesn't changes anything on the project that depends on it. 当我尝试重命名第一个项目的java类(使用项目浏览器上的java文件上的重命名函数)时,它正确地执行该项目的重构,但它不会改变依赖于它的项目上的任何内容。

Is there a way in eclipse to tell the renaming function to act even on the projects that are linked to the refactored one? 在eclipse中是否有一种方法可以告诉重命名函数甚至可以对链接到重构函数的项目执行操作? Thanks for help. 感谢帮助。

My Eclipse version is Juno. 我的Eclipse版本是Juno。

Update: 更新:
Forgot to mention that the projects are linked to an SVN repository. 忘了提到项目链接到SVN存储库。 Maybe it could be relevant. 也许它可能是相关的。

Update 2: 更新2:
I add more details after mliebelt request of clarification. 我在mliebelt请求澄清后添加更多细节。
My Eclipse version is Juno, Eclipse Java EE IDE for Web Developers, build id: 20120614-1722. 我的Eclipse版本是Juno,Eclipse Java EE IDE for Web Developers,build id:20120614-1722。

I've installed some plugins: subclipse, JRebel, m2e, Eclipse Web Tool Platform. 我已经安装了一些插件:subclipse,JRebel,m2e,Eclipse Web Tool Platform。
The second project is linked to the first one as a project dependency in eclipse. 第二个项目与第一个项目相关联,作为eclipse中的项目依赖项。 I have added the first project in the project tab of Java Build Path. 我在Java Build Path的项目选项卡中添加了第一个项目。 Everything seems to work fine, even the renaming function. 一切似乎都很好,甚至是重命名功能。

Then, I tried to put the two project in two different SVN repositories. 然后,我尝试将这两个项目放在两个不同的SVN存储库中。 I created two repositories on the SVN server and I installed on my machine the client tortoiseSVN and the eclipse plugin subclipse. 我在SVN服务器上创建了两个存储库,我在我的机器上安装了客户端tortoiseSVN和eclipse插件subclipse。 Since I didn't succeeded in importing the projects on the server directly from eclipse, I copied the projects' folders in a different location and I removed the projects from eclipse. 由于我没有成功直接从eclipse导入服务器上的项目,我将项目的文件夹复制到不同的位置,我从eclipse中删除了项目。 I used tortoiseSVN to import the projects, each one on a repository with the same name of the project, and than I imported the project back to eclipse. 我使用tortoiseSVN来导入项目,每个项目都在一个具有相同项目名称的存储库中,而不是我将项目导回到eclipse。 To do that I used the eclipse "import existent project into workspace" function with the "copy project into workspace" option selected. 为此,我使用了eclipse“将现有项目导入工作区”功能,并选择了“将项目复制到工作区”选项。 Everything seems to work but not the renaming function. 一切似乎都有效,但不是重命名功能。

It does work (for me), so here is what I have done to reproduce the behavior. 它确实有用(对我来说),所以这就是我为重现行为所做的工作。 I hope that this helps to find the error. 我希望这有助于找到错误。

  1. Create two projects, and make the second dependent on the first. 创建两个项目,并使第二个项目依赖于第一个。 <code> Test2 </ code>的Java构建路径
  2. Create some source code, so that you can refactor it. 创建一些源代码,以便您可以重构它。 Ensure that a class in Test2 is dependent on a class in Test . 确保Test2中的类依赖于Test的类。
  3. Select from the context menu of the method you want to rename. 从要重命名的方法的上下文菜单中选择。 Enter there a new name for the method, only then is the Preview option available. 为该方法输入一个新名称,然后才能使用“ Preview选项。 Ensure that Update references is checked. 确保选中“ Update references 重命名方法说明对话框
  4. Press the button Preview to see which classes will be changed by the refactoring. 按下按钮Preview以查看重构将更改哪些类。 在此输入图像描述

As you can see, it works for me. 如你所见,它对我有用。 Please check what is different in your context: 请检查您的上下文中的不同之处:

  • Define dependency different 定义依赖性不同
  • Use different refactoring (which possibly contains a bug) 使用不同的重构(可能包含错误)
  • ... ? ......?

I then added the two projects to a (local) repository (I use the plugin Subversive, it that matters), and have retried the refactoring, and it works the same way. 然后我将这两个项目添加到(本地)存储库(我使用插件Subversive,这很重要),并重新尝试重构,它的工作方式相同。 What is that "it does not work if the projects are in SVN"? 什么是“如果项目是在SVN中它不起作用”? The projects have to be in Eclipse, refactoring cannot be done on the Subversion repository directly. 项目必须在Eclipse中,不能直接在Subversion存储库上进行重构。


I have made another attempt to reproduce the error, but could not. 我再次尝试重现错误,但不能。 Here is what has worked for me (no screenshots included): 这是对我有用的(没有包含屏幕截图):

  1. Installed Java EE from Eclipse (version Indigo) 从Eclipse安装的Java EE(版本Indigo)
  2. Installed Subclipse 1.8 from the Eclipse Marketplace. 从Eclipse Marketplace安装Subclipse 1.8。
  3. Defined the 2 projects as before. 像以前一样定义了2个项目。
  4. Added the projects to the different Subversion repositories by using Team > Share Project...> SVN > select the repository location > Finish 使用Team > Share Project...> SVN > select the repository location > Finish将项目添加到不同的Subversion存储库Team > Share Project...> SVN > select the repository location > Finish
  5. I have then deleted the 2 projects, and instantiated them inside the workspace by doing the following steps: 然后我删除了2个项目,并通过执行以下步骤在工作区内实例化它们:
    • Go to the SVN Repository Exploring perspective . 转到SVN Repository Exploring perspective
    • Open in the view SVN Repositories your repository locations, and select for each project from the menu Checkout... . SVN Repositories视图中打开您的存储库位置,并从菜单Checkout...选择每个项目。
    • The projects will be reinstantiated insided the workspace, and the dependency between the 2 is not lost. 项目将在工作区内重新实例化,并且2之间的依赖关系不会丢失。
  6. After that, I am able to rename a method as I have shown above. 之后,我可以重命名一个方法,如上所示。

The problem in my workflow, described in Update2, was that, when I imported back the projects to eclipse, I used "import existent project into workspace" function. 我在Update2中描述的工作流中的问题是,当我将项目导回到eclipse时,我使用了“将现有项目导入工作区”功能。

I had to use SVN Checkout Projects from SVN instead, choosing the repositories I previously created. 我不得不使用SVN的SVN Checkout Projects ,选择我之前创建的存储库。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Maven在Eclipse中建立依赖关系,多个项目 - maven build dependencies in Eclipse, multiple projects 将引用的Eclipse项目添加到Maven依赖项 - Adding referenced Eclipse projects to Maven dependencies Eclipse 运行配置:如何添加已添加到 Classpath 的项目的 Maven 依赖项 - Eclipse Run Configurations: how to add Maven dependencies of projects added to Classpath Eclipse中的Java EE模块依赖项页面缺少项目 - Java EE Module Dependencies page in Eclipse missing projects Eclipse中多模块Maven项目中的Java项目依赖关系树 - Java projects dependencies tree in multimodule maven project in Eclipse 如何在Eclipse ADT中打开项目并自动导入库项目依赖项 - How to open a project in eclipse ADT and automatically import LIbrary Projects dependencies Eclipse RCP-在工作区中的项目中放置javadocs和相关依赖源 - Eclipse RCP - Shere javadocs and attached sources of dependencies among projects in workspace 如何在Eclipse中的Maven项目之间设置“构建”依赖关系? - How to set “build” dependencies between Maven projects in Eclipse? 使用 Tomcat 部署 Eclipse Web 应用程序:提供多个项目的依赖项? - Eclipse Web-App Deployment with Tomcat: Providing multiple projects' dependencies? Eclipse中消失了“关闭无关项目”功能 - “Close unrelated projects” function gone in Eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM