以编程方式比较Eclipse PDE中的两个Java源文件

问题描述 投票:0回答:1

我正在研究Eclipse插件,我想比较两个java源代码。我能够在文本级别比较两个java代码。我已经引用https://wiki.eclipse.org/FAQ_How_do_I_create_a_compare_editor%3F来比较两个代码。我的代码看起来像:

    CompareItem ancestor = new CompareItem(file1);
    left = new CompareItem(file1);

    right = new CompareItem(file2);

    node = new DiffNode(null, Differencer.CONFLICTING, ancestor, left, right);

    return node;

我的比较对话框看起来像(图1):

如何比较源代码级别的两个文件,以便得到类似(图2):(所有java格式)。

eclipse eclipse-plugin
1个回答
0
投票

我得到了答案。我写了一个实现ITypedElement的类。覆盖ITypedElement接口的getType()方法并返回“JAVA”是我的工作。

我的课程如下:

public class CompareItem implements IStreamContentAccessor, ITypedElement, IModificationDate, IEditableContent{

    private File content;

    public static String newContents;

    public CompareItem(File left ) {
        content = left;
    }

    @Override
    public String getType() {
        return "JAVA";
    }
..}

1

© www.soinside.com 2019 - 2024. All rights reserved.