Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 372297

Summary: [hovering] Aggressive folding hover clipping in AnnotationBarHoverManager
Product: [Eclipse Project] Platform Reporter: Wayne Kearnes <wayne.kearnes>
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, dmeibusch
Version: 4.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Wayne Kearnes CLA 2012-02-22 17:38:46 EST
Build Identifier: Version: 3.6.2 Build id: M20110210-1200

We are developing a plugin that provides folding for an TextEditor subclass. Everything is working quite well apart from the annotation hover which is clipped to restrict the amount of text displayed. I understand that clipping may be necessary so this in itself is not a problem, but the clipping performed by the AnnotationBarHoverManager is too aggressive as it clips to the number of lines of code being displayed with no minimum or regard to the size of the folded text.

The fault here is that the AnnotationBarHoverManager.computeInformation() method uses computNumberOfVisibleLines() (which includes the comment "// Hack to reduce amount of copied code.") to restrict the content during the getHoverInfo() call.  There is no simple way to override this behaviour without replacing or sub-classing several intervening classes to eventually override the computeNumberOfVisibleLines() method in the AnnotationBarHoverManager class. My suggestion would be that the computation of visible lines should have some minimum, or be based on the size of the visible window (the hover could conceivably then overlay the entire editor window).

The following java class demonstrates the problem quite well in the standard Eclipse JDT java editor.
<code>
/*******************************************************************************
 *
 * This comment block is to demonstrate the behaviour of the folding annotation hover
 * when the number of lines in the editor is much less than the number of lines in the
 * folded section.
 *
 * For most folding in the standard eclipse JDT editor you would not notice this as
 * a normal class would have enough code lines to allow for a sensible number of
 * folding annotation hover lines to be displayed.
 *
 * This sample uses the smallest java file I could come up with to demonstrate
 * the folding annotation hover provided by the standard AnnotationBarHoverManager
 * for the folded comment is aggressively clipped. It probably should show a minimum
 * number of lines rather than simply be limited to the number of lines currently
 * visible in the editor.
 *
 * We have a plugin that provides folding for much smaller code files (for a propriety
 * language). Please don't ask why, but these files can have a single code
 * line and a long header block, much the same as this example.
 *
 * As you can see for the JDT comment folding for this file the hover is clipped to
 * a single line, which is the first line of the fold even though the first significant
 * alphanumeric line (displayed as the folded text) may be in the second, third or even
 * later line.
 *
 *******************************************************************************/
public class FoldingAnnotationHoverDemonstration {}
</code>



Reproducible: Always

Steps to Reproduce:
1. Create a class based on the attached java code.
2. Collapse the header comment for the class.
3. Hover over the folding annotation (+) in the ruler.
4. Observer the displayed annotation hover widget is clipped to the first line of the comment.
5. Pressing F2 to focus in the hover results in the full folded text being displayed.
Comment 1 Dani Megert CLA 2012-02-23 05:26:18 EST
There are two issues here:

1) The wrong computation of the clipping size.
2) The enriched hover should get the entire text.

Fixed 1) in master: db449c047ea409b35e73b1cf7094d38610826800
Hope this already helps a bit.
Comment 2 Lars Vogel CLA 2019-11-14 03:28:33 EST
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.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.