Skip to main content


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 09:06
Alexey Romanov is currently offline Alexey RomanovFriend
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: Fri Apr 19 18:03:32 GMT 2024

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

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

Back to the top