Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 397467 - Javadoc hover/view should linkify package
Summary: Javadoc hover/view should linkify package
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 4.3 M6   Edit
Assignee: Martin Mathew CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-04 12:57 EST by Markus Keller CLA
Modified: 2013-03-12 11:42 EDT (History)
2 users (show)

See Also:
daniel_megert: review+


Attachments
Proposed Fix. (4.22 KB, patch)
2013-02-04 08:33 EST, Martin Mathew CLA
no flags Details | Diff
Updated Patch. (3.67 KB, patch)
2013-02-05 09:40 EST, Martin Mathew CLA
daniel_megert: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2013-01-04 12:57:06 EST
Now that we can show package Javadoc, we should also linkify the package segments in Javadoc headers. We already have links for enclosing method/type of an element, and we should extend this to packages.

Package links should not span the whole qualified package name, but only simple names. E.g. for java.lang.ref.Reference,
- "java" should link to package "java"
- "lang" should link to package "java.lang"
- "ref" should link to package "java.lang.ref"

The advantage of separately linking super packages are that
- super packages become accessible
- the browser widget still allows the user to select only parts of a package (if the whole qualified name is a single link, then you cannot select "java.lang" any more)
Comment 1 Martin Mathew CLA 2013-02-04 08:33:42 EST
Created attachment 226502 [details]
Proposed Fix.

Package name present in Javadoc hover and view header is now linked. User can now select individual package names and see the Javadoc if any provided for it. Enabled for PackageFragment and PackageDeclaration.
Comment 2 Dani Megert CLA 2013-02-04 11:10:06 EST
(In reply to comment #1)
> Created attachment 226502 [details] [diff]
> Proposed Fix.
> 
> Package name present in Javadoc hover and view header is now linked.
> User
> can now select individual package names and see the Javadoc if any provided
> for it. Enabled for PackageFragment and PackageDeclaration.

This seems to work as desired.

For now, I only quickly looked at the patch since I do not understand why there are changes in 'JavaElementLabelComposer'. If the idea was to use #getElementName, then I do not understand why you only made that refactoring at two places, and also not why it needs to be part of the fix for this bug.
Comment 3 Martin Mathew CLA 2013-02-05 00:04:38 EST
(In reply to comment #2)

> This seems to work as desired.
> 
> For now, I only quickly looked at the patch since I do not understand why
> there are changes in 'JavaElementLabelComposer'. If the idea was to use
> #getElementName, then I do not understand why you only made that refactoring
> at two places, and also not why it needs to be part of the fix for this bug.

JavaElementLinks has a class "JavaElementLinkedLabelComposer" which  extends "JavaElementLabelComposer". JavaElementLabelComposer serves as a label provider for many ui components. getElementName() method is overridden, so depending on who invokes, either the simple name of the element or the  resolved link is returned. For other element types like methods, fields etc this is already taken care off, hence i had to modify only in 2 places to take care of the PackageFragment and the PackageDeclaration.
Comment 4 Dani Megert CLA 2013-02-05 07:22:27 EST
The patch is OK, but can be improved a bit:

- I don't think #getLastSegmentName is needed since the result is always
  individualSegmentNames[i], no?

- individualSegmentNames[i] could be extracted to a local variable

- "linkIndividualPackageFragmentSegments" should be renamed since the other
  #getElementName method also creates the links
  ==> "getPackageFragmentElementName"  or "getPackageFragmentName"


Note, that I added a comment to JavaElementLabelComposer.getElementName(IJavaElement), i.e. make sure to pull this change before creating a new patch.
Comment 5 Martin Mathew CLA 2013-02-05 09:40:12 EST
Created attachment 226570 [details]
Updated Patch.

(In reply to comment #4)
> The patch is OK, but can be improved a bit:
> 
> - I don't think #getLastSegmentName is needed since the result is always
>   individualSegmentNames[i], no?
Yes, individualSegmentNames[i] has the last segment name. 

> 
> - individualSegmentNames[i] could be extracted to a local variable
reused individualSegmentNames[i] after extracting to a local variable.

> 
> - "linkIndividualPackageFragmentSegments" should be renamed since the other
>   #getElementName method also creates the links
>   ==> "getPackageFragmentElementName"  or "getPackageFragmentName"
renamed to getPackageFragmentElementName.

> 
> Note, that I added a comment to
> JavaElementLabelComposer.getElementName(IJavaElement), i.e. make sure to
> pull this change before creating a new patch.
modified the Javadoc slightly.
Comment 6 Dani Megert CLA 2013-02-05 11:20:25 EST
(In reply to comment #5)
> Created attachment 226570 [details] [diff]
> Updated Patch.

This patch is not complete: it misses the changes for 'JavaElementLabelComposer'. To avoid another ping-pong, I took the changes from the previous patch. Also, I did not use your change to the Javadoc but made another tweak myself (please review).

Fixed with http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=3ee8f8c961ee91ef640925ef9adc08d3fa1034b9
Comment 7 Dani Megert CLA 2013-02-05 11:20:42 EST
.
Comment 8 Dani Megert CLA 2013-02-05 11:21:16 EST
Comment on attachment 226570 [details]
Updated Patch.

Setting 'iplog+' since I missed to set the author when committing.
Comment 9 Dani Megert CLA 2013-03-12 11:42:41 EDT
Verified in I20130311-2000.