Package org.eclipse.jface.text.source
Class LineChangeHover
java.lang.Object
org.eclipse.jface.text.source.LineChangeHover
- All Implemented Interfaces:
IInformationProviderExtension2
,IAnnotationHover
,IAnnotationHoverExtension
public class LineChangeHover
extends Object
implements IAnnotationHover, IAnnotationHoverExtension, IInformationProviderExtension2
A hover for line oriented diffs. It determines the text to show as hover for a certain line in the
document.
- Since:
- 3.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the provided information control can interact with the mouse cursor.protected Point
computeLineRange
(ISourceViewer viewer, int line, int min, int max) Computes the block of lines which form a contiguous block of changes coveringline
.protected String
decorateText
(List<? extends ILineDiffInfo> diffInfos, int maxLines) Takes a list ofILineDiffInfo
s and computes a hover of at mostmaxLines
.protected String
formatSource
(String content) Formats the source w/ syntax coloring etc.Returns the hover control creator of this annotation hover.getHoverInfo
(ISourceViewer sourceViewer, int lineNumber) Returns the text which should be presented in the a hover popup window.getHoverInfo
(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) Returns the object which should be presented in the a hover popup window.getHoverLineRange
(ISourceViewer viewer, int lineNumber) Returns the range of lines that include the given line number for which the same hover information is valid.Returns the information control creator of this information provider.protected String
Returns a replacement for the tab character.
-
Constructor Details
-
LineChangeHover
public LineChangeHover()
-
-
Method Details
-
getHoverInfo
Description copied from interface:IAnnotationHover
Returns the text which should be presented in the a hover popup window. This information is requested based on the specified line number.- Specified by:
getHoverInfo
in interfaceIAnnotationHover
- Parameters:
sourceViewer
- the source viewer this hover is registered withlineNumber
- the line number for which information is requested- Returns:
- the requested information or
null
if no such information exists
-
formatSource
Formats the source w/ syntax coloring etc. This implementation replaces tabs with spaces. May be overridden by subclasses.- Parameters:
content
- the hover content- Returns:
content
reformatted
-
getTabReplacement
Returns a replacement for the tab character. The default implementation returns a tabulator character, but subclasses may override to specify a number of spaces.- Returns:
- a whitespace String that will be substituted for the tabulator character
-
decorateText
Takes a list ofILineDiffInfo
s and computes a hover of at mostmaxLines
. Added lines are prefixed with a'+'
, changed lines with'>'
and deleted lines with'-'
.Deleted and added lines can even each other out, so that a number of deleted lines get displayed where - in the current document - the added lines are.
- Parameters:
diffInfos
- aList
ofILineDiffInfo
maxLines
- the maximum number of lines. Note that adding up all annotations might give more than that due to deleted lines.- Returns:
- a
String
suitable for hover display
-
computeLineRange
Computes the block of lines which form a contiguous block of changes coveringline
.- Parameters:
viewer
- the source viewer showingline
- the line which a hover is displayed formin
- the first line inviewer
's document to considermax
- the last line inviewer
's document to consider- Returns:
- the selection in the document displayed in
viewer
containingline
that is covered by the hover information returned by the receiver.
-
getHoverInfo
Description copied from interface:IAnnotationHoverExtension
Returns the object which should be presented in the a hover popup window. The information is requested based on the specified line range.- Specified by:
getHoverInfo
in interfaceIAnnotationHoverExtension
- Parameters:
sourceViewer
- the source viewer this hover is registered withlineRange
- the line range for which information is requestedvisibleLines
- the number of visible lines- Returns:
- the requested information or
null
if no such information exists
-
getHoverLineRange
Description copied from interface:IAnnotationHoverExtension
Returns the range of lines that include the given line number for which the same hover information is valid.- Specified by:
getHoverLineRange
in interfaceIAnnotationHoverExtension
- Parameters:
viewer
- the viewer which the hover is queried forlineNumber
- the line number of the line for which a hover is displayed for- Returns:
- the computed line range or
null
for no range
-
canHandleMouseCursor
public boolean canHandleMouseCursor()Description copied from interface:IAnnotationHoverExtension
Returns whether the provided information control can interact with the mouse cursor. I.e. the hover must implement custom information control management.- Specified by:
canHandleMouseCursor
in interfaceIAnnotationHoverExtension
- Returns:
true
if the mouse cursor can be handled
-
getHoverControlCreator
Description copied from interface:IAnnotationHoverExtension
Returns the hover control creator of this annotation hover.- Specified by:
getHoverControlCreator
in interfaceIAnnotationHoverExtension
- Returns:
- the hover control creator
-
getInformationPresenterControlCreator
Description copied from interface:IInformationProviderExtension2
Returns the information control creator of this information provider.- Specified by:
getInformationPresenterControlCreator
in interfaceIInformationProviderExtension2
- Returns:
- the information control creator or
null
if none is available
-