- update jdt.core to v_A54
- prepare for building against 3.6RC2
diff --git a/org.eclipse.jdt.core/META-INF/Bootstrap_MANIFEST.MF b/org.eclipse.jdt.core/META-INF/Bootstrap_MANIFEST.MF
index 832c905..5998965 100644
--- a/org.eclipse.jdt.core/META-INF/Bootstrap_MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/Bootstrap_MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
-Bundle-Version: 3.6.0.v_A53
+Bundle-Version: 3.6.0.v_A54
Bundle-Activator: org.eclipse.jdt.core.JavaCore
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
index 9a98697..dc6ed2d 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties
@@ -1,7 +1,7 @@
#Format: compiler.name = word1 word2 word3
compiler.name = Eclipse Compiler for Java(TM)
#Format: compiler.version = 0.XXX[, other words (don't forget the comma if adding other words)]
-compiler.version = 0.A53, 3.6.0
+compiler.version = 0.A54, 3.6.0
compiler.copyright = Copyright IBM Corp 2000, 2010. All rights reserved.
###{ObjectTeams:
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 0b1c0ac..117cbd0 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -40,6 +40,70 @@
</td>
</tr>
</table>
+<a name="v_A54"></a>
+<hr><h1>
+Eclipse Platform Build Notes<br>
+Java development tools core</h1>
+Eclipse SDK 3.6RC2 - May 20, 2010 - 3.6.0 RC2
+<br>Project org.eclipse.jdt.core v_A54
+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_A54">cvs</a>).
+<h2>What's new in this drop</h2>
+<ul>
+<li>
+Added a new preference to force the formatter to try to keep nested expressions on one line.
+<p>
+This new preference is controlled with the option:</p>
+<code>DefaultCodeFormatterConstants.FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED</code>
+<pre>
+/**
+ * FORMATTER / Option to wrap outer expressions in nested expressions
+ * - option id: "org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested"
+ * - possible values: { TRUE, FALSE }
+ * - default: TRUE
+ *
+ * This option changes the formatter behavior when nested method calls are encountered.
+ * Since 3.6, the formatter tries to wrap outermost method calls first to have a better output.
+ * For example, let's say we are using the Eclipse built-in profile with a max line width=40+space for tab policy.
+ * Then consider the following snippet:
+ *
+ * public class X01 {
+ * void test() {
+ * foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8));
+ * }
+ * }
+ *
+ * With this new strategy, the formatter will wrap the line earlier, between the arguments of the message call
+ * for this example, and then it will allow to keep each nested call on a single line.
+ * Hence, the output will be:
+ *
+ * public class X01 {
+ * void test() {
+ * foo(bar(1, 2, 3, 4),
+ * bar(5, 6, 7, 8));
+ * }
+ * }
+ *
+ * Important notes:
+ * 1. This new behavior is automatically activated (ie. the default value for this preference is {@link #TRUE}).
+ * If the backward compatibility regarding previous versions' formatter behavior (ie. before 3.6 version) is necessary,
+ * then the preference needs to be set to {@link #FALSE} to retrieve the previous formatter behavior.
+ * 2. The new strategy currently only applies to nested method calls, but might be extended to other nested expressions in future versions
+ *
+ * @see #TRUE
+ * @see #FALSE
+ * @since 3.6
+ */
+</pre>
+See bug <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524">313524</a> for more details.
+</li>
+</ul>
+
+<h3>Problem Reports Fixed</h3>
+<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524">313524</a>
+[formatter] Add preference for improved lines wrapping in nested method calls
+<br><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=313109">313109</a>
+@SuppressWarnings on multiple locals is marked unnecessary if any local is never used
+
<a name="v_A53"></a>
<hr><h1>
Eclipse Platform Build Notes<br>
@@ -452,18 +516,18 @@
* For example, in the following snippet, the formatter will be disabled after
* the comment:
* class X {
- * /*
- * * This is a comment with a mix of disabling and enabling tags:
- * * - <b>disable-formatter</b>
- * * - <b>enable-formatter</b>
- * * - <b>disable-formatter</b>
- * * The formatter will stop to format from the beginning of this comment...
- * */
+ * /*
+ * * This is a comment with a mix of disabling and enabling tags:
+ * * - <b>disable-formatter</b>
+ * * - <b>enable-formatter</b>
+ * * - <b>disable-formatter</b>
+ * * The formatter will stop to format from the beginning of this comment...
+ * */
* void foo() {}
* void bar() {}
* }
*
- * 6. The tag cannot include newline character (i.e. '\n') but it can have white spaces.
+ * 6. The tag cannot include newline character (i.e. '\n') but it can have white spaces.
* E.g. "<b>format: off</b>" is a valid disabling tag
* In the future, newlines may be used to support multiple disabling tags.
*
@@ -526,18 +590,18 @@
* the comment:
* // disable-formatter
* class X {
- * /*
- * * This is a comment with a mix of disabling and enabling tags:
- * * - <b>enable-formatter</b>
- * * - <b>disable-formatter</b>
- * * - <b>enable-formatter</b>
- * * The formatter will restart to format after this comment...
- * */
+ * /*
+ * * This is a comment with a mix of disabling and enabling tags:
+ * * - <b>enable-formatter</b>
+ * * - <b>disable-formatter</b>
+ * * - <b>enable-formatter</b>
+ * * The formatter will restart to format after this comment...
+ * */
* void foo() {}
* void bar() {}
* }
*
- * 5. The tag cannot include newline character (i.e. '\n') but it can have white spaces.
+ * 5. The tag cannot include newline character (i.e. '\n') but it can have white spaces.
* E.g. "<b>format: on</b>" is a valid enabling tag
* In the future, newlines may be used to support multiple enabling tags.
*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 09a5a33..1a456cd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -354,7 +354,7 @@
IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
if (tokenIrritants != null
&& !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
- && options.isAnyEnabled(tokenIrritants) // if irritant is effectevely enabled
+ && options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled
&& (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
if (unusedWarningTokenIsWarning) {
int start = value.sourceStart, end = value.sourceEnd;
@@ -578,9 +578,18 @@
System.arraycopy(this.suppressWarningAnnotations, 0,this.suppressWarningAnnotations = new Annotation[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
System.arraycopy(this.suppressWarningScopePositions, 0,this.suppressWarningScopePositions = new long[2*this.suppressWarningsCount], 0, this.suppressWarningsCount);
}
+ final long scopePositions = ((long)scopeStart<<32) + scopeEnd;
+ for (int i = 0, max = this.suppressWarningsCount; i < max; i++) {
+ if (this.suppressWarningAnnotations[i] == annotation
+ && this.suppressWarningScopePositions[i] == scopePositions
+ && this.suppressWarningIrritants[i].hasSameIrritants(irritants)) {
+ // annotation data already recorded
+ return;
+ }
+ }
this.suppressWarningIrritants[this.suppressWarningsCount] = irritants;
this.suppressWarningAnnotations[this.suppressWarningsCount] = annotation;
- this.suppressWarningScopePositions[this.suppressWarningsCount++] = ((long)scopeStart<<32) + scopeEnd;
+ this.suppressWarningScopePositions[this.suppressWarningsCount++] = scopePositions;
}
/*
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
index d88fd49..6e38ee6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IrritantSet.java
@@ -261,6 +261,20 @@
return false;
}
+ /**
+ * Returns true if all of the irritants in the given irritant set are set in receiver
+ * @param irritantSet the given irritant set
+ */
+ public boolean hasSameIrritants(IrritantSet irritantSet) {
+ if (irritantSet == null)
+ return false;
+ for (int i = 0; i < GROUP_MAX; i++) {
+ if (this.bits[i] != irritantSet.bits[i])
+ return false;
+ }
+ return true;
+ }
+
public boolean isSet(int singleGroupIrritants) {
int group = (singleGroupIrritants & GROUP_MASK) >> GROUP_SHIFT;
return (this.bits[group] & singleGroupIrritants) != 0;
diff --git a/org.eclipse.jdt.core/component.xml b/org.eclipse.jdt.core/component.xml
index 9be8f9f..6199452 100644
--- a/org.eclipse.jdt.core/component.xml
+++ b/org.eclipse.jdt.core/component.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
index 4bb1b1b..0167e2c 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
@@ -3500,6 +3500,51 @@
public static final String FORMATTER_WRAP_BEFORE_BINARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.wrap_before_binary_operator"; //$NON-NLS-1$
/**
* <pre>
+ * FORMATTER / Option to wrap outer expressions in nested expressions
+ * - option id: "org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested"
+ * - possible values: { TRUE, FALSE }
+ * - default: TRUE
+ * </pre>
+ * <p>
+ * This option changes the formatter behavior when nested method calls are encountered.
+ * Since 3.6, the formatter tries to wrap outermost method calls first to have a better output.</p>
+ * <p>For example, let's say we are using the Eclipse built-in profile with a max line width=40+space for tab policy.
+ * Then consider the following snippet:</p>
+ * <pre>
+ * public class X01 {
+ * void test() {
+ * foo(bar(1, 2, 3, 4), bar(5, 6, 7, 8));
+ * }
+ * }
+ * </pre>
+ * <p>With this new strategy, the formatter will wrap the line earlier, between the arguments of the message call
+ * for this example, and then it will allow to keep each nested call on a single line.</p>
+ * <p>Hence, the output will be:</p>
+ * <pre>
+ * public class X01 {
+ * void test() {
+ * foo(bar(1, 2, 3, 4),
+ * bar(5, 6, 7, 8));
+ * }
+ * }
+ * </pre>
+ * <p>
+ * </p>
+ * <p><b><u>Important notes</u></b>:</p>
+ * <ol>
+ * <li>This new behavior is automatically activated (ie. the default value for this preference is {@link #TRUE}).
+ * If the backward compatibility regarding previous versions' formatter behavior (ie. before 3.6 version) is necessary,
+ * then the preference needs to be set to {@link #FALSE} to retrieve the previous formatter behavior.</li>
+ * <li>The new strategy currently only applies to nested method calls, but might be extended to other nested expressions in future versions</li>
+ * </ol>
+ *
+ * @see #TRUE
+ * @see #FALSE
+ * @since 3.6
+ */
+ public static final String FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED = JavaCore.PLUGIN_ID + ".formatter.wrap_outer_expressions_when_nested"; //$NON-NLS-1$
+ /**
+ * <pre>
* FORMATTER / The wrapping is done by indenting by one compare to the current indentation.
* </pre>
* @since 3.0
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
index 5bfc1af..d5a9b2d 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
@@ -1523,7 +1523,9 @@
}
startingPositionInCascade = 2;
}
- int tieBreakRule = size-startingPositionInCascade > 2 ? Alignment.R_OUTERMOST : Alignment.R_INNERMOST;
+ int tieBreakRule = this.preferences.wrap_outer_expressions_when_nested && size-startingPositionInCascade > 2
+ ? Alignment.R_OUTERMOST
+ : Alignment.R_INNERMOST;
Alignment cascadingMessageSendAlignment =
this.scribe.createAlignment(
Alignment.CASCADING_MESSAGE_SEND,
@@ -1841,7 +1843,7 @@
Alignment messageAlignment) {
if (messageAlignment != null) {
- if (messageAlignment.canAlign()) {
+ if (!this.preferences.wrap_outer_expressions_when_nested || messageAlignment.canAlign()) {
this.scribe.alignFragment(messageAlignment, 0);
}
this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
index a8950d4..627fa83 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
@@ -335,7 +335,8 @@
public int tab_char;
public boolean use_tabs_only_for_leading_indentations;
public boolean wrap_before_binary_operator;
-
+ public boolean wrap_outer_expressions_when_nested;
+
public int initial_indentation_level;
public String line_separator;
@@ -632,6 +633,7 @@
options.put(DefaultCodeFormatterConstants.FORMATTER_DISABLING_TAG, this.disabling_tag == null ? Util.EMPTY_STRING : new String(this.disabling_tag));
options.put(DefaultCodeFormatterConstants.FORMATTER_ENABLING_TAG, this.enabling_tag == null ? Util.EMPTY_STRING : new String(this.enabling_tag));
options.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, this.use_tags ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED, this.wrap_outer_expressions_when_nested ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
return options;
}
@@ -2016,6 +2018,10 @@
}
}
}
+ final Object wrapWrapOuterExpressionsWhenNestedOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_WRAP_OUTER_EXPRESSIONS_WHEN_NESTED);
+ if (wrapWrapOuterExpressionsWhenNestedOption != null) {
+ this.wrap_outer_expressions_when_nested = DefaultCodeFormatterConstants.TRUE.equals(wrapWrapOuterExpressionsWhenNestedOption);
+ }
}
/**
@@ -2329,12 +2335,13 @@
this.use_tags = false;
this.disabling_tag = DEFAULT_DISABLING_TAG;
this.enabling_tag = DEFAULT_ENABLING_TAG;
+ this.wrap_outer_expressions_when_nested = true;
//{ObjectTeams: new default:
this.scopedKeywords = true;
this.isPureJava = false;
// SH}
}
-
+
public void setEclipseDefaultSettings() {
setJavaConventionsSettings();
this.tab_char = TAB;
@@ -2607,5 +2614,6 @@
this.use_tags = false;
this.disabling_tag = DEFAULT_DISABLING_TAG;
this.enabling_tag = DEFAULT_ENABLING_TAG;
+ this.wrap_outer_expressions_when_nested = true;
}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
index ee72c05..02d2fd1 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
@@ -1267,6 +1267,38 @@
}
public void handleLineTooLong() {
+ if (this.formatter.preferences.wrap_outer_expressions_when_nested) {
+ handleLineTooLongSmartly();
+ return;
+ }
+ // search for closest breakable alignment, using tiebreak rules
+ // look for outermost breakable one
+ int relativeDepth = 0, outerMostDepth = -1;
+ Alignment targetAlignment = this.currentAlignment;
+ while (targetAlignment != null){
+ if (targetAlignment.tieBreakRule == Alignment.R_OUTERMOST && targetAlignment.couldBreak()){
+ outerMostDepth = relativeDepth;
+ }
+ targetAlignment = targetAlignment.enclosing;
+ relativeDepth++;
+ }
+ if (outerMostDepth >= 0) {
+ throw new AlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
+ }
+ // look for innermost breakable one
+ relativeDepth = 0;
+ targetAlignment = this.currentAlignment;
+ while (targetAlignment != null){
+ if (targetAlignment.couldBreak()){
+ throw new AlignmentException(AlignmentException.LINE_TOO_LONG, relativeDepth);
+ }
+ targetAlignment = targetAlignment.enclosing;
+ relativeDepth++;
+ }
+ // did not find any breakable location - proceed
+ }
+
+ private void handleLineTooLongSmartly() {
// search for closest breakable alignment, using tiebreak rules
// look for outermost breakable one
int relativeDepth = 0, outerMostDepth = -1;
diff --git a/org.eclipse.jdt.core/scripts/export-ecj.xml b/org.eclipse.jdt.core/scripts/export-ecj.xml
index 2049fcc..8b27117 100644
--- a/org.eclipse.jdt.core/scripts/export-ecj.xml
+++ b/org.eclipse.jdt.core/scripts/export-ecj.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/export-ejavac.xml b/org.eclipse.jdt.core/scripts/export-ejavac.xml
index 8c7d2ac..22e0ccc 100644
--- a/org.eclipse.jdt.core/scripts/export-ejavac.xml
+++ b/org.eclipse.jdt.core/scripts/export-ejavac.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/export-ejavac2.xml b/org.eclipse.jdt.core/scripts/export-ejavac2.xml
index a5fe20e..52ce9d8 100644
--- a/org.eclipse.jdt.core/scripts/export-ejavac2.xml
+++ b/org.eclipse.jdt.core/scripts/export-ejavac2.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/export-ejavac2_linux.xml b/org.eclipse.jdt.core/scripts/export-ejavac2_linux.xml
index 6d38b19..91f931d 100644
--- a/org.eclipse.jdt.core/scripts/export-ejavac2_linux.xml
+++ b/org.eclipse.jdt.core/scripts/export-ejavac2_linux.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/export-ejavac_linux.xml b/org.eclipse.jdt.core/scripts/export-ejavac_linux.xml
index 7a0cae9..3e2cbbc 100644
--- a/org.eclipse.jdt.core/scripts/export-ejavac_linux.xml
+++ b/org.eclipse.jdt.core/scripts/export-ejavac_linux.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/exportplugin.xml b/org.eclipse.jdt.core/scripts/exportplugin.xml
index 1223454..1821aae 100644
--- a/org.eclipse.jdt.core/scripts/exportplugin.xml
+++ b/org.eclipse.jdt.core/scripts/exportplugin.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/ikvm_script.xml b/org.eclipse.jdt.core/scripts/ikvm_script.xml
index ff090db..922bb32 100644
--- a/org.eclipse.jdt.core/scripts/ikvm_script.xml
+++ b/org.eclipse.jdt.core/scripts/ikvm_script.xml
Binary files differ
diff --git a/org.eclipse.jdt.core/scripts/oldexportplugin.xml b/org.eclipse.jdt.core/scripts/oldexportplugin.xml
index 4b76405..b9fe576 100644
--- a/org.eclipse.jdt.core/scripts/oldexportplugin.xml
+++ b/org.eclipse.jdt.core/scripts/oldexportplugin.xml
Binary files differ