GDSL Awesomeness – Setting a global context
Hi,
Sometimes we need to set the context for the GDSL contributor to all the possible files and scripts in the project scope.
This is a rare case scenario, but could be handy on some implementations.
This can be done by two techniques:
- Ignoring all filters passed to the “context” method.
- Setting the “ctype” parameter to “java.lang.Object” class.
It is illustrated as follows:
[java]
//To set the global context
def globalContext = context() // No need to provide any filters.
//Alternate method
def globalContext = context(ctype: "java.lang.Object") // Contribute to Object class
[/java]
Read Further in the “GDSL AWESOMENESS” Series
- GDSL Awesomeness – Introduction to GDSL in IntelliJ Idea
- GDSL Awesomeness – Understanding Context And Contributors in Detail
- GDSL Awesomeness – Defining dynamic property in a class
- GDSL Awesomeness – Defining dynamic method in a class
- GDSL Awesomeness – Adding Hinting for missingMethod implementation
- GDSL Awesomeness – Setting a global context
- GDSL Awesomeness – Delegating Closure Calls
- GDSL Awesomeness – Defining methods in a closure passed to method of particular name
- GDSL Awesomeness – Defining Properties in a closure passed to method of particular name
- GDSL Awesomeness – Contributing to classes which match a path/name pattern
- GDSL Awesomeness – contributing methods with current class return types or parameters
- GDSL Awesomeness – AutoComplete Script for grails-Mail-Plugin “sendMail” closure
- GDSL Awesomeness – Getting Code of a method or Field in GDSL Script
- GDSL Awesomeness – Advanced Example showing domain properties implementation
Hope it helps
Kushal Likhi