本文整理汇总了Java中org.eclipse.emf.compare.Comparison类的典型用法代码示例。如果您正苦于以下问题:Java Comparison类的具体用法?Java Comparison怎么用?Java Comparison使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Comparison类属于org.eclipse.emf.compare包,在下文中一共展示了Comparison类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compareEObjects
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
private boolean compareEObjects(EObject e1, EObject e2) {
if (e1 == e2) {
return true;
}
if (e1 == null || e2 == null) {
return false;
}
if (!compareInitialized) {
descriptor = new BasicPostProcessorDescriptorImpl(customPostProcessor, Pattern.compile(".*"), null);
registry = new PostProcessorDescriptorRegistryImpl<String>();
registry.put(customPostProcessor.getClass().getName(), descriptor);
compare = EMFCompare.builder().setPostProcessorRegistry(registry).setDiffEngine(diffEngine).build();
compareInitialized = true;
}
final IComparisonScope scope = new DefaultComparisonScope(e1, e2, null);
final Comparison comparison = compare.compare(scope);
return comparison.getDifferences().isEmpty();
}
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:22,代码来源:GenericTraceExtractor.java
示例2: findMatchingObjects
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
protected List<EObject> findMatchingObjects(final EObject model, final Collection<EObject> objects) {
boolean _isEmpty = objects.isEmpty();
if (_isEmpty) {
throw new IllegalArgumentException();
}
Resource _eResource = model.eResource();
EObject _head = IterableExtensions.<EObject>head(objects);
Resource _eResource_1 = _head.eResource();
final DefaultComparisonScope scope = new DefaultComparisonScope(_eResource, _eResource_1, null);
EMFCompare.Builder _builder = EMFCompare.builder();
EMFCompare _build = _builder.build();
final Comparison comparison = _build.compare(scope);
final Function1<EObject, EObject> _function = new Function1<EObject, EObject>() {
@Override
public EObject apply(final EObject object) {
Match _match = comparison.getMatch(object);
return _match.getLeft();
}
};
Iterable<EObject> _map = IterableExtensions.<EObject, EObject>map(objects, _function);
Iterable<EObject> _filterNull = IterableExtensions.<EObject>filterNull(_map);
return IterableExtensions.<EObject>toList(_filterNull);
}
开发者ID:spoenemann,项目名称:xtext-gef,代码行数:24,代码来源:GenericModelMerger.java
示例3: match
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
@Override
public Comparison match(IComparisonScope scope, Monitor monitor) {
Predicate<EObject> predicate = new Predicate<EObject>() {
@Override
public boolean apply(EObject eobject) {
// We only want to diff the SGraph and notation elements,
// not the transient palceholders for concrete languages
EPackage ePackage = eobject.eClass().getEPackage();
return ePackage == SGraphPackage.eINSTANCE || ePackage == NotationPackage.eINSTANCE;
}
};
if (scope instanceof DefaultComparisonScope) {
DefaultComparisonScope defaultScope = (DefaultComparisonScope) scope;
defaultScope.setEObjectContentFilter(predicate);
defaultScope.setResourceContentFilter(predicate);
}
return super.match(scope, monitor);
}
开发者ID:Yakindu,项目名称:statecharts,代码行数:19,代码来源:SCTMatchEngineFactory.java
示例4: postComparison
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例5: prettyPrint
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
protected static String prettyPrint(Comparison comparison) throws UnsupportedEncodingException {
String customPrettyPrint = comparison.getDifferences().stream()
.map(PlainTransformationTestBase::prettyPrintCustom).filter(Objects::nonNull)
.collect(Collectors.joining(String.format("%n")));
ByteArrayOutputStream baos = null;
PrintStream ps = null;
try {
baos = new ByteArrayOutputStream();
ps = new PrintStream(baos);
EMFComparePrettyPrinter.printDifferences(comparison, ps);
return customPrettyPrint + String.format("%n%n") + new String(baos.toByteArray(), "UTF-8");
} finally {
IOUtils.closeQuietly(ps);
IOUtils.closeQuietly(baos);
}
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:17,代码来源:PlainTransformationTestBase.java
示例6: distance
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
@Override
public double distance(Comparison comparison, EObject first, EObject second) {
double semanticDistanceThreshold = 0.26;
Class<?> firstClass = first.getClass();
Class<?> secondClass = second.getClass();
double result = Double.MAX_VALUE;
if (firstClass.toString().equals(secondClass.toString())) {
try {
String firstName = (String) firstClass.getMethod("getName", new Class<?>[] {}).invoke(first, new Object[] {});
String secondName = (String) secondClass.getMethod("getName", new Class<?>[] {}).invoke(second, new Object[] {});
this.wordnetDictionary.open();
result = new SemanticDistanceEvaluator(firstName, secondName, this.similarityComparationEngine, this.similarityMeasureConfiguration, this.wordnetNounIndexer, this.wordnetVerbIndexer, this.maxentTagger, this.wordnetStemmer).call();
this.wordnetDictionary.close();
//System.out.println(firstName);
//System.out.println(secondName);
//System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
//System.out.println(result <= semanticDistanceThreshold ? result : Double.MAX_VALUE);
return (double) result <= semanticDistanceThreshold ? result : Double.MAX_VALUE;
}
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:24,代码来源:SemanticDistanceFunction.java
示例7: match
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>
* <b>Note:</b> This method overrides
* {@link DefaultMatchEngine#match(Comparison, IComparisonScope, EObject, EObject, EObject, Monitor)}
* to remove incompatible Guava dependencies. It should be removed if/when
* Guava dependencies become compatible with NeoEMF.
*/
@Override
protected void match(Comparison comparison, IComparisonScope scope, EObject left,
EObject right, EObject origin, Monitor monitor) {
if (left == null || right == null) {
throw new IllegalArgumentException();
}
final Iterator<? extends EObject> leftEObjects = Iterators.concat(
Iterators.singletonIterator(left), scope.getChildren(left));
final Iterator<? extends EObject> rightEObjects = Iterators.concat(
Iterators.singletonIterator(right), scope.getChildren(right));
final Iterator<? extends EObject> originEObjects;
if (origin != null) {
originEObjects = Iterators.concat(Iterators.singletonIterator(origin),
scope.getChildren(origin));
} else {
originEObjects = Collections.emptyIterator();
}
getEObjectMatcher().createMatches(comparison, leftEObjects, rightEObjects, originEObjects,
monitor);
}
开发者ID:atlanmod,项目名称:NeoEMF,代码行数:31,代码来源:LazyMatchEngine.java
示例8: testArrayFieldDeclarationDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例9: testNewInTheMiddleDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例10: testRemovedFromTheMiddleDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例11: testPrimitivesDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例12: testDerivedCopyWithIgnoreImports
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例13: testDerivedCopyWithChangedMethodCounterpart
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例14: testDerivedCopyWithIgnoreConstructor
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例15: testArrayAccessesDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例16: testArrayItemAccessesDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的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
示例17: testArrayItemAccessWithSameContainerIdentifierDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
/**
* Test diffing of array access by an identifier within the same container. This test case is
* part of the fix for a bug causing a StackOverflowError (SPLEVO-427).
*
* @throws Exception
* Identifies a failed diffing.
*/
@Test
public void testArrayItemAccessWithSameContainerIdentifierDiff() throws Exception {
File testFileA = new File(basePath + "a/ArrayItemAccessWithSameContainerIdentifier.java");
File testFileB = new File(basePath + "b/ArrayItemAccessWithSameContainerIdentifier.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,代码行数:23,代码来源:StatementTest.java
示例18: testEnumAccessesDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
/**
* Test diffing of enum value accesses.
*
* @throws Exception
* Identifies a failed diffing.
*/
@Test
public void testEnumAccessesDiff() throws Exception {
File testFileA = new File(basePath + "a/EnumAccesses.java");
File testFileB = new File(basePath + "b/EnumAccesses.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
示例19: testClassStatementInsertDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
/**
* Test insertion of new statements and order changes
*
* @throws Exception
* Identifies a failed diffing.
*/
@Test
public void testClassStatementInsertDiff() throws Exception {
File testFileA = new File(basePath + "a/ClassStatementInsert.java");
File testFileB = new File(basePath + "b/ClassStatementInsert.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(7));
}
开发者ID:kopl,项目名称:SPLevo,代码行数:22,代码来源:StatementTest.java
示例20: testSynchronizedDiff
import org.eclipse.emf.compare.Comparison; //导入依赖的package包/类
/**
* Test insertion of new statements
*
* @throws Exception
* Identifies a failed diffing.
*/
@Test
public void testSynchronizedDiff() throws Exception {
File testFileA = new File(basePath + "a/Synchronized.java");
File testFileB = new File(basePath + "b/Synchronized.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));
}
开发者ID:kopl,项目名称:SPLevo,代码行数:22,代码来源:StatementTest.java
注:本文中的org.eclipse.emf.compare.Comparison类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论