Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding a cross-reference by qualified name
Adding a cross-reference by qualified name [message #965477] Wed, 31 October 2012 05:06
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
In my grammar I have

'interface' name=ValidID ('extends' super+=[InterfaceDef|QualifiedName] (',' super+=[InterfaceDef|QualifiedName])*)?

and I want to make sure that every interface extends one provided in the standard library.

I can do this in the following way:
   		val interfaceName = intDef.fullyQualifiedName.toString
   		if (!interfaceName.equals("fire.Object")) {
   			val baseFireResource = intDef.eResource.resourceSet.getResource(URI::createPlatformPluginURI("ru.focusmedia.fire.lib/bin/base.fire", true), true)
   			val models = baseFireResource.contents.filter(typeof(Model))
   			for (model : models) {
   				val containedInterfaces = model.definitions.filter(typeof(InterfaceDef))
   				for (containedInterface : containedInterfaces) {
   					if (containedInterface.fullyQualifiedName.toString.equals("fire.Object")) {
   						intDef.^super += containedInterface
   					}
   				}
   			}
   		}

but is seems bad to me: 1) it doesn't work in unit tests because "platform" URIs aren't recognized; 2) baseFireResource.contents.filter(typeof(Model)) is _very_ slow; 3) correct URL probably will change (removing "bin") when the plugins are deployed. What is a better way to do this?
Previous Topic:Cyclic resolution of lazy links Exception
Next Topic:Standalone Xtend2
Goto Forum:
  


Current Time: Wed Jul 30 07:18:23 EDT 2014

Powered by FUDForum. Page generated in 0.02025 seconds