Community
Participate
Working Groups
Version: 3.1.0 Build id: I20050401-1645 [formatter] Max line width not applied. My max line width is defined as 120. The line below is 126 chars long (4 spaces start the line). public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = getSystemProperty("java.util.prefs.PreferencesFactory"); After formatting the whole file or just that line, the line does not change. The line could broken up as: public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = getSystemProperty("java.util.prefs.PreferencesFactory"); or: public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = getSystemProperty("java.util.prefs.PreferencesFactory"); If it matters, the getSystemProperty method is: private static String getSystemProperty(String property) { try { return System.getProperty(property); } catch (SecurityException ex) { // we are not allowed to look at this property System.err.println( "Caught a SecurityException reading the system property '" + property + "'; the SystemUtils property value will default to null." ); return null; } }
The following is not broken up either at length 120: public static String toString(Object object, ToStringStyle style, boolean outputTransients, Class reflectUpToClass) { return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients).toString(); } The first line above is 122 long.
The same 120 limit is not applied to: /** * <p> * Returns whether the named charset is supported. * </p> * <p> * This is similar to <a * href="http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html#isSupported(java.lang.String)">java.nio.charset.Charset.isSupported(String)</a> * </p> * * @param name * the name of the requested charset; may be either a canonical name or an alias * @return <code>true</code> if, and only if, support for the named charset is available in the current Java * virtual machine * * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc">JRE character * encoding names</a> */ Note that the @see properly breaks the line appart in the <a>.
re comment 2: please note that comment formatting and normal formatting have different preferences and are different formatters (Java / Javadoc). I consider this bug for the Java formatter. Please file a separate bug report if you see the problem reported in comment 2 after confirming that you've set the comment formatter line length preference.
Check, I have max line width set to 120 for both tabs "Line Wrapping" and "Comments".
Created "https://bugs.eclipse.org/bugs/show_bug.cgi?id=93459" for Javadoc issue.
I also encountered this problem: if((pMetricsData.getMetricsData().length < 22) || (pMetricsData.getMetricsData()[0].length < 2)) { is 102 characters long. It doesn't get wrapped when "Maximum line width" is set to 100. This is rather annoying, because the code gets "QAed" with Checkstyle, which always reports that the line is too long once I use the code formatting. :-( I', using Eclipse 3.1M7 on WindowsXP.
Problem in comment 0 is a dup of bug 71766. Problem in comment 6 is a dup of bug 90238. With fix for bug 71766, it would be split as: public static final String JAVA_UTIL_PREFS_PREFERENCES_FACTORY = getSystemProperty("java.util.prefs.PreferencesFactory"); *** This bug has been marked as a duplicate of 71766 ***