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


Java Diff类代码示例

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


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

示例1: hasDiffForFeature

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Tells if there is a difference in the given {@link Match} for the given {@link EStructuralFeature}.
 * 
 * @param match
 *            the {@link Match}
 * @param feature
 *            the {@link EStructuralFeature}
 * @return <code>true</code> if there is a difference in the given {@link Match} for the given
 *         {@link EStructuralFeature}, <code>false</code> otherwise
 */
protected boolean hasDiffForFeature(Match match, EStructuralFeature feature) {
	boolean res = false;

	for (Diff diff : match.getDifferences()) {
		if (diff instanceof AttributeChange) {
			if (((AttributeChange)diff).getAttribute() == feature) {
				res = true;
				break;
			}
		} else if (diff instanceof ReferenceChange) {
			if (((ReferenceChange)diff).getReference() == feature) {
				res = true;
				break;
			}
		}
	}

	return res;
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:30,代码来源:EObjectConnector.java

示例2: postComparison

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
@Override
public void postComparison(Comparison comparison, Monitor monitor) {
	for (Diff diff : comparison.getDifferences()) {
		if (diff instanceof EdgeChange) {
			EdgeChange edgeChange = (EdgeChange) diff;
			switch (edgeChange.getKind()) {
			case ADD:
				postProcessEdgeAddition(edgeChange);
				break;
			case DELETE:
				postProcessEdgeDeletion(edgeChange);
				break;
			default: // do nothing
			}

		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:EdgeChangePostProcessor.java

示例3: postProcessEdgeAddition

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * In this case by default following dependencies are created:<br>
 * <br>
 * EdgeDeletion --requires-> OutgoingTransitionDeletion <-requires--
 * IncomingTransitionDeletion<br>
 * <br>
 * Needs to be changed into:<br>
 * <br>
 * EdgeDeletion --requires-> IncomingTransitionDeletion --requires->
 * OutgoingTransitionDeletion<br>
 * 
 * @param edgeChange
 */
private void postProcessEdgeAddition(EdgeChange edgeChange) {
	Set<Diff> requiredIncomingTransitionAdditions = new HashSet<Diff>();
	for (Diff requireds : edgeChange.getRequires()) {
		if (requireds instanceof ReferenceChange) {
			ReferenceChange requiredRefChange = (ReferenceChange) requireds;
			// for required changes in outgoing transition refs we also need
			// to add the corresponding change in incoming transition refs
			if (requiredRefChange.getReference() == SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS
					&& requiredRefChange.getKind() == DifferenceKind.ADD) {
				requiredIncomingTransitionAdditions
						.addAll(findRequiredIncomingTransitionRefChange(
								requiredRefChange, DifferenceKind.ADD));
			}
		}
	}
	edgeChange.getRequires().addAll(requiredIncomingTransitionAdditions);
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:31,代码来源:EdgeChangePostProcessor.java

示例4: postProcessEdgeDeletion

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * In this case by default following dependencies are created:<br>
 * <br>
 * EdgeDeletion <-requires-- OutgoingTransitionDeletion --requires->
 * IncomingTransitionDeletion<br>
 * <br>
 * Needs to be changed into:<br>
 * <br>
 * EdgeDeletion --requires-> OutgoingTransitionDeletion --requires->
 * IncomingTransitionDeletion<br>
 * 
 * @param edgeChange
 */
private void postProcessEdgeDeletion(EdgeChange edgeChange) {
	Set<Diff> requiredOutgoingTransitionDeletions = new HashSet<Diff>();
	for (Diff requireds : edgeChange.getRequiredBy()) {
		if (requireds instanceof ReferenceChange) {
			ReferenceChange requiredRefChange = (ReferenceChange) requireds;
			// for required changes in outgoing transition refs we also need
			// to add the corresponding change in incoming transition refs
			if (requiredRefChange.getReference() == SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS
					&& requiredRefChange.getKind() == DifferenceKind.DELETE) {
				requiredOutgoingTransitionDeletions.add(requiredRefChange);
			}
		}
	}
	edgeChange.getRequires().addAll(requiredOutgoingTransitionDeletions);
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:29,代码来源:EdgeChangePostProcessor.java

示例5: prettyPrintCustom

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
private static String prettyPrintCustom(Diff diff) {
    CompareSwitch<String> printer = new CompareSwitch<String>() {

        @Override
        public String caseReferenceChange(ReferenceChange object) {
            EObject actual = object.getMatch().getRight();
            EObject expected = object.getMatch().getLeft();
            EReference reference = object.getReference();

            if (actual != null && expected != null) {
                EObject parent = actual;
                String referenceName = String.format("%s::%s", reference.getEContainingClass().getName(),
                        object.getReference().getName());
                Object actualValue = actual.eGet(reference);
                Object expectedValue = expected.eGet(reference);

                return String.format(
                        "ReferenceChange%n\tParent: %s%n\tReference: %s%n\tExpected Value: %s%n\tActual Value: %s",
                        parent, referenceName, expectedValue, actualValue);
            }
            return defaultCase(object);
        }

    };
    return printer.doSwitch(diff);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:27,代码来源:PlainTransformationTestBase.java

示例6: testRegular

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
protected void testRegular(String modelName, Function<Collection<Diff>, Collection<Diff>> diffProcessor)
        throws Exception {
    URI sourceModelURI = createResourceModelURI(resourcePluginId, modelName + "." + sourceFileExtension);
    URI umlModelURI = createResourceModelURI(resourcePluginId, modelName + ".uml");
    URI resultModelURI = createResourceModelURI(resourcePluginId, modelName + "." + targetFileExtension);

    ModelExtent transformationResult = runTransformation(transformationURI, sourceModelURI, umlModelURI);

    EObject expected = getRootElement(resultModelURI);
    assertEquals(1, transformationResult.getContents().size());
    EObject actual = transformationResult.getContents().get(0);
    EcoreUtil.resolveAll(getResourceSet());

    debugSerialize(expected, actual);

    assertModelEquals(expected, actual, diffProcessor);
}
 
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:DirectionalTransformationTestBase.java

示例7: testArrayFieldDeclarationDiff

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test diffing of changed array field declarations.
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testArrayFieldDeclarationDiff() throws Exception {

    TestUtil.setUp();
    File testFileA = new File(basePathA + "ArrayFieldDeclarationChange.java");
    File testFileB = new File(basePathB + "ArrayFieldDeclarationChange.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("1 difference should be detected", differences.size(), is(1));
    FieldChange change = (FieldChange) differences.get(0);
    assertThat("Wrong diff kind", change.getKind(), is(DifferenceKind.CHANGE));
    assertThat("Diff should be FieldChange", change, is(instanceOf(FieldChange.class)));
    Field field = change.getChangedField();
    assertThat("Wrong field name", field.getName(), is("newValueArray"));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:28,代码来源:FieldDeclarationTest.java

示例8: testNewInTheMiddleDiff

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test new field declarations to ignore field order.
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testNewInTheMiddleDiff() throws Exception {

    TestUtil.setUp();
    File testFileA = new File(basePathA + "NewInTheMiddle.java");
    File testFileB = new File(basePathB + "NewInTheMiddle.java");
    ResourceSet rsLeading = TestUtil.loadResourceSet(Sets.newHashSet(testFileA));
    ResourceSet rsIntegration = TestUtil.loadResourceSet(Sets.newHashSet(testFileB));

    JaMoPPDiffer differ = new JaMoPPDiffer();
    Comparison comparison = differ.doDiff(rsLeading, rsIntegration, TestUtil.getDiffOptions());

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

    assertThat("1 difference should be detected", differences.size(), is(1));
    FieldChange change = (FieldChange) differences.get(0);
    assertThat("Diff should be FieldChange", change, is(instanceOf(FieldChange.class)));
    assertThat("Wrong diff kind", change.getKind(), is(DifferenceKind.ADD));
    Field field = change.getChangedField();
    assertThat("Wrong field name", field.getName(), is("newField"));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:28,代码来源:FieldDeclarationTest.java

示例9: testRemovedFromTheMiddleDiff

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test new field declarations to ignore field order.
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testRemovedFromTheMiddleDiff() throws Exception {

    TestUtil.setUp();
    File testFileA = new File(basePathA + "RemovedFromTheMiddle.java");
    File testFileB = new File(basePathB + "RemovedFromTheMiddle.java");
    ResourceSet rsLeading = TestUtil.loadResourceSet(Sets.newHashSet(testFileA));
    ResourceSet rsIntegration = TestUtil.loadResourceSet(Sets.newHashSet(testFileB));

    JaMoPPDiffer differ = new JaMoPPDiffer();
    Comparison comparison = differ.doDiff(rsLeading, rsIntegration, TestUtil.getDiffOptions());

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

    assertThat("1 difference should be detected", differences.size(), is(1));
    FieldChange change = (FieldChange) differences.get(0);
    assertThat("Diff should be FieldChange", change, is(instanceOf(FieldChange.class)));
    assertThat("Wrong diff kind", change.getKind(), is(DifferenceKind.DELETE));
    Field field = change.getChangedField();
    assertThat("Wrong field name", field.getName(), is("removeField"));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:28,代码来源:FieldDeclarationTest.java

示例10: testPrimitivesDiff

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test primitive declarations
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testPrimitivesDiff() throws Exception {

    File testFileA = new File(basePath + "a/Primitives.java");
    File testFileB = new File(basePath + "b/Primitives.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));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:22,代码来源:PrimitivesTest.java

示例11: testDerivedCopyWithIgnoreImports

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test method to detect changes in the class and package declarations.
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testDerivedCopyWithIgnoreImports() throws Exception {

    String basePath = "testmodels/implementation/derivedcopyimport/";
    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();
    assertThat("No diff because not present imports must not be detected as deleted", differences.size(), is(0));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:31,代码来源:DerivedCopyTest.java

示例12: testDerivedCopyWithChangedMethodCounterpart

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test that the derived method delete is not filtered if anyway.
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testDerivedCopyWithChangedMethodCounterpart() 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");
    diffOptions.put(JaMoPPPostProcessor.OPTION_DIFF_CLEANUP_DERIVED_COPIES_CLEAN_METHODS, null);

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

    EList<Diff> differences = comparison.getDifferences();
    assertThat("Wrong number of differences", differences.size(), is(3));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:32,代码来源:DerivedCopyTest.java

示例13: testDerivedCopyWithIgnoreConstructor

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test that the derived method delete is not filtered if anyway.
 *
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testDerivedCopyWithIgnoreConstructor() throws Exception {

    String basePath = "testmodels/implementation/derivedcopyconstructor/";
    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();
    assertThat("There should be no differences", differences.size(), is(0));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:31,代码来源:DerivedCopyTest.java

示例14: testArrayAccessesDiff

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test diffing of changed array field declarations.
 * 
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testArrayAccessesDiff() throws Exception {

    File testFileA = new File(basePath + "a/ArrayAccesses.java");
    File testFileB = new File(basePath + "b/ArrayAccesses.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(0));
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:22,代码来源:StatementTest.java

示例15: testArrayItemAccessesDiff

import org.eclipse.emf.compare.Diff; //导入依赖的package包/类
/**
 * Test diffing of changed array field declarations.
 * 
 * @throws Exception
 *             Identifies a failed diffing.
 */
@Test
public void testArrayItemAccessesDiff() throws Exception {

    File testFileA = new File(basePath + "a/ArrayItemAccess.java");
    File testFileB = new File(basePath + "b/ArrayItemAccess.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(1));

    StatementChange change = (StatementChange) differences.get(0);
    ExpressionStatement statement = (ExpressionStatement) change.getChangedStatement();
    AssignmentExpression exp = (AssignmentExpression) statement.getExpression();
    NewConstructorCall call = (NewConstructorCall) exp.getValue();
    StringReference stringRef = (StringReference) call.getArguments().get(0);
    assertThat(stringRef.getValue(), equalTo("3"));

}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:30,代码来源:StatementTest.java


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