« Return to Thread: Groovy AST not taking?

Re: Groovy AST not taking?

by Robert Fischer :: Rate this Message:

Reply to Author | View in Thread

I'm trying to do this as a Grails plugin.  The standards work just fine.

I think my problem is that I need to compile the transform into a jar that lives in ./lib before I
do the larger project compile.  For this build issue, i've started that conversation on grails-user.

~~ Robert.

Peter Niederwieser wrote:

>
> Robert Fischer wrote:
>> Also, my errors were runtime, not compile-time.
>>
> Since your latest example works for me, there must be something wrong with
> your setup. Therefore let me repeat the question: how to you build and run
> your code? And do the standard transforms (e.g. @Singleton) work for you?
>
>
> Robert Fischer wrote:
>> And what seemed off is that there was validation
>> happening on static calls at compile time -- after all, is it any
>> different if I were to inject log
>> to the class via metaclass mangling?
>>
> Agreed. But before investigating this any further, I'd like to find out why
> your transform doesn't work for you.
>
> Cheers,
> Peter
>
>
> Robert Fischer wrote:
>> Also, my errors were runtime, not compile-time.  And what seemed off is
>> that there was validation
>> happening on static calls at compile time -- after all, is it any
>> different if I were to inject log
>> to the class via metaclass mangling?
>>
>> ~~ Robert.
>>
>> Peter Niederwieser wrote:
>>> What is it that seems off to you? The fact that only global transforms
>>> can
>>> run in phase conversion? There is a good reason for this: It's not
>>> possible
>>> to tell if @WithLog is annotated with @GroovyASTTransformationClass
>>> before
>>> its type has been resolved (which happens in phase semantic analysis).
>>> In general, writing a global transform isn't harder than writing a local
>>> one. Your case is an exception because in phase conversion it's not
>>> completely trivial to correctly identify a @WithLog annotation (which you
>>> would get for free with a local transform). Before you go down this
>>> route, I
>>> suggest to verify my belief that phase semantic analysis, and therefore a
>>> local transform, isn't good enough for your case. The example that didn't
>>> seem to work with your original transform was:
>>>
>>> @WithLog
>>> class Foo {
>>>   def foo() {
>>>     assert log != null // OK
>>>     assert Foo.log != null // compile error
>>>   }
>>> }
>>>
>>> Cheers,
>>> Peter
>>>
>>>
>>> Robert Fischer wrote:
>>>> I haven't run your tests, so I'm not sure what the result is.  Since my
>>>> error was a lack of "log"
>>>> property, it sounds like this conversion problem was the issue.
>>>>
>>>>> No. The reason why I suggested a global transform is that the compiler
>>>>> seems
>>>>> to do some checks for static properties during semantic analysis.
>>>>> Therefore
>>>>> you might need to add 'log' before semantic analysis if you want to
>>>>> support
>>>>> all ways that it could be accessed (qualified, unqualified, from the
>>>>> same
>>>>> class, from other classes, etc.). But only global transforms can be run
>>>>> before semantic analysis (i.e. in phase CONVERSION).
>>>>>
>>>> Ah.  Sucky.  Is this something I should open a JIRA on?  Seems off to
>>>> me.
>>>>
>>>> ~~ Robert Fischer, Smokejumper IT Consulting.
>>>> Enfranchised Mind Blog http://EnfranchisedMind.com/blog
>>>>
>>>> Check out my book, "Grails Persistence with GORM and GSQL"!
>>>> http://www.smokejumperit.com/redirect.html
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>> --
>> ~~ Robert Fischer, Smokejumper IT Consulting.
>> Enfranchised Mind Blog http://EnfranchisedMind.com/blog
>>
>> Check out my book, "Grails Persistence with GORM and GSQL"!
>> http://www.smokejumperit.com/redirect.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>

--
~~ Robert Fischer, Smokejumper IT Consulting.
Enfranchised Mind Blog http://EnfranchisedMind.com/blog

Check out my book, "Grails Persistence with GORM and GSQL"!
http://www.smokejumperit.com/redirect.html

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Groovy AST not taking?