### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/BinaryMethod.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java,v retrieving revision 1.66 diff -u -r1.66 BinaryMethod.java --- model/org/eclipse/jdt/internal/core/BinaryMethod.java 10 Nov 2005 15:25:25 -0000 1.66 +++ model/org/eclipse/jdt/internal/core/BinaryMethod.java 10 Nov 2005 15:33:20 -0000 @@ -11,6 +11,8 @@ package org.eclipse.jdt.internal.core; import java.net.URL; +import java.util.ArrayList; +import java.util.StringTokenizer; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; @@ -192,10 +194,44 @@ } } } + IBinaryMethod info = (IBinaryMethod) getElementInfo(); + final int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor())); + if (this.parameterNames == null) { + // try to see if we can retrieve the names from the attached javadoc + if (paramCount != 0) { + String javadoc = this.getAttachedJavadoc(null, "UTF-8"); //$NON-NLS-1$ + if (javadoc != null) { + final int indexOfOpenParen = javadoc.indexOf('('); + if (indexOfOpenParen != -1) { + final int indexOfClosingParen = javadoc.indexOf(')', indexOfOpenParen); + if (indexOfClosingParen != -1) { + final char[] paramsSource = + CharOperation.replace( + javadoc.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(), + " ".toCharArray(), //$NON-NLS-1$ + new char[] {' '}); + final StringTokenizer tokenizer = new StringTokenizer(String.valueOf(paramsSource), ", \n\r"); //$NON-NLS-1$ + int index = 0; + final ArrayList paramNames = new ArrayList(paramCount); + while (tokenizer.hasMoreTokens()) { + final String token = tokenizer.nextToken(); + if ((index & 1) != 0) { + // if odd then this is a parameter name + paramNames.add(token); + } + index++; + } + if (!paramNames.isEmpty()) { + this.parameterNames = new String[paramNames.size()]; + paramNames.toArray(this.parameterNames); + } + } + } + } + } + } // if still no parameter names, produce fake ones if (this.parameterNames == null) { - IBinaryMethod info = (IBinaryMethod) getElementInfo(); - int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor())); this.parameterNames = new String[paramCount]; for (int i = 0; i < paramCount; i++) { this.parameterNames[i] = "arg" + i; //$NON-NLS-1$ Index: model/org/eclipse/jdt/core/IMethod.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IMethod.java,v retrieving revision 1.22 diff -u -r1.22 IMethod.java --- model/org/eclipse/jdt/core/IMethod.java 25 May 2005 16:39:44 -0000 1.22 +++ model/org/eclipse/jdt/core/IMethod.java 10 Nov 2005 15:33:20 -0000 @@ -99,8 +99,8 @@ String getKey(); /** * Returns the names of parameters in this method. - * For binary types, these names are invented as "arg"+i, where i starts at 1 - * (even if source is associated with the binary). + * For binary types, associated source or attached javadoc are used to retrieve the names. + * If none can be retrieve, then these names are invented as "arg"+i, where i starts at 1. * Returns an empty array if this method has no parameters. * *

For example, a method declared as public void foo(String text, int length)