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?