MCPcopy Index your code
hub / github.com/apache/groovy / doInvokeMethod

Method doInvokeMethod

src/main/java/groovy/util/BuilderSupport.java:111–196  ·  view source on GitHub ↗

Creates a node for the given method invocation and processes any child closure. @param methodName the original method name @param name the mapped node name @param args the invocation arguments @return the created node, or a replacement from #postNodeCompletion(Object, Object)

(final String methodName, final Object name, final Object args)

Source from the content-addressed store, hash-verified

109 * @return the created node, or a replacement from {@link #postNodeCompletion(Object, Object)}
110 */
111 protected Object doInvokeMethod(final String methodName, final Object name, final Object args) {
112 Object node = null;
113 Closure closure = null;
114 List list = InvokerHelper.asList(args);
115
116 switch (list.size()) {
117 case 0:
118 node = proxyBuilder.createNode(name);
119 break;
120 case 1:
121 {
122 Object object = list.get(0);
123 if (object instanceof Map) {
124 node = proxyBuilder.createNode(name, (Map) object);
125 } else if (object instanceof Closure) {
126 closure = (Closure) object;
127 node = proxyBuilder.createNode(name);
128 } else {
129 node = proxyBuilder.createNode(name, object);
130 }
131 }
132 break;
133 case 2:
134 {
135 Object object1 = list.get(0);
136 Object object2 = list.get(1);
137 if (object1 instanceof Map) {
138 if (object2 instanceof Closure) {
139 closure = (Closure) object2;
140 node = proxyBuilder.createNode(name, (Map) object1);
141 } else {
142 node = proxyBuilder.createNode(name, (Map) object1, object2);
143 }
144 } else {
145 if (object2 instanceof Closure) {
146 closure = (Closure) object2;
147 node = proxyBuilder.createNode(name, object1);
148 } else if (object2 instanceof Map) {
149 node = proxyBuilder.createNode(name, (Map) object2, object1);
150 } else {
151 throw new MissingMethodException(name.toString(), getClass(), list.toArray(), false);
152 }
153 }
154 }
155 break;
156 case 3:
157 {
158 Object arg0 = list.get(0);
159 Object arg1 = list.get(1);
160 Object arg2 = list.get(2);
161 if (arg0 instanceof Map && arg2 instanceof Closure) {
162 closure = (Closure) arg2;
163 node = proxyBuilder.createNode(name, (Map) arg0, arg1);
164 } else if (arg1 instanceof Map && arg2 instanceof Closure) {
165 closure = (Closure) arg2;
166 node = proxyBuilder.createNode(name, (Map) arg1, arg0);
167 } else {
168 throw new MissingMethodException(name.toString(), getClass(), list.toArray(), false);

Callers 1

invokeMethodMethod · 0.95

Calls 14

asListMethod · 0.95
getCurrentMethod · 0.95
setCurrentMethod · 0.95
setClosureDelegateMethod · 0.95
callMethod · 0.95
getClassMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65
toStringMethod · 0.65
setParentMethod · 0.65
createNodeMethod · 0.45
toArrayMethod · 0.45

Tested by

no test coverage detected