summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-20 02:32:50 (EDT)
committer sefftinge2009-04-20 02:32:50 (EDT)
commit3d67dcd8e4cb55df528232071c6a867116499ac7 (patch)
tree9ea0f3dea0dace4b2d502a61a8b3f06424b167f7
parent0c1c85bfeb85c1ae6b56512da03787e89cc7be3b (diff)
downloadorg.eclipse.xtext-3d67dcd8e4cb55df528232071c6a867116499ac7.zip
org.eclipse.xtext-3d67dcd8e4cb55df528232071c6a867116499ac7.tar.gz
org.eclipse.xtext-3d67dcd8e4cb55df528232071c6a867116499ac7.tar.bz2
Reverted https://bugs.eclipse.org/bugs/show_bug.cgi?id=270963
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinker.java8
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinkingService.java4
-rw-r--r--examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslScopeProvider.java8
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaProposalProvider.java4
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java3
-rw-r--r--plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hyperlinking/HyperlinkHelper.java8
-rw-r--r--plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/contentassist/ContentAssistHelper.java4
-rw-r--r--plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/Scope.java2
-rwxr-xr-xplugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/XtendScopeProvider.java36
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/CrossRefTest.java2
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/DeclarativeScopeProviderTest.java31
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java6
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/PluginTestSuite.java1
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/InheritanceTest.java12
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextScopingTest.java65
-rw-r--r--tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.ext4
-rw-r--r--tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.java5
17 files changed, 72 insertions, 131 deletions
diff --git a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinker.java b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinker.java
index c04cc11..a87d454 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinker.java
+++ b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinker.java
@@ -27,12 +27,12 @@ public class EcoreDslLinker extends Linker {
protected final Logger logger = Logger.getLogger(getClass());
@Override
- protected void setDefaultValueImpl(EObject rootModel, EObject obj, EReference ref, IDiagnosticProducer producer) {
+ protected void setDefaultValueImpl(EObject obj, EReference ref, IDiagnosticProducer producer) {
//hack: ePackage always needs an eFactoryInstance (gets cleared in #clearReferences?)
if (ref.getName().equalsIgnoreCase("eFactoryInstance")) {
((EPackage) obj).setEFactoryInstance(EcoreFactory.eINSTANCE.createEFactory());
}
- super.setDefaultValueImpl(rootModel, obj, ref, producer);
+ super.setDefaultValueImpl(obj, ref, producer);
}
@Override
@@ -42,8 +42,8 @@ public class EcoreDslLinker extends Linker {
// hack: exceptions when eType, eExceptions are null
for (EReference ref : allReferences) {
try {
- if (ref.isContainment() ||
- ref.isContainer() ||
+ if (ref.isContainment() ||
+ ref.isContainer() ||
ref.isDerived() || obj.eGet(ref) == null || ref.getName() == null
|| (obj instanceof ETypedElement && ref.getName().equalsIgnoreCase("eType"))
|| (obj instanceof ETypedElement && ref.getName().equalsIgnoreCase("eExceptions"))) {
diff --git a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinkingService.java b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinkingService.java
index 332df2a..10d70c8 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinkingService.java
+++ b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslLinkingService.java
@@ -40,11 +40,11 @@ public class EcoreDslLinkingService extends DefaultLinkingService {
private IValueConverterService valueConverterService;
@Override
- public List<EObject> getLinkedObjects(EObject rootModel, EObject context, EReference ref,
+ public List<EObject> getLinkedObjects(EObject context, EReference ref,
AbstractNode node) throws IllegalNodeException {
if (ref == EcoredslPackage.eINSTANCE.getReferencedMetamodel_EPackage())
return getPackage((ReferencedMetamodel) context, (LeafNode) node);
- return super.getLinkedObjects(rootModel, context, ref, node);
+ return super.getLinkedObjects(context, ref, node);
}
private List<EObject> getPackage(ReferencedMetamodel context, LeafNode text) {
diff --git a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslScopeProvider.java b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslScopeProvider.java
index 0d2c27d..7a9b0c0 100644
--- a/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslScopeProvider.java
+++ b/examples/org.eclipse.xtext.example.ecoredsl/src/org/eclipse/xtext/example/linker/EcoreDslScopeProvider.java
@@ -40,17 +40,17 @@ public class EcoreDslScopeProvider extends DefaultScopeProvider {
private IValueConverterService valueConverterService;
@Override
- protected IScope createScope(EObject rootModel, Resource resource, EClass type) {
+ protected IScope createScope(Resource resource, EClass type) {
if (EcorePackage.Literals.EPACKAGE == type) {
EcoreDsl ecoreDsl = (EcoreDsl) resource.getResourceSet()
.getEObject(resource.getURI().appendFragment("/"), true);
return createEPackageScope(ecoreDsl);
}
- return super.createScope(rootModel, resource, type);
+ return super.createScope(resource, type);
}
@Override
- public IScope getScope(EObject rootModel, EObject context, EReference reference) {
+ public IScope getScope(EObject context, EReference reference) {
if (reference.getEType()
.equals(EcorePackage.eINSTANCE.getEClassifier())) {
EcoreDsl ecoreDsl = (EcoreDsl) context.eResource().getResourceSet()
@@ -68,7 +68,7 @@ public class EcoreDslScopeProvider extends DefaultScopeProvider {
allClassifiers.addAll(ecoreDsl.getPackage().getEClassifiers());
return createClassifierScope(allClassifiers);
}
- return super.getScope(rootModel, context, reference);
+ return super.getScope(context, reference);
}
private IScope createEPackageScope(final EcoreDsl ecoreDsl) {
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaProposalProvider.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaProposalProvider.java
index 0ee0f6b..07a5e5e 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaProposalProvider.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/AbstractJavaProposalProvider.java
@@ -16,7 +16,6 @@ import org.apache.log4j.Logger;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.text.templates.TemplateContextType;
@@ -214,8 +213,7 @@ public abstract class AbstractJavaProposalProvider implements IProposalProvider
EClass eClass = (EClass) containingParserRule.getType().getClassifier();
EReference ref = GrammarUtil.getReference(crossReference,eClass);
String trimmedPrefix = contentAssistContext.getMatchString().trim();
- EObject context = contentAssistContext.getModel();
- IScope scope = scopeProvider.getScope(EcoreUtil.getRootContainer(context), context, ref);
+ IScope scope = scopeProvider.getScope(contentAssistContext.getModel(), ref);
Iterable<IScopedElement> candidates = scope.getAllContents();
for (IScopedElement candidate : candidates) {
if (null != candidate.name() && isCandidateMatchingPrefix(contentAssistContext
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java
index bd40cc4..ea30041 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/contentassist/impl/XtextTemplateContextType.java
@@ -62,9 +62,8 @@ public class XtextTemplateContextType extends TemplateContextType {
EReference reference = getReference(classReferencePair[0], classReferencePair[1], getGrammar(xtextTemplateContext));
- EObject eContext = xtextTemplateContext.getContentAssistContext().getModel();
Iterable<IScopedElement> linkingCandidates = xtextTemplateContext.getScopeProvider()
- .getScope(EcoreUtil.getRootContainer(eContext), eContext, reference).getAllContents();
+ .getScope(xtextTemplateContext.getContentAssistContext().getModel(), reference).getAllContents();
List<String> names = new ArrayList<String>();
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hyperlinking/HyperlinkHelper.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hyperlinking/HyperlinkHelper.java
index ba1600c..c681c48 100644
--- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hyperlinking/HyperlinkHelper.java
+++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/hyperlinking/HyperlinkHelper.java
@@ -57,7 +57,7 @@ public class HyperlinkHelper {
Assert.isNotNull(parseResult);
AbstractNode abstractNode = ParseTreeUtil.getCurrentOrFollowingNodeByOffset(parseResult.getRootNode(), offset);
final Wrapper<Region> location = Wrapper.wrap(new Region(abstractNode.getOffset(), abstractNode.getLength()));
- List<EObject> crossLinkedEObjects = findCrossLinkedEObject(resource.getContents().get(0), abstractNode, location);
+ List<EObject> crossLinkedEObjects = findCrossLinkedEObject(abstractNode, location);
if (crossLinkedEObjects.isEmpty())
return null;
final URIConverter uriConverter = resource.getResourceSet().getURIConverter();
@@ -75,7 +75,7 @@ public class HyperlinkHelper {
public OpenDeclarationAction getOpenDeclarationAction(XtextResource resource, int offset) {
AbstractNode node = ParseTreeUtil.getCurrentOrFollowingNodeByOffset(resource.getParseResult().getRootNode(), offset);
- List<EObject> crossLinkedEObject = findCrossLinkedEObject(resource.getContents().get(0), node, null);
+ List<EObject> crossLinkedEObject = findCrossLinkedEObject(node, null);
if (crossLinkedEObject.isEmpty())
return null;
final URI uri = EcoreUtil.getURI(crossLinkedEObject.get(0));
@@ -83,7 +83,7 @@ public class HyperlinkHelper {
return new OpenDeclarationAction(normalized, locationProvider);
}
- protected List<EObject> findCrossLinkedEObject(EObject rootModel, AbstractNode node, Wrapper<Region> location) {
+ protected List<EObject> findCrossLinkedEObject(AbstractNode node, Wrapper<Region> location) {
AbstractNode nodeToCheck = node;
while(nodeToCheck != null && !(nodeToCheck.getGrammarElement() instanceof Assignment)) {
if (nodeToCheck.getGrammarElement() instanceof CrossReference) {
@@ -93,7 +93,7 @@ public class HyperlinkHelper {
try {
if (location != null)
location.set(new Region(nodeToCheck.getOffset(), nodeToCheck.getLength()));
- return linkingService.getLinkedObjects(rootModel, semanticModel, eReference, nodeToCheck);
+ return linkingService.getLinkedObjects(semanticModel, eReference, nodeToCheck);
} catch (IllegalNodeException ex) {
return Collections.emptyList();
}
diff --git a/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/contentassist/ContentAssistHelper.java b/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/contentassist/ContentAssistHelper.java
index 26d0797..6d76b85 100644
--- a/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/contentassist/ContentAssistHelper.java
+++ b/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/contentassist/ContentAssistHelper.java
@@ -9,7 +9,6 @@ package org.eclipse.xtext.xtend.contentassist;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.xtext.AbstractElement;
import org.eclipse.xtext.crossref.IScope;
@@ -31,8 +30,7 @@ public class ContentAssistHelper {
public static IScope getScope(IScopeProvider scopeProvider, Object context, Object reference) {
if (reference == null)
return null;
- EObject eContext = (EObject) context;
- IScope scope = scopeProvider.getScope(EcoreUtil.getRootContainer(eContext), eContext, (EReference) reference);
+ IScope scope = scopeProvider.getScope((EObject) context, (EReference) reference);
return scope;
}
}
diff --git a/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/Scope.java b/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/Scope.java
index 50f0e3a..89c7e5f 100644
--- a/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/Scope.java
+++ b/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/Scope.java
@@ -22,7 +22,7 @@ import com.google.common.collect.Collections2;
* @author Sven Efftinge - Initial contribution and API
*
*/
-public class Scope extends AbstractScope {
+public class Scope extends AbstractScope implements IScope {
private List<IScopedElement> elements;
diff --git a/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/XtendScopeProvider.java b/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/XtendScopeProvider.java
index c790425..1d80a95 100755
--- a/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/XtendScopeProvider.java
+++ b/plugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/XtendScopeProvider.java
@@ -28,14 +28,14 @@ import com.google.inject.name.Named;
*
* IScope scope_<ExpectedTypeName>(<MyContextType> ctx, EReference ref) : ...
*
- * Where
+ * Where
* 1) ExpectedTypeName refers to ref.getEType().getName() and
* 2) MyContextType refers to the type (or any super type) of the source element.
*
* If no such declaration can be found it will sitch the ctx to ctx.eContainer and try again.
* Example:
- * If you have Classes containing Features which have a cross reference to a Class.
- * The implementation will first look for
+ * If you have Classes containing Features which have a cross reference to a Class.
+ * The implementation will first look for
*
* IScope scope_Class(Feature ctx,EReference ref) : ...
*
@@ -50,9 +50,9 @@ import com.google.inject.name.Named;
public class XtendScopeProvider extends AbstractXtendService implements IScopeProvider {
public final static String EXTENSION_FILE = "ScopeExtensions";
- private final String extensionFile;
+ private String extensionFile;
- private final DefaultScopeProvider defaultScopeProvider;
+ private DefaultScopeProvider defaultScopeProvider;
@Inject
public XtendScopeProvider(@Named(EXTENSION_FILE) String name, DefaultScopeProvider defaultScopeProvider) {
@@ -64,22 +64,23 @@ public class XtendScopeProvider extends AbstractXtendService implements IScopePr
private static final String SCOPE_EXTENSION_PREFIX = "scope_";
- public IScope getScope(EObject rootModel, EObject context, final EReference reference) {
+ public IScope getScope(EObject context, final EReference reference) {
try {
while (true) {
Object result = null;
try {
String extensionName = extensionName(context, reference);
- result = invokeExtension(extensionName, Lists.newArrayList(rootModel, context, reference));
+ result = invokeExtension(extensionName, Lists.newArrayList(context, reference));
} catch (NoSuchExtensionException e) {
// ignore
}
if (result != null)
return (IScope) result;
if (context.eContainer() != null) {
- return getScope(rootModel, context.eContainer(), reference);
+ return getScope(context.eContainer(), reference);
+ } else {
+ computeDefaultScope(context, reference);
}
- computeDefaultScope(rootModel, context, reference);
}
} catch (Throwable e) {
log.error("Error invoking scope extension", e);
@@ -87,22 +88,23 @@ public class XtendScopeProvider extends AbstractXtendService implements IScopePr
return null;
}
- public IScope getScope(EObject rootModel, EObject context, final EClass type) {
+ public IScope getScope(EObject context, final EClass type) {
try {
while (true) {
Object result = null;
try {
String extensionName = extensionName(context, type);
- result = invokeExtension(extensionName, Lists.newArrayList(rootModel, context, type));
+ result = invokeExtension(extensionName, Lists.newArrayList(context, type));
} catch (NoSuchExtensionException e) {
// ignore
}
if (result != null)
return (IScope) result;
if (context.eContainer() != null) {
- return getScope(rootModel, context.eContainer(), type);
+ return getScope(context.eContainer(), type);
+ } else {
+ computeDefaultScope(context, type);
}
- computeDefaultScope(rootModel, context, type);
}
} catch (Throwable e) {
log.error("Error invoking scope extension", e);
@@ -110,12 +112,12 @@ public class XtendScopeProvider extends AbstractXtendService implements IScopePr
return null;
}
- protected IScope computeDefaultScope(EObject rootModel, EObject ctx, EReference reference) {
- return this.defaultScopeProvider.getScope(rootModel, ctx, reference);
+ protected IScope computeDefaultScope(EObject ctx, EReference reference) {
+ return this.defaultScopeProvider.getScope(ctx, reference);
}
- protected IScope computeDefaultScope(EObject rootModel, EObject ctx, EClass type) {
- return this.defaultScopeProvider.getScope(rootModel, ctx, type);
+ protected IScope computeDefaultScope(EObject ctx, EClass type) {
+ return this.defaultScopeProvider.getScope(ctx, type);
}
private String extensionName(EObject context, EReference reference) {
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/CrossRefTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/CrossRefTest.java
index 7988e15..1725dbb 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/CrossRefTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/CrossRefTest.java
@@ -47,7 +47,7 @@ public class CrossRefTest extends AbstractGeneratorTest {
CrossReference xref = (CrossReference) asExtends.getTerminal();
EReference ref = GrammarUtil.getReference(xref, context.eClass());
- assertEquals(1, linkingService.getLinkedObjects(model, context, ref, leaf).size());
+ assertEquals(1, linkingService.getLinkedObjects(context, ref, leaf).size());
}
}
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 d207924..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
@@ -13,7 +13,6 @@ 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.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
@@ -38,13 +37,13 @@ public class DeclarativeScopeProviderTest extends TestCase {
public void testSimple() throws Exception {
final IScope a = new SimpleScope(IScope.NULLSCOPE, Collections.<IScopedElement>emptySet());
AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
- private IScope scope_EClass(EPackage rootModel, EClass clazz, EReference ref) {
+ private IScope scope_EClass(EClass clazz, EReference ref) {
return a;
}
};
EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
- assertEquals(a,provider.getScope(details.eClass().getEPackage(), details, details));
+ assertEquals(a,provider.getScope(details, details));
}
@SuppressWarnings("unused")
@@ -53,17 +52,17 @@ public class DeclarativeScopeProviderTest extends TestCase {
final IScope b = new SimpleScope(IScope.NULLSCOPE, Collections.<IScopedElement>emptySet());
AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
- private IScope scope_EClass(EPackage rootModel, EClass clazz, EReference ref) {
+ private IScope scope_EClass(EClass clazz, EReference ref) {
return a;
}
- private IScope scope_EClass(EPackage rootModel, EReference ctx, EReference ref) {
+ private IScope scope_EClass(EReference ctx, EReference ref) {
return b;
}
};
EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
- assertEquals(b,provider.getScope(details.eClass().getEPackage(), details, details));
- assertEquals(a,provider.getScope(details.eClass().getEPackage(), details.getEContainingClass(), details));
+ assertEquals(b,provider.getScope(details, details));
+ assertEquals(a,provider.getScope(details.getEContainingClass(), details));
}
@SuppressWarnings("unused")
@@ -73,22 +72,22 @@ public class DeclarativeScopeProviderTest extends TestCase {
final IScope c = new SimpleScope(IScope.NULLSCOPE, Collections.<IScopedElement>emptySet());
AbstractDeclarativeScopeProvider provider = new AbstractDeclarativeScopeProvider() {
- private IScope scope_EClass(EPackage rootModel, EClassifier clazz, EReference ref) {
+ private IScope scope_EClass(EClassifier clazz, EReference ref) {
return a;
}
- private IScope scope_EClass(EPackage rootModel, EClass clazz, EReference ref) {
+ private IScope scope_EClass(EClass clazz, EReference ref) {
return c;
}
- private IScope scope_EClass(EPackage rootModel, EReference ctx, EReference ref) {
+ private IScope scope_EClass(EReference ctx, EReference ref) {
return b;
}
};
EReference details = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
- assertEquals(b,provider.getScope(details.eClass().getEPackage(), details, details));
- assertEquals(c,provider.getScope(details.eClass().getEPackage(), details.getEContainingClass(), details));
+ assertEquals(b,provider.getScope(details, details));
+ assertEquals(c,provider.getScope(details.getEContainingClass(), details));
}
@SuppressWarnings("unused")
@@ -97,15 +96,15 @@ public class DeclarativeScopeProviderTest extends TestCase {
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(EPackage rootModel, EClassifier clazz, EReference ref) {
+ private IScope scope_EClass(EClassifier clazz, EReference ref) {
return a;
}
- private IScope scope_EClass(EPackage rootModel, EClass clazz, EReference ref) {
+ private IScope scope_EClass(EClass clazz, EReference ref) {
return c;
}
- private IScope scope_EClass(EPackage rootModel, EReference ctx, EReference ref) {
+ private IScope scope_EClass(EReference ctx, EReference ref) {
return b;
}
};
@@ -116,6 +115,6 @@ public class DeclarativeScopeProviderTest extends TestCase {
resourceSet.getResources().add(res);
EReference details = (EReference) EcoreUtil.copy(EcorePackage.eINSTANCE.getEClass_ESuperTypes());
res.getContents().add(details);
- assertNotNull(provider.getScope(details, details, details.eClass()));
+ assertNotNull(provider.getScope(details, details.eClass()));
}
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java
index 56ceb86..ad0a6bd 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/crossrefs/PartialLinkingTest.java
@@ -71,13 +71,13 @@ public class PartialLinkingTest extends AbstractGeneratorTest implements IScopeP
/**
* We try to emulate a changed scope after a partial parsing so we mock the ScopeService.
*/
- public IScope getScope(EObject rootModel, EObject context, EReference reference) {
+ public IScope getScope(EObject context, EReference reference) {
if (doFakeScope && context == this.context && reference == this.reference)
return IScope.NULLSCOPE;
- return scopeProvider.getScope(rootModel, context, reference);
+ return scopeProvider.getScope(context, reference);
}
- public IScope getScope(EObject rootModel, EObject context, EClass type) {
+ public IScope getScope(EObject context, EClass type) {
throw new UnsupportedOperationException();
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/PluginTestSuite.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/PluginTestSuite.java
index 4366480..1db3ff2 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/PluginTestSuite.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/generator/PluginTestSuite.java
@@ -94,7 +94,6 @@ public class PluginTestSuite {
suite.addTestSuite(org.eclipse.xtext.xtext.ResourceLoadTest.class);
suite.addTestSuite(org.eclipse.xtext.xtext.parser.packrat.XtextPackratParserTest.class);
suite.addTestSuite(org.eclipse.xtext.xtext.XtextValidationTest.class);
- suite.addTestSuite(org.eclipse.xtext.xtext.XtextScopingTest.class);
return suite;
}
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/InheritanceTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/InheritanceTest.java
index 138a5f3..615b733 100644
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/InheritanceTest.java
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/grammarinheritance/InheritanceTest.java
@@ -18,8 +18,11 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.AbstractRule;
import org.eclipse.xtext.GrammarUtil;
+import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.TypeRef;
+import org.eclipse.xtext.crossref.ILinkingService;
import org.eclipse.xtext.grammarinheritance.ametamodel.AmetamodelPackage;
+import org.eclipse.xtext.grammarinheritance.services.ConcreteTestLanguageGrammarAccess;
import org.eclipse.xtext.tests.AbstractGeneratorTest;
import com.google.common.base.Function;
@@ -63,4 +66,13 @@ public class InheritanceTest extends AbstractGeneratorTest {
}
assertTrue(expectedNames.toString(), expectedNames.isEmpty());
}
+
+ //see https://bugs.eclipse.org/bugs/show_bug.cgi?id=270963
+ public void _testScoping() {
+ ILinkingService l = getLinkingService();
+ ConcreteTestLanguageGrammarAccess ga = (ConcreteTestLanguageGrammarAccess) getGrammarAccess();
+ RuleCall rc = ga.getAbstractCallOverridenParserRuleAccess().getElementsOverridableParserRuleParserRuleCall_1_0();
+ String ref = l.getLinkText(rc.getRule(), rc.eContainmentFeature(), rc);
+ assertNotNull(ref);
+ }
}
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextScopingTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextScopingTest.java
deleted file mode 100644
index 5189ebd..0000000
--- a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/xtext/XtextScopingTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 itemis AG (http://www.itemis.eu) 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
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.xtext.xtext;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xtext.AbstractRule;
-import org.eclipse.xtext.Assignment;
-import org.eclipse.xtext.Grammar;
-import org.eclipse.xtext.GrammarUtil;
-import org.eclipse.xtext.Group;
-import org.eclipse.xtext.ParserRule;
-import org.eclipse.xtext.RuleCall;
-import org.eclipse.xtext.XtextPackage;
-import org.eclipse.xtext.XtextStandaloneSetup;
-import org.eclipse.xtext.junit.AbstractXtextTests;
-import org.eclipse.xtext.resource.XtextResourceSet;
-
-/**
- * @author Sebastian Zarnekow - Initial contribution and API
- */
-public class XtextScopingTest extends AbstractXtextTests {
-
- private Grammar grammar;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- with(XtextStandaloneSetup.class);
- XtextResourceSet resourceSet = get(XtextResourceSet.class);
- resourceSet.setClasspathURIContext(getClass().getClassLoader());
- Resource resource = resourceSet.getResource(
- URI.createURI("classpath:/org/eclipse/xtext/grammarinheritance/ConcreteTestLanguage.xtext"), true);
- grammar = (Grammar) resource.getContents().get(0);
- }
-
- @Override
- protected void tearDown() throws Exception {
- grammar = null;
- super.tearDown();
- }
-
- public void testSetup() {
- assertNotNull(grammar);
- }
-
- public void testScope_01() {
- ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(grammar, "AbstractCallOverridenParserRule");
- assertNotNull(rule);
- Group group = (Group) rule.getAlternatives();
- Assignment ass = (Assignment) group.getTokens().get(1);
- assertNotNull(ass);
- RuleCall call = (RuleCall) ass.getTerminal();
- AbstractRule calledRule = call.getRule();
- assertNotNull(calledRule);
- String text = getLinkingService().getLinkText(grammar, calledRule, XtextPackage.Literals.RULE_CALL__RULE, call);
- assertNotNull(text);
- assertEquals(calledRule.getName(), text);
- }
-}
diff --git a/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.ext b/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.ext
index 8af73d4..35815ff 100644
--- a/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.ext
+++ b/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.ext
@@ -4,10 +4,10 @@ import org::eclipse::xtext::xtend::scoping;
extension org::eclipse::xtext::xtend::scoping::ScopeProvider;
-create Scope scope_EClass(EPackage rootModel, EPackage pack, EReference ref) :
+create Scope scope_EClass(EPackage pack, EReference ref) :
setElements(pack.EClassifiers.typeSelect(EClass).scopedElement()) ->
setOuterScope(IScope::NULLSCOPE);
-create Scope scope_EClass(EPackage rootModel, EClass class, EReference ref) :
+create Scope scope_EClass(EClass class, EReference ref) :
setElements({class.scopedElement()}) ->
setOuterScope(IScope::NULLSCOPE);
diff --git a/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.java b/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.java
index f79694b..eb5ae5f 100644
--- a/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.java
+++ b/tests/org.eclipse.xtext.xtend.tests/src/org/eclipse/xtext/xtend/crossref/XtendScopeProviderTest.java
@@ -33,7 +33,6 @@ import com.google.inject.Provider;
public class XtendScopeProviderTest extends TestCase {
private XtendScopeProvider scopeProvider;
-
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -53,7 +52,7 @@ public class XtendScopeProviderTest extends TestCase {
EcorePackage p = EcorePackage.eINSTANCE;
EReference reference = p.getEClass_EAllSuperTypes();
- IScope scope = scopeProvider.getScope(p, p, reference);
+ IScope scope = scopeProvider.getScope(p, reference);
Iterator<IScopedElement> iterator = scope.getAllContents().iterator();
int i = 0;
while(iterator.hasNext()) {
@@ -68,7 +67,7 @@ public class XtendScopeProviderTest extends TestCase {
public void testSimple2() throws Exception {
EcorePackage p = EcorePackage.eINSTANCE;
EReference reference = p.getEClass_EAllSuperTypes();
- IScope scope = scopeProvider.getScope(p, reference, reference);
+ IScope scope = scopeProvider.getScope(reference, reference);
Iterator<IScopedElement> iterator = scope.getAllContents().iterator();
IScopedElement element = iterator.next();
assertFalse(iterator.hasNext());