Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foo("aa").is {
- bar("bb").is {
- foobar("cc")
- }
- }
- def globalContext = context(scope: scriptScope())
- contributor(globalContext) {
- method name: "foo", type: "A", params: [name:"java.lang.String"]
- }
- def aContext = context(ctype:"A")
- contributor(aContext) {
- method name: "is", type: "A", params: [closure:"groovy.lang.Closure"]
- }
- def bContext = context(ctype:"B")
- contributor(bContext) {
- method name: "is", type: "B", params: [closure:"groovy.lang.Closure"]
- }
- def closureContext = context(scope: closureScope())
- contributor(closureContext, {
- def call = enclosingCall("is")
- if (call) {
- def callingMethod = call.bind()
- if ("A".equals(callingMethod?.returnType?.name)) {
- method name: "bar", type: "B", params:
- [name:"java.lang.String"]
- }
- else if ("B".equals(callingMethod?.returnType?.name)) {
- method name: "foobar", type: "C", params:
- [name:"java.lang.String"]
- }
- }
- })
Add Comment
Please, Sign In to add comment