View | Details | Raw Unified | Return to bug 84750 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/BinaryMethod.java (-2 / +38 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import java.net.URL;
13
import java.net.URL;
14
import java.util.ArrayList;
15
import java.util.StringTokenizer;
14
16
15
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.OperationCanceledException;
18
import org.eclipse.core.runtime.OperationCanceledException;
Lines 192-201 Link Here
192
				}
194
				}
193
			}
195
			}
194
		}
196
		}
197
		IBinaryMethod info = (IBinaryMethod) getElementInfo();
198
		final int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
199
		if (this.parameterNames == null) {
200
			// try to see if we can retrieve the names from the attached javadoc
201
			if (paramCount != 0) {
202
				String javadoc = this.getAttachedJavadoc(null, "UTF-8"); //$NON-NLS-1$
203
				if (javadoc != null) {
204
					final int indexOfOpenParen = javadoc.indexOf('(');
205
					if (indexOfOpenParen != -1) {
206
						final int indexOfClosingParen = javadoc.indexOf(')', indexOfOpenParen);
207
						if (indexOfClosingParen != -1) {
208
							final char[] paramsSource =
209
								CharOperation.replace(
210
									javadoc.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(),
211
									" ".toCharArray(), //$NON-NLS-1$
212
									new char[] {' '});
213
							final StringTokenizer tokenizer = new StringTokenizer(String.valueOf(paramsSource), ", \n\r"); //$NON-NLS-1$
214
							int index = 0;
215
							final ArrayList paramNames = new ArrayList(paramCount);
216
							while (tokenizer.hasMoreTokens()) {
217
								final String token = tokenizer.nextToken();
218
								if ((index & 1) != 0) {
219
									// if odd then this is a parameter name
220
									paramNames.add(token);
221
								}
222
								index++;
223
							}
224
							if (!paramNames.isEmpty()) {
225
								this.parameterNames = new String[paramNames.size()];
226
								paramNames.toArray(this.parameterNames);
227
							}
228
	 					}
229
					}
230
				}
231
			}
232
		}
195
		// if still no parameter names, produce fake ones
233
		// if still no parameter names, produce fake ones
196
		if (this.parameterNames == null) {
234
		if (this.parameterNames == null) {
197
			IBinaryMethod info = (IBinaryMethod) getElementInfo();
198
			int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
199
			this.parameterNames = new String[paramCount];
235
			this.parameterNames = new String[paramCount];
200
			for (int i = 0; i < paramCount; i++) {
236
			for (int i = 0; i < paramCount; i++) {
201
				this.parameterNames[i] = "arg" + i; //$NON-NLS-1$
237
				this.parameterNames[i] = "arg" + i; //$NON-NLS-1$
(-)model/org/eclipse/jdt/core/IMethod.java (-2 / +2 lines)
Lines 99-106 Link Here
99
String getKey();
99
String getKey();
100
/**
100
/**
101
 * Returns the names of parameters in this method.
101
 * Returns the names of parameters in this method.
102
 * For binary types, these names are invented as "arg"+i, where i starts at 1 
102
 * For binary types, associated source or attached javadoc are used to retrieve the names.
103
 * (even if source is associated with the binary).
103
 * If none can be retrieve, then these names are invented as "arg"+i, where i starts at 1.
104
 * Returns an empty array if this method has no parameters.
104
 * Returns an empty array if this method has no parameters.
105
 *
105
 *
106
 * <p>For example, a method declared as <code>public void foo(String text, int length)</code>
106
 * <p>For example, a method declared as <code>public void foo(String text, int length)</code>

Return to bug 84750