Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langer2017-05-11 17:14:58 +0000
committerLaurent Goubet2017-07-06 12:54:43 +0000
commit9d475305806b71999f6cfec5ba0b1e815f36c9fd (patch)
treefa8203b9464017799ce59d4ac133d91c06f230db /plugins/org.eclipse.emf.compare.tests/src/org
parent56ad5529f9103568e2e7f30569e8e010de011f42 (diff)
downloadorg.eclipse.emf.compare-9d475305806b71999f6cfec5ba0b1e815f36c9fd.tar.gz
org.eclipse.emf.compare-9d475305806b71999f6cfec5ba0b1e815f36c9fd.tar.xz
org.eclipse.emf.compare-9d475305806b71999f6cfec5ba0b1e815f36c9fd.zip
[516524] Use more efficient feature look-up in ReferenceUtil
ReferenceUtil could make use of an EClass.getFeatureID(feature) which returns -1 if the feature doesn't belong to the class. Only in that case do we need to try to look up the feature by name. Once we've computed the feature ID, we can use it directly to efficiently access the generated reflective methods. This is a replacement of the reverted change 96871, as 96871 has been reverted for an Oxygen release candidate build of EMF Compare. Bug: 516524 Change-Id: I6ff031ebc02dd10bf3b0d88c00f03f15c25cfb62 Signed-off-by: Philip Langer <planger@eclipsesource.com>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org')
-rw-r--r--plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java
index f46559d4d..a905457db 100644
--- a/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java
+++ b/plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare/tests/utils/MatchUtilFeatureContainsTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 EclipseSource Muenchen GmbH.
+ * Copyright (c) 2015, 2017 EclipseSource Muenchen GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Michael Borkowski - initial tests
+ * Philip Langer - bug 516524
*******************************************************************************/
package org.eclipse.emf.compare.tests.utils;
@@ -31,11 +32,13 @@ import org.junit.Test;
@SuppressWarnings({"boxing", "nls" })
public class MatchUtilFeatureContainsTest {
+ private static final int MOCK_FEATURE_ID = 1;
+
List<EObject> featureList;
InternalEObject value;
- EObject container;
+ InternalEObject container;
EClass eClass;
@@ -45,17 +48,20 @@ public class MatchUtilFeatureContainsTest {
public void setUp() {
EPackage ePackage = mock(EPackage.class);
- container = mock(EObject.class);
+ container = mock(InternalEObject.class);
+
feature = mock(EStructuralFeature.class);
+ when(feature.isMany()).thenReturn(true);
eClass = mock(EClass.class);
when(eClass.getEPackage()).thenReturn(ePackage);
+ when(eClass.getFeatureID(feature)).thenReturn(MOCK_FEATURE_ID);
when(container.eClass()).thenReturn(eClass);
when(feature.getEContainingClass()).thenReturn(eClass);
featureList = new LinkedList<EObject>();
- when(container.eGet(feature, false)).thenReturn(featureList);
+ when(container.eGet(MOCK_FEATURE_ID, false, true)).thenReturn(featureList);
value = mockInternalObject();
featureList.add(value);

Back to the top