@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(); } }
@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(); } }
public static TabSpacesInfo getTabSpaces(ITextViewer viewer) { TabsToSpacesConverter converter = ClassHelper.getFieldValue(viewer, "fTabsToSpacesConverter", TextViewer.class); if (converter != null) { int tabSize = ClassHelper.getFieldValue(converter, "fTabRatio", TabsToSpacesConverter.class); return new TabSpacesInfo(tabSize, true); } return new TabSpacesInfo(-1, false); }
/** * Retrieves the tab to spaces converter * @return */ public static TabsToSpacesConverter getTabToSpacesConverter() { TabsToSpacesConverter converter = new TabsToSpacesConverter(); converter.setNumberOfSpacesPerTab(4); return converter; }