Community
Participate
Working Groups
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)
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.
(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.
(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.
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.
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.
(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 on attachment 226570 [details] Updated Patch. Setting 'iplog+' since I missed to set the author when committing.
Verified in I20130311-2000.