Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Langer2017-05-11 17:14:58 +0000
committerPhilip Langer2017-05-23 15:38:17 +0000
commit888d9a60c302d4519bf01f088d0c22b585cff675 (patch)
tree6804b1e7f841c3b9c446ce1bdf4454c960c4e121 /plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare
parent47f29ed984d7c941aa33c035297fd0b56ca17b31 (diff)
downloadorg.eclipse.emf.compare-888d9a60c302d4519bf01f088d0c22b585cff675.tar.gz
org.eclipse.emf.compare-888d9a60c302d4519bf01f088d0c22b585cff675.tar.xz
org.eclipse.emf.compare-888d9a60c302d4519bf01f088d0c22b585cff675.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. Bug: 516524 Change-Id: I6ff031ebc02dd10bf3b0d88c00f03f15c25cfb61 Signed-off-by: Philip Langer <planger@eclipsesource.com>
Diffstat (limited to 'plugins/org.eclipse.emf.compare.tests/src/org/eclipse/emf/compare')
-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