Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 29719 Details for
Bug 84750
[perf] BinaryMethod.getParameterNames does not follow IMethod API contract
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch for parameter names from attached javadoc
patch_84750.txt (text/plain), 3.67 KB, created by
Olivier Thomann
on 2005-11-10 13:24:13 EST
(
hide
)
Description:
Proposed patch for parameter names from attached javadoc
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2005-11-10 13:24:13 EST
Size:
3.67 KB
patch
obsolete
>### 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 18:23:32 -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 18:23:32 -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 0. > * Returns an empty array if this method has no parameters. > * > * <p>For example, a method declared as <code>public void foo(String text, int length)</code>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 84750
:
29699
| 29719