use of org.eclipse.xtext.ui.editor.ISourceViewerAware in project xtext-eclipse by eclipse.
the class XtextReconciler method install.
@Override
public void install(ITextViewer textViewer) {
if (!isInstalled) {
this.textViewer = textViewer;
textInputListener = new TextInputListener();
textViewer.addTextInputListener(textInputListener);
handleInputDocumentChanged(null, textViewer.getDocument());
if (textViewer instanceof ISourceViewerExtension4) {
ContentAssistantFacade facade = ((ISourceViewerExtension4) textViewer).getContentAssistantFacade();
if (facade == null) {
shouldInstallCompletionListener = true;
} else {
facade.addCompletionListener(documentListener);
}
if (strategy instanceof ISourceViewerAware) {
((ISourceViewerAware) strategy).setSourceViewer((ISourceViewer) textViewer);
}
}
isInstalled = true;
}
}
use of org.eclipse.xtext.ui.editor.ISourceViewerAware 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