use of org.eclipse.xtext.ui.editor.hyperlinking.IHyperlinkHelper in project n4js by eclipse.
the class N4JSHyperlinkDetector method detectHyperlinks.
/**
* Method copied from super class with only a minor change: call to "readOnly" changed to "tryReadOnly".
*/
@Override
public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region, final boolean canShowMultipleHyperlinks) {
final IDocument xtextDocument = textViewer.getDocument();
if (!(xtextDocument instanceof N4JSDocument)) {
return super.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
}
final IHyperlinkHelper helper = getHelper();
return ((N4JSDocument) xtextDocument).tryReadOnly(new IUnitOfWork<IHyperlink[], XtextResource>() {
@Override
public IHyperlink[] exec(XtextResource resource) throws Exception {
if (resource == null) {
return null;
}
if (helper instanceof ISourceViewerAware && textViewer instanceof ISourceViewer) {
((ISourceViewerAware) helper).setSourceViewer((ISourceViewer) textViewer);
}
return helper.createHyperlinksByOffset(resource, region.getOffset(), canShowMultipleHyperlinks);
}
}, null);
}
Aggregations