Bug 512220 - @link and @see does not link to correct method for methods using variable length arguments.
Summary: @link and @see does not link to correct method for methods using variable len...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-15 07:39 EST by David Glodich CLA
Modified: 2023-06-15 19:01 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Glodich CLA 2017-02-15 07:39:46 EST
In the following sample, the @link and @see annotations will link to the wrong method when following the links from the Javadoc view or from the hover popup.

Generated javadoc for this sample will link to the correct method.

public class SeeTest
{

	/**
	 * Link to string array method: {@link #myMethod(String[], String...)}.
	 * 
	 * @see #myMethod(String[], String...)
	 */
	public SeeTest()
	{
	}

	/**
	 * My method with single String
	 * 
	 * @param param
	 *            a string
	 * @param args
	 *            variable length args
	 */
	public void myMethod(String param, String... args)
	{
	}

	/**
	 * My method with String array.
	 * 
	 * @param params
	 *            string array
	 * @param args
	 *            variable length args
	 */
	public void myMethod(String[] params, String... args)
	{
	}
}
Comment 1 Noopur Gupta CLA 2017-02-15 08:15:17 EST
The issue occurs in 
org.eclipse.jdt.internal.ui.text.javadoc.JavadocContentAccess2.createAST(IJavaElement element, String cuSource) when ASTParser.createAST(IProgressMonitor monitor) is invoked. 

The source set in ASTParser.setSource(char[] source) contains "String..." in the Javadoc but the result from BodyDeclaration.getJavadoc() after calling ASTParser#createAST changes it to "String". 

As a result, the correct method is not found and the first method matching the number of parameters is returned in jdt.ui, which is the reported bug.

Moving to JDT Core to fix the issue from ASTParser#createAST.
Comment 2 Manoj N Palat CLA 2017-02-15 23:57:40 EST
(In reply to Noopur from comment #1)
> 
> The source set in ASTParser.setSource(char[] source) contains "String..." in
> the Javadoc but the result from BodyDeclaration.getJavadoc() after calling
> ASTParser#createAST changes it to "String". 
> 

@Noopur: I see this for BodyDeclaration.getJavadoc()
/** 
 * Link to string array method:  {@link #myMethod(String[],String)}.
 * @see #myMethod(String[],String)
 */

at:
Daemon Thread [Text Viewer Hover Presenter] (Suspended)	
	TypeDeclaration(BodyDeclaration).getJavadoc() line: 171	
	JavadocContentAccess2.getJavadocNode(IJavaElement, String) line: 730	
	JavadocContentAccess2.javadoc2HTML(IMember, IJavaElement, String) line: 759	
	JavadocContentAccess2.getHTMLContentFromSource(IJavaElement) line: 671	
	JavadocContentAccess2.getHTMLContent(IJavaElement, boolean) line: 534	
	JavadocHover.getHoverInfo(IJavaElement[], ITypeRoot, IRegion, JavadocBrowserInformationControlInput) line: 719	
	JavadocHover.internalGetHoverInfo(ITextViewer, IRegion) line: 637	
	JavadocHover.getHoverInfo2(ITextViewer, IRegion) line: 629	
	BestMatchHover.getHoverInfo2(ITextViewer, IRegion, boolean) line: 164	
	BestMatchHover.getHoverInfo2(ITextViewer, IRegion) line: 130	
	JavaEditorTextHoverProxy.getHoverInfo2(ITextViewer, IRegion) line: 86	
	TextViewerHoverManager$4.run() line: 166	

Can you please paste the stack trace where you find String instead of String[]?
Comment 3 Noopur Gupta CLA 2017-02-16 00:01:12 EST
(In reply to Manoj Palat from comment #2)
> (In reply to Noopur from comment #1)
> > 
> > The source set in ASTParser.setSource(char[] source) contains "String..." in
> > the Javadoc but the result from BodyDeclaration.getJavadoc() after calling
> > ASTParser#createAST changes it to "String". 
> > 
> 
> @Noopur: I see this for BodyDeclaration.getJavadoc()
> /** 
>  * Link to string array method:  {@link #myMethod(String[],String)}.
                                                             ^^^^^^
>  * @see #myMethod(String[],String)
                             ^^^^^^ 
>  */

Please check the highlighted type above which is "String" now but was passed as "String...".
Comment 4 Eclipse Genie CLA 2019-06-30 05:12:38 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 David Glodich CLA 2019-07-01 05:34:01 EDT
(In reply to Eclipse Genie from comment #4)
> This bug hasn't had any activity in quite some time. Maybe the problem got
> resolved, was a duplicate of something else, or became less pressing for
> some reason - or maybe it's still relevant but just hasn't been looked at
> yet.
> 
> If you have further information on the current state of the bug, please add
> it. The information can be, for example, that the problem still occurs, that
> you still want the feature, that more information is needed, or that the bug
> is (for whatever reason) no longer relevant.
> 
> --
> The automated Eclipse Genie.

This issue still occurs in 2019-03.
Comment 6 Jay Arthanareeswaran CLA 2019-07-02 12:56:11 EDT
Something I don't understand about the following code in JavaElementLinks#parseURI(URI):

//Shortcut: only check name and parameter count:
methods= type.getMethods();
for (int i= 0; i < methods.length; i++) {
  method= methods[i];
  if (method.getElementName().equals(refMemberName) && method.getNumberOfParameters() == paramSignatures.length)
    return method;
}

Even though the paramSignatures constructed from the hyperlink is [[QString;, QString;], which appears alright to me, we return with the following:

myMethod(String, String ...) 

Noopur, can you confirm if this is not playing a role here?
Comment 7 Eclipse Genie CLA 2021-06-22 15:36:24 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Eclipse Genie CLA 2023-06-15 19:01:49 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.