/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * Returns the possibly <code>project</code>-specific core preference * defined under <code>key</code>, or <code>def</code> if the value is * not a integer. * * @param project the project to get the preference from, or * <code>null</code> to get the global preference * @param key the key of the preference * @param def the default value * @return the value of the preference * @since 3.1 */ private static int getCoreOption(IJavaProject project, String key, int def) { try { return Integer.parseInt(getCoreOption(project, key)); } catch (NumberFormatException e) { return def; } }
/** * Returns the possibly <code>project</code>-specific core preference defined under <code>key</code>, * or <code>def</code> if the value is not a integer. * * @param project * the project to get the preference from, * or <code>null</code> to get the global preference * @param key * the key of the preference * @param def * the default value * @return the value of the preference * @since 3.1 */ private static int getCoreOption(IJavaProject project, String key, int def) { try { return Integer.parseInt(getCoreOption(project, key)); } catch (NumberFormatException e) { return def; } }
/** * Returns the possibly <code>project</code>-specific core preference defined under <code>key</code>, * or <code>def</code> if the value is not a integer. * * @param project * the project to get the preference from, * or <code>null</code> to get the global preference * @param key * the key of the preference * @param def * the default value * @return the value of the preference * @since 3.1 */ private static int getCoreOption(IJavaProject project, String key, int def) { try { return Integer.parseInt(getCoreOption(project, key)); } catch (NumberFormatException e) { return def; } }