Java Code Examples for org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_TAB_SIZE

The following examples show how to use org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants#FORMATTER_TAB_SIZE . 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: CodeFormatterUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the current tab width.
 *
 * @param project
 *        The project where the source is used, used for project specific options or
 *        <code>null</code> if the project is unknown and the workspace default should be used
 * @return The tab width
 */
public static int getTabWidth(IJavaProject project) {
	/*
	 * If the tab-char is SPACE, FORMATTER_INDENTATION_SIZE is not used
	 * by the core formatter.
	 * We piggy back the visual tab length setting in that preference in
	 * that case.
	 */
	String key;
	if (JavaCore.SPACE.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
		key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
	else
		key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;

	return getCoreOption(project, key, 4);
}
 
Example 2
Source File: CodeFormatterUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the current indent width.
 *
 * @param project
 *        the project where the source is used or,
 *        <code>null</code> if the project is unknown and the workspace default should be used
 * @return the indent width
 * @since 3.1
 */
public static int getIndentWidth(IJavaProject project) {
	String key;
	if (DefaultCodeFormatterConstants.MIXED.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
		key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
	else
		key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;

	return getCoreOption(project, key, 4);
}