/* * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String) */ public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) { IJavaProject project = getProject(); final int tabWidth = CodeFormatterUtil.getTabWidth(project); final int indentWidth = CodeFormatterUtil.getIndentWidth(project); boolean allowTabs = tabWidth <= indentWidth; String indentMode; if (project == null) indentMode = JavaCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); else indentMode = project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true); boolean useSpaces = JavaCore.SPACE.equals(indentMode) || DefaultCodeFormatterConstants.MIXED.equals(indentMode); Assert.isLegal(allowTabs || useSpaces); if (!allowTabs) { char[] spaces = new char[indentWidth]; Arrays.fill(spaces, ' '); return new String[] {new String(spaces), ""}; // $NON-NLS-1$ } else if (!useSpaces) return getIndentPrefixesForTab(tabWidth); else return getIndentPrefixesForSpaces(tabWidth); }
/* * @see SourceViewerConfiguration#getTabWidth(ISourceViewer) */ public int getTabWidth(ISourceViewer sourceViewer) { return CodeFormatterUtil.getTabWidth(getProject()); }