org.eclipse.jface.text.TabsToSpacesConverter Java Examples

The following examples show how to use org.eclipse.jface.text.TabsToSpacesConverter. 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: TypeScriptEditor.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer = getSourceViewer();
	SourceViewerConfiguration config = getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth = config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter = new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider = getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup = (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7) sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example #2
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer= getSourceViewer();
	SourceViewerConfiguration config= getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth= config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider= getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7)sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example #3
Source File: TextUtils.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
public static TabSpacesInfo getTabSpaces(ITextViewer viewer) {
	TabsToSpacesConverter converter = ClassHelper.getFieldValue(viewer, "fTabsToSpacesConverter", TextViewer.class); //$NON-NLS-1$
	if (converter != null) {
		int tabSize = ClassHelper.getFieldValue(converter, "fTabRatio", TabsToSpacesConverter.class); //$NON-NLS-1$
		return new TabSpacesInfo(tabSize, true);
	}
	return new TabSpacesInfo(-1, false);
}
 
Example #4
Source File: FormHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Retrieves the tab to spaces converter
 * @return
 */
public static TabsToSpacesConverter getTabToSpacesConverter()
{
    TabsToSpacesConverter converter = new TabsToSpacesConverter();
    converter.setNumberOfSpacesPerTab(4);
    return converter;
}