简体   繁体   English

在Eclipse插件中获取两个IFile之间的差异

[英]Getting the differences between two IFiles in an eclipse plugin

I am writing an eclipse plugin that notices when a file has moved or been renamed. 我正在编写一个eclipse插件,用于通知文件何时移动或重命名。 In eclipse, this can happen when you choose to move or rename a file. 在eclipse中,当您选择移动或重命名文件时可能会发生这种情况。 The interesting thing is that in a rename, for example, eclipse will delete the old file and create a brand new file. 有趣的是,例如,在重命名中,eclipse将删除旧文件并创建一个全新文件。

I do have access to the old file and the new one: 我确实可以访问旧文件和新文件:

//grab each new and deleted file
IFile oldFile = resourceParser.getDeletedFiles().get(i);
IFile newFile = resourceParser.getNewFiles().get(i);

The problem is that in some situations (renaming a package, for example) a file will be moved and the contents of the file will be changed to account for the new package name. 问题在于,在某些情况下(例如,重命名软件包),将移动文件,并且文件内容将更改为新的软件包名称。

So, I need to get a list of differences between the two files. 因此,我需要获取两个文件之间的差异列表。 Like I said, I have access to the two IFiles (the deleted one and the new one) but I want to see how their contents differ. 就像我说的那样,我可以访问两个IFile(删除的一个和新的一个),但是我想看看它们的内容有何不同。 Is there some kind of java diff tool that will produce a simple list of changes that I can manipulate? 是否有某种Java差异工具可以生成我可以操纵的简单更改列表?

The Eclipse org.eclipse.compare provides a general mechanism for writing diff tools and editors, this is described in the Eclipse Help . Eclipse org.eclipse.compare提供了一种用于编写差异工具和编辑器的通用机制,这在Eclipse Help中进行了描述。

The Java Development Tools part of Eclipse extends this compare support for Java, however the code is in the org.eclipse.jdt.ui.internal.ui.compare package which is internal and consequently not part of the Eclipse API and should not be used Eclipse API Rules of Engagement Eclipse的Java Development Tools部分扩展了对Java的比较支持,但是代码在org.eclipse.jdt.ui.internal.ui.compare包中,该包是内部的 ,因此不属于Eclipse API,因此不应使用Eclipse API参与规则

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM