Hi,
I'd like to propose two enhancements for scripts: 1. Support annotating a script with `@TypeChecked`/`@CompileStatic` If an import statement inside a script is annotated in `@TypeChecked`/`@CompileStatic`, statically type-check/compile the script class and any other classes declared in the script file. (On a side note, annotating an explicit script main method with `@CompileStatic` doesn't have any effect as of 2.2.0-beta-1.) 2. Support annotating a script with its base class/delegate If an import statement inside a script is annotated with `@ScriptBaseClass(...)`, use the given value as the base class for the script. Or perhaps even better, if an import statement is annotated with `@DelegatesTo`, compile the script to a `DelegatingScript`. Benefits: * Full IDE support for the API exposed by the script (assuming it's a typed API), without a need for DSL descriptors. * Ability to set base class for (and therefore use `@TypeChecked` and `@CompileStatic` on) scripts which are compiled statically rather than at runtime. These features would come in handy for a DSL that I'm currently working on. Thoughts? Cheers, Peter |
Am 22.08.2013 11:40, schrieb Peter Niederwieser:
[...] > (On a side note, annotating an explicit script main method with > `@CompileStatic` doesn't have any effect as of 2.2.0-beta-1.) since normal methods are working just fine, I can only imagine information loss of some kind somewhere... that would be of course a bug > 2. Support annotating a script with its base class/delegate > > If an import statement inside a script is annotated with > `@ScriptBaseClass(...)`, use the given value as the base class for the > script. Or perhaps even better, if an import statement is annotated with > `@DelegatesTo`, compile the script to a `DelegatingScript`. Benefits: > > * Full IDE support for the API exposed by the script (assuming it's a typed > API), without a need for DSL descriptors. > * Ability to set base class for (and therefore use `@TypeChecked` and > `@CompileStatic` on) scripts which are compiled statically rather than at > runtime. > > These features would come in handy for a DSL that I'm currently working on. > Thoughts? not sure what Cedric has to say here, but I think it is a good idea. bye blackdrag -- Jochen "blackdrag" Theodorou - Groovy Project Tech Lead blog: http://blackdragsview.blogspot.com/ german groovy discussion newsgroup: de.comp.lang.misc For Groovy programming sources visit http://groovy-lang.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
In reply to this post by Peter Niederwieser
Yes please make this happen!! I've searched high and low for why I couldn't apply the @CompileStatic annotation to my script - and finally end up here
http://octodecillion.com/blog/use-type-checked-or-compile-static-for-groovy-scripts/ .. whick again directs to this post, effectively explaining that it is not possible. |
It is possible to use @TypeChecked or @CompileStatic on a script, using
the compiler configuration (see http://groovy.codehaus.org/Advanced+compiler+configuration, "static compilation by default"). Best regards, Le 09/02/2014 13:29, stolsvik a écrit : > Yes please make this happen!! I've searched high and low for why I couldn't > apply the @CompileStatic annotation to my script - and finally end up here > > http://octodecillion.com/blog/use-type-checked-or-compile-static-for-groovy-scripts/ > .. whick again directs to this post, effectively explaining that it is not > possible. > > > > -- > View this message in context: http://groovy.329449.n5.nabble.com/Proposal-Script-enhancements-related-to-TypeChecked-and-CompileStatic-tp5716615p5718391.html > Sent from the groovy - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > -- Cédric Champeau SpringSource - Pivotal http://spring.io/ http://www.gopivotal.com/ http://twitter.com/CedricChampeau --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
Can this be improved so that `@TypeChecked` and `@CompileStatic` can be used on a package or import statement of a script? My concrete use case is being able to use these features in GroovyConsole, without having to wrap the script with a class. (Perhaps script-level `@TypeChecked` and `@CompileStatic` annotations should also propagate to classes defined in the script, but this is less critical.) Cheers, Peter |
Free forum by Nabble | Edit this page |