Created
October 3, 2020 17:04
-
-
Save nbhusare/0ddb170b9defd31fc32d16f3339dba18 to your computer and use it in GitHub Desktop.
Scope provider implementation to demonstrate how you can created a nested scope with elements in it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* In the implementation of the scope provider, we create a nested scope, where each scope contains the fields from the given Clazz. | |
**/ | |
override IScope getScope(EObject context, EReference eReference) { | |
if (reference == MyDslPackage.Literals.REF_TO_FIELD_FIELD) { | |
return clazzScope(context.getContainerOfType(Clazz)); | |
} | |
return super.getScope(context, eReference); | |
} | |
private IScope clazzScope(Class clazz) { | |
if (clazz != null) { | |
Scopes.scopeFor(clazz.features.filter(Field), clazzScope(clazz.superType)); | |
} else { | |
return IScope.NULLSCOPE; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment