aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-03 08:10:57 (EDT)
committersefftinge2009-04-03 08:10:57 (EDT)
commit6cecee5b78ced02a1dbc93b12bd0072e68ab5a03 (patch)
treecca2676125d77f225bb02e489a3e81156ae58418
parentc6049044e6923ae675bfee65f4a40f18d5e6ea23 (diff)
downloadorg.eclipse.xtext-6cecee5b78ced02a1dbc93b12bd0072e68ab5a03.zip
org.eclipse.xtext-6cecee5b78ced02a1dbc93b12bd0072e68ab5a03.tar.gz
org.eclipse.xtext-6cecee5b78ced02a1dbc93b12bd0072e68ab5a03.tar.bz2
Make AbstractDeclarativeScopeProvider more configurable
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DeclarativeScopeProviderTest.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DeclarativeScopeProviderTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DeclarativeScopeProviderTest.java
index 101406b..64e3fc8 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DeclarativeScopeProviderTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DeclarativeScopeProviderTest.java
@@ -10,13 +10,20 @@ package org.eclipse.xtext.crossrefs;
import java.util.Collections;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.xtext.crossref.IScope;
import org.eclipse.xtext.crossref.IScopedElement;
import org.eclipse.xtext.crossref.impl.AbstractDeclarativeScopeProvider;
+import org.eclipse.xtext.crossref.impl.DefaultScopeProvider;
import org.eclipse.xtext.crossref.impl.SimpleScope;
import junit.framework.TestCase;
@@ -82,4 +89,32 @@ public class DeclarativeScopeProviderTest extends TestCase {
assertEquals(b,provider.getScope(details, details));
assertEquals(c,provider.getScope(details.getEContainingClass(), details));
}
+
+ @SuppressWarnings("unused")
+ public void testScopeByType() throws Exception {
+ final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IScopedElement>emptySet());
+ final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IScopedElement>emptySet());
+ final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IScopedElement>emptySet());
+ AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
+ private IScope scope_EClass(EClassifier clazz, EReference ref) {
+ return a;
+ }
+
+ private IScope scope_EClass(EClass clazz, EReference ref) {
+ return c;
+ }
+
+ private IScope scope_EClass(EReference ctx, EReference ref) {
+ return b;
+ }
+ };
+ DefaultScopeProvider defaultScopeProvider = new DefaultScopeProvider();
+ provider.setGenericFallBack(defaultScopeProvider);
+ ResourceSet resourceSet = new ResourceSetImpl();
+ Resource res = new XMIResourceFactoryImpl().createResource(URI.createURI("test.uri"));
+ resourceSet.getResources().add(res);
+ EReference details = (EReference) EcoreUtil.copy(EcorePackage.eINSTANCE.getEClass_ESuperTypes());
+ res.getContents().add(details);
+ assertNotNull(provider.getScope(details, details.eClass()));
+ }
}