|[Xpand] Using Xpand programmatically [message #638299]
||Wed, 10 November 2010 18:17
| Rafael Angarita
Registered: November 2010
Hello, I exported my Xtext projects as pluging and created a new Java project and added the Xtext Nature, so I can write code using the language I defined. Now, I would like to generate source code using the template I defined in my Xpand project. |
Unfortunally, I have not had much success in finding documenation and tutorials about using Xpand programmatically, so I am working almost only with the information I have found in other posts. Therefore I am a little bit lost.
In my Java project I created a class with the following code:
OutputImpl output = new OutputImpl();
Outlet outlet = new Outlet("xpandOutput");
Outlet outputOutlet = new Outlet("testOutput");
// create an execution context
XpandExecutionContextImpl execCtx = new
org.eclipse.xtend.expression.Resource template =
execCtx = (XpandExecutionContextImpl)(execCtx.cloneWithResource(template));
XpandFacade facade = XpandFacade.create(execCtx);
String templateName = "expSpecification";
List<Object> params = new ArrayList<Object>();
facade.evaluate2(templateName, targetObject, params);
One of the problems I have is that I am not sure about what the targetObject should be. Also, I don't know in which step I am suppossed to tell Xpand about the file from which the code would be generated.
I would appreciate if someone could help me or show me any tutorial or documentation about this specific proccess.
Thank you very much.
Powered by FUDForum
. Page generated in 0.03664 seconds