org.eclipse.jface.text.source.ISourceViewerExtension2 Java Examples

The following examples show how to use org.eclipse.jface.text.source.ISourceViewerExtension2. 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: ModulaSpellingHover.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private HoverInfoWithSpellingAnnotation getSpellingHover(ITextViewer textViewer, IRegion hoverRegion) {
    IAnnotationModel model= null;
    if (textViewer instanceof ISourceViewerExtension2) {
        model = ((ISourceViewerExtension2)textViewer).getVisualAnnotationModel();
    } else if (textViewer instanceof SourceViewer) {
        model= ((SourceViewer)textViewer).getAnnotationModel();
    }
    if (model != null) {
        @SuppressWarnings("rawtypes")
        Iterator e= model.getAnnotationIterator();
        while (e.hasNext()) {
            Annotation a= (Annotation) e.next();
            if (a instanceof SpellingAnnotation) {
                Position p= model.getPosition(a);
                if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
                    return new HoverInfoWithSpellingAnnotation((SpellingAnnotation)a, textViewer, p.getOffset());
                }
            }
        }
    }
    return null;
}
 
Example #2
Source File: JavaScriptLightWeightEditor.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
	ISourceViewer sourceViewer = getSourceViewer();
	if (!(sourceViewer instanceof ISourceViewerExtension2)) {
		setPreferenceStore(createCombinedPreferenceStore(input));
		internalDoSetInput(input);
		return;
	}

	// uninstall & unregister preference store listener
	getSourceViewerDecorationSupport(sourceViewer).uninstall();
	((ISourceViewerExtension2) sourceViewer).unconfigure();

	setPreferenceStore(createCombinedPreferenceStore(input));

	// install & register preference store listener
	sourceViewer.configure(getSourceViewerConfiguration());
	getSourceViewerDecorationSupport(sourceViewer).install(getPreferenceStore());

	internalDoSetInput(input);
}
 
Example #3
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
	ISourceViewer sourceViewer= getSourceViewer();
	if (!(sourceViewer instanceof ISourceViewerExtension2)) {
		setPreferenceStore(createCombinedPreferenceStore(input));
		internalDoSetInput(input);
		return;
	}

	// uninstall & unregister preference store listener
	getSourceViewerDecorationSupport(sourceViewer).uninstall();
	((ISourceViewerExtension2)sourceViewer).unconfigure();

	setPreferenceStore(createCombinedPreferenceStore(input));

	// install & register preference store listener
	sourceViewer.configure(getSourceViewerConfiguration());
	getSourceViewerDecorationSupport(sourceViewer).install(getPreferenceStore());

	internalDoSetInput(input);
}
 
Example #4
Source File: CommonAnnotationHover.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private IAnnotationModel getAnnotationModel(ISourceViewer viewer)
{
	if (viewer instanceof ISourceViewerExtension2)
	{
		ISourceViewerExtension2 extension = (ISourceViewerExtension2) viewer;
		return extension.getVisualAnnotationModel();
	}
	return viewer.getAnnotationModel();
}