Merge branch 'idea90' of git.labs.intellij.net:idea/community into idea90
[fedora-idea.git] / plugins / groovy / resources / standardDsls / newifyTransform.gdsl
blob95c31019c7d2944c9d1ed229cc642eb69454ed47
1 contributor(context()) {
2   // For methods
3   def memb = enclosingMember()
4   // For classes
5   def clazz = enclosingClass()
6   if (memb) {
7     def newifyName = "groovy.lang.Newify"
8     for (a in memb?.getAnnotations(newifyName) + clazz?.getAnnotations(newifyName)) {
9       def refs = a?.findAttributeValue("value")
10       def auto  = a?.findAttributeValue("auto")
11       //For Python-like style
12       if (refs && !place.qualifier) {
13         for (c in refs.asList()) {
14           def targetClass = c.bind()
15           for (cons in (targetClass?.constructors ?: [])) {
16             method name: targetClass.name, params: cons.paramStringVector, type: targetClass.qualName
17           }
18         }
19       }
21       // For Ruby-like style
22       if (!auto || auto.eval()) {
23         for (cons in classType?.getConstructors()) {
24           method name: 'new', isStatic: true, params: cons.paramStringVector, type: classType?.qualName ?: "java.lang.Object"
25         }
26       }
27     }
28   }