org.eclipse.jface.text.ITextHoverExtension2 Java Examples
The following examples show how to use
org.eclipse.jface.text.ITextHoverExtension2.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtendHoverInEditorTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
private void hasHoverOver(final CharSequence it, final String textUnderHover, final Class<? extends BrowserInformationControlInput> expectedPopupType, final String expectedHoverContent) { try { final IFile fileFoo = this.helper.createFile("Foo.xtend", it.toString()); this._syncUtil.waitForBuild(null); final XtextEditor editor = this.helper.openEditor(fileFoo); int _indexOf = it.toString().indexOf(textUnderHover); int _length = textUnderHover.length(); final Region region = new Region(_indexOf, _length); final Object info = ((ITextHoverExtension2) this.hoverer).getHoverInfo2(editor.getInternalSourceViewer(), region); Assert.assertTrue(expectedPopupType.isInstance(info)); final String html = ((BrowserInformationControlInput) info).getHtml(); Assert.assertTrue(html.contains(expectedHoverContent)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #2
Source File: XtextInformationProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public Object getInformation2(ITextViewer textViewer, IRegion subject) { if(hover != null && hover instanceof ITextHoverExtension2){ return ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, subject); } return null; }
Example #3
Source File: XtextInformationProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * Just for compatibility reasons * {@link org.eclipse.jface.text.information.IInformationProvider#getInformation(ITextViewer, IRegion)} */ @Override @Deprecated public String getInformation(ITextViewer textViewer, IRegion subject) { if(hover instanceof ITextHoverExtension2){ Object hoverInfo2 = ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, subject); return hoverInfo2!= null ? hoverInfo2.toString():null; } return null; }
Example #4
Source File: AbstractCompositeHover.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override @SuppressWarnings("deprecation") public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (currentHover != null) { if (currentHover instanceof ITextHoverExtension2) return ((ITextHoverExtension2) currentHover).getHoverInfo2(textViewer, hoverRegion); else { return currentHover.getHoverInfo(textViewer, hoverRegion); } } return null; }
Example #5
Source File: ModulaInformationProvider.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public Object getInformation2(ITextViewer textViewer, IRegion subject) { createHover(textViewer); if (hover instanceof ITextHoverExtension2) { return ((ITextHoverExtension2)hover).getHoverInfo2(textViewer, subject); } return null; }
Example #6
Source File: ModulaEditorTextHover.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { // Overridden from ITextHoverExtension2. We try and return the richest // help available; this // means trying to call getHoverInfo2() on any contributors, and falling // back on getHoverInfo(). lastReturnedHover = null; // Check through the contributed hover providers. for (ITextHover hoverContributer : hoverContributors) { if (hoverContributer instanceof ITextHoverExtension2) { Object hoverInfo = ((ITextHoverExtension2) hoverContributer) .getHoverInfo2(textViewer, hoverRegion); if (hoverInfo != null) { lastReturnedHover = hoverContributer; return hoverInfo; } } else { @SuppressWarnings("deprecation") String hoverText = hoverContributer.getHoverInfo(textViewer, hoverRegion); if (hoverText != null) { lastReturnedHover = hoverContributer; return hoverText; } } } return getModulaDocHover(textViewer, hoverRegion); }
Example #7
Source File: CommonSourceViewerConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (activeTextHover != null) { Object info = null; if (activeTextHover instanceof AbstractCommonTextHover) { AbstractCommonTextHover commonHover = (AbstractCommonTextHover) activeTextHover; commonHover.setEditor(getEditor()); } if (activeTextHover instanceof ITextHoverExtension2) { info = ((ITextHoverExtension2) activeTextHover).getHoverInfo2(textViewer, hoverRegion); } else { info = activeTextHover.getHoverInfo(textViewer, hoverRegion); } if (info != null) { return info; } } String defaultInfo = super.getHoverInfo(textViewer, hoverRegion); if (defaultInfo != null) { // wrap it in a SimpleTextHover so it will look the same as other hovers (i.e. use the theme colors, // etc.) return new SimpleTextHover(defaultInfo, null).getHoverInfo2(textViewer, hoverRegion); } return null; }
Example #8
Source File: CommonSourceViewerConfiguration.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public IRegion getHoverRegion(ITextViewer textViewer, int offset) { activeTextHover = null; List<TextHoverDescriptor> descriptors = getEnabledTextHoverDescriptors(textViewer, offset); for (TextHoverDescriptor descriptor : descriptors) { ITextHover textHover = descriptor.createTextHover(); IRegion region = null; if (textHover != null) { region = textHover.getHoverRegion(textViewer, offset); } if (region != null) { if (descriptors.size() > 1) { if (textHover instanceof ITextHoverExtension2) { if (((ITextHoverExtension2) textHover).getHoverInfo2(textViewer, region) == null) { continue; } } else if (textHover.getHoverInfo(textViewer, region) == null) { continue; } } activeTextHover = textHover; return region; } } return super.getHoverRegion(textViewer, offset); }
Example #9
Source File: BestMatchHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the information which should be presented when a hover or persistent popup is shown * for the specified hover region. * * @param textViewer the viewer on which the hover popup should be shown * @param hoverRegion the text range in the viewer which is used to determine the hover display * information * @param forInformationProvider <code>true</code> iff the hover info is requested by the * information presenter. In this case, the method only considers text hovers for * which a proper IInformationControlCreator is available that can supply focusable * and resizable information controls. * * @return the hover popup display information, or <code>null</code> if none available * * @see ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion) * @since 3.8 */ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion, boolean forInformationProvider) { checkTextHovers(); fBestHover= null; if (fInstantiatedTextHovers == null) return null; for (Iterator<IJavaEditorTextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) { ITextHover hover= iterator.next(); if (hover == null) continue; if (hover instanceof ITextHoverExtension2) { Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion); if (info != null && !(forInformationProvider && getInformationPresenterControlCreator(hover) == null)) { fBestHover= hover; return info; } } else { String s= hover.getHoverInfo(textViewer, hoverRegion); if (s != null && s.trim().length() > 0) { fBestHover= hover; return s; } } } return null; }
Example #10
Source File: JavaEditorTextHoverProxy.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if (ensureHoverCreated()) { if (fHover instanceof ITextHoverExtension2) return ((ITextHoverExtension2) fHover).getHoverInfo2(textViewer, hoverRegion); else return fHover.getHoverInfo(textViewer, hoverRegion); } return null; }
Example #11
Source File: DelegatingDebugTextHover.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public Object getHoverInfo(ISourceBuffer sourceBuffer, IRegion hoverRegion, ITextViewer textViewer) { fDelegate = getDelegate(); if (fDelegate instanceof ITextHoverExtension2) { return ((ITextHoverExtension2) fDelegate).getHoverInfo2(textViewer, hoverRegion); } // fall back to legacy method if (fDelegate != null) { return fDelegate.getHoverInfo(textViewer, hoverRegion); } return null; }
Example #12
Source File: AbstractHoverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected BrowserInformationControlInput hoveringOver(IFile dslFile, IRegion hoverRegion) { XtextEditor editor = openInEditor(dslFile); Object hoverInfo = ((ITextHoverExtension2) eObjectHover).getHoverInfo2(editor.getInternalSourceViewer(), hoverRegion); return (BrowserInformationControlInput) hoverInfo; }
Example #13
Source File: DotHtmlLabelAdaptingTextHover.java From gef with Eclipse Public License 2.0 | 4 votes |
@Override public Object getHoverInfo(EObject eObject, ITextViewer textViewer, IRegion hoverRegion) { if (textViewer == null || hoverRegion == null) { return null; } HtmlOffsetPair html = htmlOffsetPair(hoverRegion.getOffset(), textViewer); if (html == null) { return null; } synchronized (sourceViewer) { try { sourceViewer.setDocument( DotEditorUtils.getDocument(injector, html.code)); } catch (Exception e) { return null; } Object hoverInfo = null; if (hover instanceof DotHtmlLabelSubgrammarEObjectHover && eObject instanceof Attribute) { ((DotHtmlLabelSubgrammarEObjectHover) hover) .setContainingAttribute((Attribute) eObject); } if (hover instanceof ITextHoverExtension2) { hoverInfo = ((ITextHoverExtension2) hover).getHoverInfo2( sourceViewer, new Region(hoverRegion.getOffset() - html.offset, hoverRegion.getLength())); } if (hover instanceof DotHtmlLabelSubgrammarEObjectHover) { lastCreatorProvider = ((DotHtmlLabelSubgrammarEObjectHover) hover) .getLastCreatorProvider(); } return hoverInfo; } }
Example #14
Source File: XtendHoverInEditorTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testHoverOfReferencedElement() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("/**"); _builder.newLine(); _builder.append(" "); _builder.append("* Hello Foo"); _builder.newLine(); _builder.append(" "); _builder.append("*/"); _builder.newLine(); _builder.append("class Foo {}"); _builder.newLine(); final String contentFoo = _builder.toString(); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("class Bar extends Foo {}"); _builder_1.newLine(); final String contentBar = _builder_1.toString(); final IFile fileFoo = this.helper.createFile("Foo.xtend", contentFoo); final IFile fileBar = this.helper.createFile("Bar.xtend", contentBar); this._syncUtil.waitForBuild(null); final XtextEditor editor = this.helper.openEditor(fileBar); ISourceViewer _internalSourceViewer = editor.getInternalSourceViewer(); Region _region = new Region(19, 1); Object _hoverInfo2 = ((ITextHoverExtension2) this.hoverer).getHoverInfo2(((ITextViewer) _internalSourceViewer), _region); final XtextBrowserInformationControlInput info = ((XtextBrowserInformationControlInput) _hoverInfo2); Assert.assertTrue(info.getHtml().contains("Hello Foo")); final XtextEditor fooEditor = this.helper.openEditor(fileFoo); IXtextDocument _document = fooEditor.getDocument(); StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("/**"); _builder_2.newLine(); _builder_2.append(" "); _builder_2.append("* Hello BAZ"); _builder_2.newLine(); _builder_2.append(" "); _builder_2.append("*/"); _builder_2.newLine(); _builder_2.append("class Foo {}"); _builder_2.newLine(); _document.set(_builder_2.toString()); this._syncUtil.waitForReconciler(fooEditor); this._syncUtil.waitForReconciler(editor); ISourceViewer _internalSourceViewer_1 = editor.getInternalSourceViewer(); Region _region_1 = new Region(19, 1); Object _hoverInfo2_1 = ((ITextHoverExtension2) this.hoverer).getHoverInfo2(((ITextViewer) _internalSourceViewer_1), _region_1); final XtextBrowserInformationControlInput info2 = ((XtextBrowserInformationControlInput) _hoverInfo2_1); Assert.assertFalse(info2.getHtml().contains("Hello Foo")); Assert.assertTrue(info2.getHtml().contains("Hello BAZ")); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }