|
|
|
|
|
|
Re: Combining the IJvmModelInferrer with custom code generation [message #758940 is a reply to message #758849] |
Fri, 25 November 2011 11:04 |
|
On 11/24/2011 06:41 PM, Goran wrote:
> Thanks Lorenzo,
>
> That's a great blog post indeed. You described a switch to your custom
glad you enjoyed it :)
> generator instead of the JvmModelGenerator. What was not very clear to
> me is if we could still use the JvmModelInferrer when using the custom
> code generator you described. Do you know if this is possible?
>
well, I still haven't switched to JvmModelInferrer, but I think that
could be possible... actually I had pointed you to my post just for the
part concerning calling XbaseCompiler explicitly: I didn't mean to point
you to the part concerning using a custom code generator :)
> I was able to put the following into the JvmModelInferrer which helped:
>
>
> ..
> return element.toMethod(name, returnType)[
> for(p : element.advice.parameters.parameters) {
> parameters += p.toParameter(p.name, p.parameterType)
> }
> documentation = element.documentation
> final = element.^final
>
> val importManager = new ImportManager(true, getJvmType(aspectFQN))
> val mainMethod = compile(element.advice.body, importManager)
> body = ['''
> «mainMethod»
> System.out.println("Some generated custom statement besides the
> automatically generated statements");
> ''']
> )]
> ...
> def compile(XExpression xExpression, ImportManager importManager) {
> val result = new StringBuilderBasedAppendable(importManager)
> compiler.toJavaStatement(xExpression, result, true)
> result
> }
>
>
> However now I also would like to customize the import statements. I know
> how to do that according to your post however I would like to avoid
> throwing away my JvmModelInferrer xtend class.
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
|
Powered by
FUDForum. Page generated in 0.04175 seconds