daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. foo("aa").is {
  2.     bar("bb").is {
  3.         foobar("cc")
  4.     }
  5. }
  6.    
  7. def globalContext = context(scope: scriptScope())
  8. contributor(globalContext) {
  9. method name: "foo", type: "A",  params: [name:"java.lang.String"]
  10. }
  11.  
  12. def aContext = context(ctype:"A")
  13. contributor(aContext) {
  14.     method name: "is", type: "A", params: [closure:"groovy.lang.Closure"]
  15. }
  16.  
  17. def bContext = context(ctype:"B")
  18. contributor(bContext) {
  19.     method name: "is", type: "B", params: [closure:"groovy.lang.Closure"]
  20. }
  21.  
  22.  
  23. def closureContext = context(scope: closureScope())
  24.  
  25. contributor(closureContext, {
  26.     def call = enclosingCall("is")
  27.     if (call) {
  28.         def callingMethod = call.bind()
  29.         if ("A".equals(callingMethod?.returnType?.name)) {
  30.             method name: "bar", type: "B",  params:
  31. [name:"java.lang.String"]
  32.         }
  33.         else if ("B".equals(callingMethod?.returnType?.name)) {
  34.             method name: "foobar", type: "C",  params:
  35. [name:"java.lang.String"]
  36.         }
  37.  
  38.     }
  39.  
  40. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top