Bug 510395 - Reference private fields in Javadoc ({@link Particle#spinDir})
Summary: Reference private fields in Javadoc ({@link Particle#spinDir})
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7   Edit
Hardware: PC Windows 10
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-12 15:15 EST by Thomas Schmiereck CLA
Modified: 2017-01-24 08:05 EST (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 Thomas Schmiereck CLA 2017-01-12 15:15:45 EST
If I refereces a priavte field from a other class in JavaDoc the Eclipse editor does not find the field.
JavaDoc does this.

Example: 
class A
{
/**
 * {@link Particle#spinDir}
*/
}
class Particle
{
	priavte int spinDir;
}
Comment 1 Andreas Sewe CLA 2017-01-13 03:56:01 EST
(In reply to Thomas Schmiereck from comment #0)
> If I refereces a priavte field from a other class in JavaDoc the Eclipse
> editor does not find the field.
> JavaDoc does this.
> 
> Example: 
> class A
> {
> /**
>  * {@link Particle#spinDir}
> */
> }
> class Particle
> {
> 	priavte int spinDir;
> }

@Thomas: Thank you for your report. This is not an issue with Eclipse Code Recommenders, however, but with the Eclipse Java Development Tools (which Code Recommenders builds upon). I have assigned this bug to the correct project.

@JDT Team: After fixing the typo (priavte) and "attaching" the Javadoc comment to a method, I was able to confirm this problem using the Eclipse SDK 4.7 M4. Navigate > Open Hyperlink doesn't work, but as soon as I change the modifier to something other than private, it works again. Hope this helps.
Comment 2 Noopur Gupta CLA 2017-01-23 05:08:52 EST
ICodeAssist.codeComplete(int offset, CompletionRequestor requestor, IProgressMonitor monitor) does not provide this proposal at JavaCompletionProposalComputer#internalComputeCompletionProposals. 

Moving to JDT/Core.
Comment 3 Jay Arthanareeswaran CLA 2017-01-23 10:03:27 EST
My 'guess' is we don't seem to be ignoring the Javadoc as it is not attached to any program element. Need to check the JLS on where the Javadoc belongs in this particular case.

Interestingly in case of an error in the field being referenced (as in the reported code in comment #0 where private is spelt wrongly), the navigation does work fine. 

This needs more investigation.
Comment 4 Andreas Sewe CLA 2017-01-23 10:16:10 EST
(In reply to Jay Arthanareeswaran from comment #3)
> My 'guess' is we don't seem to be ignoring the Javadoc as it is not attached
> to any program element. Need to check the JLS on where the Javadoc belongs
> in this particular case.

Note that I tried this with a correctly "attached" Javadoc as well (see my comment 2) and still couldn't get Ctrl+click hyperlinking on "spinDir" to work.

Here's the complete compilation unit (a fixed variant of the compilation unit in comment 0):

    public class A {
        /**
         * {@link Particle#spinDir}
         */
        public static void main(String[] args) { }
    }

    class Particle {
        private int spinDir;
    }

Hope this helps.
Comment 5 Jay Arthanareeswaran CLA 2017-01-23 10:49:22 EST
(In reply to Andreas Sewe from comment #4)
> (In reply to Jay Arthanareeswaran from comment #3)
> > My 'guess' is we don't seem to be ignoring the Javadoc as it is not attached
> > to any program element. Need to check the JLS on where the Javadoc belongs
> > in this particular case.
> 
> Note that I tried this with a correctly "attached" Javadoc as well (see my
> comment 2) and still couldn't get Ctrl+click hyperlinking on "spinDir" to
> work.

I see it now, thanks. But this is even more straight forward case of visibility or lack of it of a private field.

When you said Javadoc does it, what did you mean? The generated javadoc does seem to have the referenced field, but not a clickable link.
Comment 6 Andreas Sewe CLA 2017-01-23 10:58:52 EST
(In reply to Jay Arthanareeswaran from comment #5)
> I see it now, thanks. But this is even more straight forward case of
> visibility or lack of it of a private field.
> 
> When you said Javadoc does it, what did you mean? The generated javadoc does
> seem to have the referenced field, but not a clickable link.

I didn't run the standalone Javadoc (I just checked hyperlinking within Eclipse), but I read comment 0 as if Thomas Schmiereck did.

Anyway, I just checks this and the following produces a clickable link in Javadoc:

Compilation unit A.java:

    public class A {
        /**
         * {@link Particle#spinDir}
         */
        public static void main(String[] args) { }
    }

Separate(!) compilation unit Particle.java

    public class Particle {
        private int spinDir;
    }

Javadoc generated using Project > Generate Javadoc...
Comment 7 Noopur Gupta CLA 2017-01-24 08:05:52 EST
(In reply to Noopur Gupta from comment #2)
> ICodeAssist.codeComplete(int offset, CompletionRequestor requestor,
> IProgressMonitor monitor) does not provide this proposal at
> JavaCompletionProposalComputer#internalComputeCompletionProposals. 

Sorry, this code location was for another bug.

Here, ICodeAssist.codeSelect(int offset, int length) returns no result in JavaElementHyperlinkDetector#detectHyperlinks.