Written on
GContracts 1.2.11 Sneak Peak - Improved IDE Support
GContracts [0] is a "Design-by-Contract" implementation for Groovy. It adds the concept of programming by contract to the Groovy programming language by adding a single JAR file without third-party dependencies to the class-path. Here is a short preview for the upcoming 1.2.11 release. In the very beginning, GContracts was based on a "hidden" feature in Groovy 1.7: closure annotation parameters. As this was kind of a hidden trick, there was only accidental support for this feature in IDEs. This changed with the release of Groovy 1.8, which officially released the feature of closure annotation parameters. Another missing piece besides supporting closure annotation parameters was the possibility to let the IDE know about implicit variables added by GContracts during compile-time. This was especially needed for the @Ensures annotation's result and old variables. With the ongoing support for custom DSLs, I am happy to announce improved support in this area for the Eclipse Groovy/Grails Toolsuite (GGTS) and Intellij 12.1 [1] and upwards.Unresolved Variables EVERYWHERE
As of today, GContracts provides only a small - yet powerful - set of annotations: @Requires, @Ensures and @Invariant @Ensures - the annotation to define postconditions - is a special case. It adds two implicit variables to the closure code block: old and result. result is available in the case the target method is a non-void instance method and resembles the method's return value. old is a map and resembles all parameter and property values before a method call.

