Unit Test with cross-references to an external emf model [message #1781440] |
Wed, 07 February 2018 06:09  |
Eclipse User |
|
|
|
Hi guys,
I have a similar setup to https://typefox.io/linking-xtext-models-with-other-emf-models. From my language it's possible to refer to elements of an instance of an external emf model.
Reference:
'ref' ref=[ecore::EObject|ID]
This works well!
But I want to do some parsing test without the IDE now.
'''
ref Element1
'''.parse.assertNotNull
So far I build the following class
class MydslWithDependenciesInjectorProvider extends MydslInjectorProvider {
override internalCreateInjector() {
ExternalModelStandaloneSetup.doSetup
return super.internalCreateInjector
}
}
@RunWith(XtextRunner)
@InjectWith(MydslWithDependenciesInjectorProvider)
class ParsingTest {
And the StandaloneSetup of my external model looks like this
class ExternalModelStandaloneSetup implements ISetup {
@Inject
private FileExtensionProvider fileExtensionProvider;
@Inject
private IResourceServiceProvider resourceServiceProvider;
@Inject
private IResourceServiceProvider.Registry registry;
override createInjectorAndDoEMFRegistration() {
val injector = Guice.createInjector(new ExternalmodelRuntimeModule)
injector.injectMembers(this)
for(fileExt: fileExtensionProvider.fileExtensions)
registry.extensionToFactoryMap.put(fileExt, resourceServiceProvider)
// the following implicitly registers the EPackage to the registry
val externalmodelPackage = ExternalmodelPackage.eINSTANCE
return injector
}
def static void doSetup() {
new ExternalModelStandaloneSetup().createInjectorAndDoEMFRegistration()
}
}
But I have no idea how to continue. It would be very nice if someone can give me a small example.
Many thanks!!!
[Updated on: Wed, 07 February 2018 06:11] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25347 seconds