Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » for Java Packages(Need help to use to compare Java Packages) for Java Packages [message #521176] Tue, 16 March 2010 16:18
mRoby88 is currently offline mRoby88Friend
Messages: 4
Registered: March 2010
Junior Member
Dear all,
I'm writing an Eclipse Plug-in and I need to make use of in an "abstract way" as the built-in function "Compare with Each Other" does.

In a way I need to be able to:
- Select two Java source file and compare these two (done as follow)

	public static void findDiff(IFile left, IFile right) {

		IStructureCreator structureCreator = StructureDiffUtil.getStructureCreator(right.getFileExtension());
		Differencer differencer = new Differencer();

		Object structureDiffs = differencer.findDifferences(
				false, new NullProgressMonitor(), null, null, 
				structureCreator.getStructure(new ResourceNode(left)),
				structureCreator.getStructure(new ResourceNode(right)));

Where StructureDiffUtil is implemented as follows:

public class StructureDiffUtil {

	 * Structure creator for files with file type type
	 * @param type the file type
	 * @return
	public static IStructureCreator getStructureCreator(String type) {
		if (type == null) {
			return null;
		if (type.startsWith(".")) {
			type = type.substring(1);
		StructureCreatorDescriptor scd = CompareUIPlugin.getDefault(). getStructureCreator(type);
		if (scd == null) {
			return null;
		return scd.createStructureCreator();

	public static boolean isAddition(DiffNode diffNode) {
		return diffNode.getKind() == Differencer.ADDITION;

	public static boolean isDeletion(DiffNode diffNode) {
		return diffNode.getKind() == Differencer.DELETION;

	public static boolean isChange(DiffNode diffNode) {
		return diffNode.getKind() == Differencer.CHANGE;

- Select two Java *packages* and be able to get all the differences (!).

I have no clue, after long trials, on how to adapt the code above in order to be able to pass-in packages (that, if I'm not wrong, are treated like Folders) and get out a DiffNode with all the differences between all the source files in those packages.

Is this feasible?

The intent of this Plug-in will be comparing your local package content, at commit time, with a versioned one (i.g. SVN) in order to process these changes.

Thanks in advance,
Next Topic:Java Packages Comparison
Goto Forum:

Current Time: Sun Sep 19 09:29:39 GMT 2021

Powered by FUDForum. Page generated in 0.02240 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top