Here are some larger examples of DSLDs.
All scripts here are available under an EPL license. You are free to redistribute any of the scripts below, but please include the following header in the file:
This DSLD handles the
@Delegate AST transform through a call to
This shows how
@Singleton is implemented. We need to explicitly use a bind pointcut here since we want to bind to the outermost pointcut.
The code for
@Mixin looks like this:
Although this next example is quite long, it is fairly straight forward. We are just adding lots and lots and lots of methods to the
SwingBuilder class. This script is only partially complete since we don't include documentation for all contributed methods. It might be possible to use
BeanInfo to generate this script automatically.
DSLD Meta Script
Finally, here is the script that defines editing support for DSLDs themselves. A few comments:
- Notice the use of
wormholeto store the declaration of binding names so that they can appear in content assist later.
- We are accessing the
org.codehaus.groovy.eclipse.dsl.script.PointcutFactory, which is a class defined inside of Groovy-Eclipse where all of the pointcuts are registered. Doing this ensures thatthe list of pointcuts available for content assist is always synchronized with what is available in Groovy-Eclipse.
- There is a mock interface
IPointcutthat is defined. It is based on an internal interface of the same name, but in a different package.
IPointcutonly exists in the script so that the
acceptmethod will not be underlined.
- This script is long and complicated, but it shows many of the features available in the DSLD language.