Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Importing implicit global scope
Importing implicit global scope [message #1276706] Mon, 24 March 2014 23:36 Go to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member

I'm wondering if there is a simple pattern to follow when you want to provide an implicit set of referenced files for all editor instances? IOTW, this would act just as if you had the import uris, except that the list wouldn't have to be defined or maintained by the tool user. It seems like this should be pretty simple but I'm getting lost in the sea of IResourceDescriptors and the like when trying to implement it and I'm thinking that I might be making a simple thing too complex...

thanks and cheers,

Re: Importing implicit global scope [message #1287149 is a reply to message #1276706] Mon, 07 April 2014 13:07 Go to previous message
Pawel Pogorzelski is currently offline Pawel PogorzelskiFriend
Messages: 40
Registered: July 2009
working example for supporting both - explicit and implicit imports:

public class LocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {

	protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(final EObject context, boolean ignoreCase) {
		List<ImportNormalizer> resolvers = Lists.newArrayList();

		if (context instanceof Algorithm) {
			Algorithm algorithm = (Algorithm) context;

			// treat namespace declaration as implicit import
			Namespace namespace = algorithm.getNamespace();
			if (namespace != null) {
				String namespaceName = namespace.getName();
				if (namespaceName != null) {
					namespaceName += ".*";
					ImportNormalizer resolver = createImportedNamespaceResolver(namespaceName, ignoreCase);
					if (resolver != null)

			// add explicit imports
			SimpleAttributeResolver<EObject, String> importResolver = SimpleAttributeResolver.newResolver(String.class,
			EList<EObject> eContents = algorithm.eContents();
			for (EObject child : eContents) {
				String value = importResolver.getValue(child);
				ImportNormalizer resolver = createImportedNamespaceResolver(value, ignoreCase);
				if (resolver != null)

		return resolvers;


Corresponding snippet from the grammar file (for the part with explicit imports):
"import" comments+=Comment* importedNamespace=WildCardName;

This might be needed in you Workflow file as well:
fragment = scoping.ImportNamespacesScopingFragment {}

Previous Topic:Cross References to "surrounding" resource
Next Topic:Serialization Issue with Mathematical Expression
Goto Forum:

Current Time: Tue Aug 04 06:21:40 GMT 2020

Powered by FUDForum. Page generated in 0.01902 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top