当前位置: 首页>>代码示例>>Java>>正文


Java Diff.getKind方法代码示例

本文整理汇总了Java中org.eclipse.emf.compare.Diff.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java Diff.getKind方法的具体用法?Java Diff.getKind怎么用?Java Diff.getKind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.emf.compare.Diff的用法示例。


在下文中一共展示了Diff.getKind方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: identifyParentMethodDeletes

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
private List<Diff> identifyParentMethodDeletes(Match classMatch) {

        Class copiedClass = (Class) classMatch.getLeft();
        List<Diff> changesToIgnore = Lists.newLinkedList();

        for (Diff diff : classMatch.getDifferences()) {

            if (diff.getKind() != DifferenceKind.DELETE) {
                continue;
            }

            if (diff instanceof MethodChange) {
                changesToIgnore.add(diff);
            }

            if (diff instanceof ConstructorChange) {
                Constructor origConstructor = ((ConstructorChange) diff).getChangedConstructor();
                if (hasEquivalentConstructor(copiedClass, origConstructor)) {
                    changesToIgnore.add(diff);
                    continue;
                }
            }
        }

        return changesToIgnore;
    }
 
开发者ID:kopl,项目名称:SPLevo,代码行数:27,代码来源:DerivedCopyFilter.java

示例2: identifyParentFieldDeletes

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Find all field deletes within a match of a class.
 *
 * @param classMatch
 *            The match to check for field deletes
 * @return The list of field deletes.
 */
private List<Diff> identifyParentFieldDeletes(Match classMatch) {

    List<Diff> changesToIgnore = Lists.newLinkedList();

    for (Diff diff : classMatch.getDifferences()) {

        if (diff.getKind() != DifferenceKind.DELETE) {
            continue;
        }

        if (diff instanceof FieldChange) {
            changesToIgnore.add(diff);
        }
    }

    return changesToIgnore;
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:25,代码来源:DerivedCopyFilter.java

示例3: buildKindSpecificVariationPoint

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Build a variation point according to the change kind of the provided Change.
 *
 * @param diff
 *            The Diff element to build the VP for.
 * @param changedCommentable
 *            The changed software AST node.
 * @return The variation point for the provided Diff.
 */
private VariationPoint buildKindSpecificVariationPoint(Diff diff, Commentable changedCommentable) {
    Commentable parent = getParentNode(changedCommentable);

    switch (diff.getKind()) {
    case ADD:
        return createVariationPointInsert(changedCommentable, parent);

    case DELETE:
        return createVariationPointDelete(changedCommentable, parent);

    case CHANGE:
        return createVariationPointChange(changedCommentable, parent);

    default:
        logger.error("Unhandled change: " + diff);
        return null;
    }
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:28,代码来源:JaMoPPDiffVisitor.java

示例4: testDerivedCopyWithChangedMethod

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Test method for a derived copy scenarios with derived, overloaded and not visible methods.
 * <ul>
 * <li>1 method derived</li>
 * <li>1 method overridden</li>
 * <li>1 method not visible</li>
 * </ul>
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testDerivedCopyWithChangedMethod() throws Exception {

    String basePath = "testmodels/implementation/derivedcopymethod/";
    ResourceSet setA = TestUtil.extractModel(basePath + "a");
    ResourceSet setB = TestUtil.extractModel(basePath + "b");

    StringBuilder packageMapping = new StringBuilder();

    StringBuilder classifierNormalization = new StringBuilder();
    classifierNormalization.append("*Custom");

    JaMoPPDiffer differ = new JaMoPPDiffer();

    Map<String, String> diffOptions = TestUtil.getDiffOptions();
    diffOptions.put(JaMoPPDiffer.OPTION_JAVA_PACKAGE_NORMALIZATION, packageMapping.toString());
    diffOptions.put(JaMoPPDiffer.OPTION_JAVA_CLASSIFIER_NORMALIZATION, classifierNormalization.toString());
    diffOptions.put(JaMoPPPostProcessor.OPTION_DIFF_CLEANUP_DERIVED_COPIES, "true");

    Comparison comparison = differ.doDiff(setA, setB, diffOptions);

    EList<Diff> differences = comparison.getDifferences();

    for (Diff diff : differences) {
        if (diff.getKind() == DifferenceKind.ADD) {
            assertThat("ADD of wrong type detected", diff, instanceOf(StatementChange.class));
        } else {
            fail("Change of unexpected kind detected: " + diff.getKind());
        }
    }

    assertThat("Wrong number of differences", differences.size(), is(1));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:45,代码来源:DerivedCopyTest.java

示例5: testIfElseStatementDiff

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Test insertion of new statements
 * 
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testIfElseStatementDiff() throws Exception {

    File testFileA = new File(basePath + "a/IfElseStatements.java");
    File testFileB = new File(basePath + "b/IfElseStatements.java");
    ResourceSet rsA = TestUtil.loadResourceSet(Sets.newHashSet(testFileA));
    ResourceSet rsB = TestUtil.loadResourceSet(Sets.newHashSet(testFileB));

    JaMoPPDiffer differ = new JaMoPPDiffer();
    Comparison comparison = differ.doDiff(rsA, rsB, TestUtil.getDiffOptions());

    EList<Diff> differences = comparison.getDifferences();

    assertThat("Wrong number of differences", differences.size(), is(2));

    for (Diff diff : differences) {
        assertThat("StatementChange expected", diff, instanceOf(StatementChange.class));
        StatementChange stmtChange = (StatementChange) diff;
        assertThat("Wrong changed statement type", stmtChange.getChangedStatement(), instanceOf(Condition.class));

        Condition condition = (Condition) stmtChange.getChangedStatement();
        EqualityExpression exp = (EqualityExpression) condition.getCondition();
        DecimalIntegerLiteral value = (DecimalIntegerLiteral) exp.getChildren().get(1);

        if (diff.getKind() == DifferenceKind.ADD) {
            assertThat("Wrong condition for add", value.getDecimalValue(), is(equalTo(BigInteger.valueOf(54))));
        } else if (diff.getKind() == DifferenceKind.DELETE) {
            assertThat("Wrong condition for add", value.getDecimalValue(), is(equalTo(BigInteger.valueOf(2))));
        } else {
            fail("Unexpected condition value: " + value);
        }
    }
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:40,代码来源:StatementTest.java

示例6: testIfElseMultipleStatementDiff

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Test insertion of new statements
 * 
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testIfElseMultipleStatementDiff() throws Exception {

    File testFileA = new File(basePath + "a/IfElseMultipleStatements.java");
    File testFileB = new File(basePath + "b/IfElseMultipleStatements.java");
    ResourceSet rsA = TestUtil.loadResourceSet(Sets.newHashSet(testFileA));
    ResourceSet rsB = TestUtil.loadResourceSet(Sets.newHashSet(testFileB));

    JaMoPPDiffer differ = new JaMoPPDiffer();
    Comparison comparison = differ.doDiff(rsA, rsB, TestUtil.getDiffOptions());

    EList<Diff> differences = comparison.getDifferences();

    assertThat("Wrong number of differences", differences.size(), is(2));

    for (Diff diff : differences) {
        assertThat("StatementChange expected", diff, instanceOf(StatementChange.class));
        StatementChange stmtChange = (StatementChange) diff;
        assertThat("Wrong changed statement type", stmtChange.getChangedStatement(), instanceOf(Condition.class));

        Condition condition = (Condition) stmtChange.getChangedStatement();
        EqualityExpression exp = (EqualityExpression) condition.getCondition();
        DecimalIntegerLiteral value = (DecimalIntegerLiteral) exp.getChildren().get(1);

        if (diff.getKind() == DifferenceKind.ADD) {
            assertThat("Wrong condition for add", value.getDecimalValue(), is(equalTo(BigInteger.valueOf(54))));
        } else if (diff.getKind() == DifferenceKind.DELETE) {
            assertThat("Wrong condition for add", value.getDecimalValue(), is(equalTo(BigInteger.valueOf(2))));
        } else {
            fail("Unexpected condition value: " + value);
        }
    }
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:40,代码来源:StatementTest.java

示例7: overlayChangeType

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Create a change type specific overlay for the provided base image. This assumes the provided
 * object is of type Diff.
 *
 * @param baseImage
 *            The base image to overlay.
 * @param diff
 *            The diff element to get the kind for.
 * @param itemProvider
 *            The item provider to generate the overlay.
 * @return The prepared change image.
 */
public static Object overlayChangeType(Object baseImage, Diff diff, DiffItemProvider itemProvider) {
    switch (diff.getKind()) {
    case ADD:
        return ImageUtil.makeInsertIcon(baseImage, itemProvider);

    case DELETE:
        return ImageUtil.makeDeleteIcon(baseImage, itemProvider);

    case CHANGE:
    case MOVE:
    default:
        return ImageUtil.makeChangeIcon(baseImage, itemProvider);
    }
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:27,代码来源:ImageUtil.java

示例8: getImportDeleteDiffs

import org.eclipse.emf.compare.Diff; //导入方法依赖的package包/类
/**
 * Detect the import deletes that can be ignored.
 *
 * Due to the derived copy match, the original CompilationUnit is matched twice to it's
 * counterpart in the copy and to the derived CompilationUnit in the copy.
 *
 * <table>
 * <tr>
 * <th>Original</th>
 * <th>Copy</th>
 * </tr>
 * <tr>
 * <td>BaseClass.java</td>
 * <td>BaseClass.java</td>
 * </tr>
 * <tr>
 * <td>BaseClass.java</td>
 * <td>BaseClassCustom.java</td>
 * </tr>
 * </table>
 * <p>
 * The derived copy typically is a sub match of the match between the BaseClass and the
 * BaseClassCustom (in the example above). However, differences identified are typically
 * registered for the primary match of the original source. This seems to happen because the
 * comparison model returns a single side match only when asked for a match of an EObject:
 * Comparison#getMatch(EObject).
 * </p>
 * <p>
 * DesignDecision: Using primary compilation unit match.
 * </p>
 * <p>
 * To be able to access the import deletes, the comparison model is asked for the compilation
 * unit match instead of just using the one provided as parameter.
 * </p>
 *
 * @param cuMatch
 *            The compilation unit match to search import deletes for.
 * @return The list of import deletes
 */
private List<ImportChange> getImportDeleteDiffs(Match cuMatch) {

    // TODO: Check Cleanup primary Match
    // as we no longer use duplicate matches for derived copies
    // we might be able to use the cuMatch directly
    CompilationUnit originalCU = (CompilationUnit) cuMatch.getRight();
    Match primaryMatch = cuMatch.getComparison().getMatch(originalCU);

    List<ImportChange> ignoreImports = Lists.newArrayList();

    for (Diff diff : primaryMatch.getDifferences()) {
        if (diff instanceof ImportChange && diff.getKind() == DifferenceKind.DELETE) {
            ignoreImports.add((ImportChange) diff);
        }
    }
    return ignoreImports;
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:57,代码来源:DerivedCopyFilter.java


注:本文中的org.eclipse.emf.compare.Diff.getKind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。