How @Inject ParseHelper<> is supposed to work ? [message #902319] |
Fri, 17 August 2012 03:35 |
Cristiano Gavião Messages: 279 Registered: July 2009 |
Senior Member |
|
|
Hi,
I've create a test using only one ParseHelper and it worked. But when I tryed to add two parsers, both points to same class (ParserHelp<Library>). They have different object Id numbers (at debug) but same fileExtension.
In my case Company model is being imported in Library DSL.
I couldn't find where and how ParseHelper is binded.
Could someone explain me?
thanks
class TestComponentTemplateLibraryParsing extends AbstractXtextCommonTest {
@Inject
ParseHelper<Library> parserLibrary
@Inject
ParseHelper<Company> parserOrg
[Updated on: Fri, 17 August 2012 03:50] Report message to a moderator
|
|
|
|
|
|
Re: How @Inject ParseHelper<> is supposed to work ? [message #902394 is a reply to message #902388] |
Fri, 17 August 2012 13:03 |
|
Here is a patched parsehelper
public class ParseHelper2<T extends EObject> extends ParseHelper<T> {
public T parse(InputStream in, URI uriToUse, Map<?, ?> options, ResourceSet resourceSet) {
Resource resource = resourceSet.createResource(uriToUse);
resourceSet.getResources().add(resource);
try {
resource.load(in, options);
final T root = (T) (resource.getContents().isEmpty() ? null : resource.getContents().get(0));
return root;
} catch (IOException e) {
throw new WrappedException(e);
}
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
Re: How @Inject ParseHelper&lt;&gt; is supposed to work ? [message #902432 is a reply to message #902402] |
Fri, 17 August 2012 14:44 |
Cristiano Gavião Messages: 279 Registered: July 2009 |
Senior Member |
|
|
I couldn't make it work with ParseHelper2 too... I mean, I can load the resource of main dsl but not its associated model.
I don't understand. In the workflow I have this:
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
registerGeneratedEPackage = "organization.en.organizationDsl.OrganizationDslPackage"
registerGenModelFile = "platform:/resource/organization.en/src-gen/organization/en/OrganizationDsl.genmodel"
}
At runtime I can refer to the organization models from library editor without problems.
But at test it seems that organization is not being registered. this part of ParseHelp2 do not work because there isn't a resource factory in the registry:
Resource resource = resourceSet.createResource(uriToUse);
So, how can I load both resources using same resourceset?
regards,
Cristiano
[Updated on: Fri, 17 August 2012 14:46] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04580 seconds