org.eclipse.xtext.ui.editor.hover
Class AbstractEObjectHover

java.lang.Object
  extended by org.eclipse.xtext.ui.editor.hover.AbstractHover
      extended by org.eclipse.xtext.ui.editor.hover.AbstractEObjectHover
All Implemented Interfaces:
org.eclipse.jface.text.ITextHover, org.eclipse.jface.text.ITextHoverExtension, org.eclipse.jface.text.ITextHoverExtension2, IEObjectHover, ISourceViewerAware
Direct Known Subclasses:
DispatchingEObjectTextHover

public abstract class AbstractEObjectHover
extends AbstractHover
implements IEObjectHover

A hover which determines the EObject at the hover region. Subclasses have to implement getHoverInfo2 (final EObject eObject, final ITextViewer textViewer, final IRegion hoverRegion).

Author:
Christoph Kulla - Initial contribution and API

Field Summary
 
Fields inherited from class org.eclipse.xtext.ui.editor.hover.AbstractHover
sourceViewer
 
Constructor Summary
AbstractEObjectHover()
           
 
Method Summary
abstract  java.lang.Object getHoverInfo(org.eclipse.emf.ecore.EObject eObject, org.eclipse.jface.text.ITextViewer textViewer, org.eclipse.jface.text.IRegion hoverRegion)
           
 java.lang.Object getHoverInfo2(org.eclipse.jface.text.ITextViewer textViewer, org.eclipse.jface.text.IRegion hoverRegion)
          Returns the information which should be presented when a hover popup is shown for the specified hover region.
 org.eclipse.jface.text.IRegion getHoverRegion(org.eclipse.jface.text.ITextViewer textViewer, int offset)
          Returns the text region which should serve as the source of information to compute the hover popup display information.
protected  Pair<org.eclipse.emf.ecore.EObject,org.eclipse.jface.text.IRegion> getXtextElementAt(XtextResource resource, int offset)
          Call this method only from within an IUnitOfWork
protected  Pair<org.eclipse.emf.ecore.EObject,org.eclipse.jface.text.IRegion> getXtextElementAt(XtextResource resource, org.eclipse.jface.text.IRegion hoverRegion)
          Call this method only from within an IUnitOfWork
 
Methods inherited from class org.eclipse.xtext.ui.editor.hover.AbstractHover
getDocument, getHoverControlCreator, getHoverInfo, getLineNumber, setSourceViewer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEObjectHover

public AbstractEObjectHover()
Method Detail

getHoverRegion

public org.eclipse.jface.text.IRegion getHoverRegion(org.eclipse.jface.text.ITextViewer textViewer,
                                                     int offset)
Description copied from interface: org.eclipse.jface.text.ITextHover
Returns the text region which should serve as the source of information to compute the hover popup display information. The popup has been requested for the given offset.

For example, if hover information can be provided on a per method basis in a source viewer, the offset should be used to find the enclosing method and the source range of the method should be returned.

Specified by:
getHoverRegion in interface org.eclipse.jface.text.ITextHover
Overrides:
getHoverRegion in class AbstractHover
Parameters:
textViewer - the viewer on which the hover popup should be shown
offset - the offset for which the hover request has been issued
Returns:
the hover region used to compute the hover display information

getHoverInfo2

public java.lang.Object getHoverInfo2(org.eclipse.jface.text.ITextViewer textViewer,
                                      org.eclipse.jface.text.IRegion hoverRegion)
Description copied from interface: org.eclipse.jface.text.ITextHoverExtension2
Returns the information which should be presented when a hover popup is shown for the specified hover region. The hover region has the same semantics as the region returned by ITextHover.getHoverRegion(ITextViewer, int). If the returned information is null, no hover popup will be shown.

Note: Implementers have to ensure that ITextHoverExtension.getHoverControlCreator() returns IInformationControls that implement IInformationControlExtension2 and whose IInformationControlExtension2.setInput(Object) can handle the information objects returned by this method.

Callers should ignore the text returned by ITextHover.getHoverInfo(ITextViewer, IRegion).

Specified by:
getHoverInfo2 in interface org.eclipse.jface.text.ITextHoverExtension2
Parameters:
textViewer - the viewer on which the hover popup should be shown
hoverRegion - the text range in the viewer which is used to determine the hover display information
Returns:
the hover popup display information, or null if none available

getHoverInfo

public abstract java.lang.Object getHoverInfo(org.eclipse.emf.ecore.EObject eObject,
                                              org.eclipse.jface.text.ITextViewer textViewer,
                                              org.eclipse.jface.text.IRegion hoverRegion)
Specified by:
getHoverInfo in interface IEObjectHover

getXtextElementAt

protected Pair<org.eclipse.emf.ecore.EObject,org.eclipse.jface.text.IRegion> getXtextElementAt(XtextResource resource,
                                                                                               org.eclipse.jface.text.IRegion hoverRegion)
Call this method only from within an IUnitOfWork


getXtextElementAt

protected Pair<org.eclipse.emf.ecore.EObject,org.eclipse.jface.text.IRegion> getXtextElementAt(XtextResource resource,
                                                                                               int offset)
Call this method only from within an IUnitOfWork