org.eclipse.compare for Java Packages [message #521176] |
Tue, 16 March 2010 16:18 |
mRoby88 Messages: 4 Registered: March 2010 |
Junior Member |
|
|
Dear all,
I'm writing an Eclipse Plug-in and I need to make use of org.eclipse.compare 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,
RM
|
|
|
Powered by
FUDForum. Page generated in 0.01451 seconds