summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-02 09:06:22 (EDT)
committer sefftinge2009-04-02 09:06:22 (EDT)
commit38e6e74cedbfdea07804354bcfeccaaa0b2eeccb (patch)
tree560173491000f34ba1af5ba2a38b3b8b1b04ccf2
parentb52611c5955b2be740cfb5115e6c96d0b28f80ab (diff)
downloadorg.eclipse.xtext-38e6e74cedbfdea07804354bcfeccaaa0b2eeccb.zip
org.eclipse.xtext-38e6e74cedbfdea07804354bcfeccaaa0b2eeccb.tar.gz
org.eclipse.xtext-38e6e74cedbfdea07804354bcfeccaaa0b2eeccb.tar.bz2
Restored: IScopeProvider.getScope(context, type)
-rwxr-xr-xplugins/org.eclipse.xtext.xtend/src/org/eclipse/xtext/xtend/scoping/XtendScopeProvider.java38
1 files changed, 34 insertions, 4 deletions
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 062a239..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
@@ -8,6 +8,7 @@
package org.eclipse.xtext.xtend.scoping;
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.xtext.crossref.IScope;
@@ -86,18 +87,47 @@ public class XtendScopeProvider extends AbstractXtendService implements IScopePr
}
return null;
}
+
+ 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(context, type));
+ } catch (NoSuchExtensionException e) {
+ // ignore
+ }
+ if (result != null)
+ return (IScope) result;
+ if (context.eContainer() != null) {
+ return getScope(context.eContainer(), type);
+ } else {
+ computeDefaultScope(context, type);
+ }
+ }
+ } catch (Throwable e) {
+ log.error("Error invoking scope extension", e);
+ }
+ return null;
+ }
- /**
- *
- */
protected IScope computeDefaultScope(EObject ctx, EReference reference) {
return this.defaultScopeProvider.getScope(ctx, reference);
}
+
+ protected IScope computeDefaultScope(EObject ctx, EClass type) {
+ return this.defaultScopeProvider.getScope(ctx, type);
+ }
private String extensionName(EObject context, EReference reference) {
- return SCOPE_EXTENSION_PREFIX + reference.getEType().getName();
+ return extensionName(context, reference.getEReferenceType());
}
+ private String extensionName(EObject context, EClass type) {
+ return SCOPE_EXTENSION_PREFIX + type.getName();
+ }
+
@Override
protected String getMasterXtendFileName() {
return extensionFile;