Invoking Expand generator from Java [message #484710] |
Tue, 08 September 2009 16:17  |
Eclipse User |
|
|
|
As I develop a generator with Xtext, I'm curious about options to reduce
the resource requirements. One thing that seems expensive in my scenario
is initializing the workflow for each model file. My project has several
thousand model files, so it looks like significant time may go into
initializing the MWE workflow.
Since I'm running the process from a Java application that is already
invoking the parser directly (through XtextResourceSet), I wonder if there
is a reasonable API to invoke the Xpand without starting an MWE Workflow.
What I'm not clear on is how I may provide the the instance with the model
instance that will drive template expansion. I see
org.eclipse.xpand2.XpandFacade, but its JavaDoc is bare and searches don't
yield any apparently useful references.
Thanks for you advice!
John
|
|
|
Re: Invoking Expand generator from Java [message #485227 is a reply to message #484710] |
Thu, 10 September 2009 16:37  |
Eclipse User |
|
|
|
Hi John,
you're on the right track :-)
The XpandFacade can be used like this:
// create an execution context
XpandExecutionContextImpl execCtx = new
XpandExecutionContextImpl(output, null);
execCtx.setFileEncoding("iso-8859-1"); //$NON-NLS-1$
execCtx.registerMetaModel(new JavaBeansMetaModel());
// create a facade
XpandFacade facade = XpandFacade.create(execCtx);
// invoke a template definition
facade.evaluate("foo:bar::MyTemplate::definition", myObject);
Hope that helps.
Cheers,
Sven
John schrieb:
> As I develop a generator with Xtext, I'm curious about options to reduce
> the resource requirements. One thing that seems expensive in my
> scenario is initializing the workflow for each model file. My project
> has several thousand model files, so it looks like significant time may
> go into initializing the MWE workflow.
>
> Since I'm running the process from a Java application that is already
> invoking the parser directly (through XtextResourceSet), I wonder if
> there is a reasonable API to invoke the Xpand without starting an MWE
> Workflow. What I'm not clear on is how I may provide the the instance
> with the model instance that will drive template expansion. I see
> org.eclipse.xpand2.XpandFacade, but its JavaDoc is bare and searches
> don't yield any apparently useful references.
>
> Thanks for you advice!
> John
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
Powered by
FUDForum. Page generated in 0.27976 seconds