### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: buildnotes_jdt-core.html
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v
retrieving revision 1.7242
diff -u -r1.7242 buildnotes_jdt-core.html
--- buildnotes_jdt-core.html 21 Dec 2009 14:40:13 -0000 1.7242
+++ buildnotes_jdt-core.html 30 Dec 2009 16:08:39 -0000
@@ -48,6 +48,7 @@
Project org.eclipse.jdt.core v_A29
(cvs).
What's new in this drop
+Patch v06 for bug 264112
Problem Reports Fixed
298243
Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java,v
retrieving revision 1.222
diff -u -r1.222 CodeFormatterVisitor.java
--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 7 Dec 2009 18:17:36 -0000 1.222
+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 30 Dec 2009 16:08:43 -0000
@@ -1395,6 +1395,9 @@
this.scribe.enterAlignment(cascadingMessageSendAlignment);
boolean ok = false;
do {
+ if (startingPositionInCascade == 1) {
+ cascadingMessageSendAlignment.startingColumn = this.scribe.column;
+ }
try {
this.scribe.alignFragment(cascadingMessageSendAlignment, 0);
this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
@@ -1468,6 +1471,7 @@
if (numberOfParens > 0) {
manageClosingParenthesizedExpression(currentMessageSend, numberOfParens);
}
+ cascadingMessageSendAlignment.startingColumn = -1;
if (i < size - 1) {
this.scribe.alignFragment(cascadingMessageSendAlignment, i);
this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
@@ -1664,6 +1668,7 @@
if (messageAlignment != null) {
this.scribe.alignFragment(messageAlignment, 0);
this.scribe.printNextToken(TerminalTokens.TokenNameDOT);
+ messageAlignment.startingColumn = -1;
}
TypeReference[] typeArguments = messageSend.typeArguments;
if (typeArguments != null) {
@@ -4086,6 +4091,7 @@
this.scribe.enterAlignment(messageAlignment);
boolean ok = false;
do {
+ messageAlignment.startingColumn = this.scribe.column;
try {
formatMessageSend(messageSend, scope, messageAlignment);
ok = true;
Index: formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java,v
retrieving revision 1.36
diff -u -r1.36 Alignment.java
--- formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 25 Oct 2009 15:59:51 -0000 1.36
+++ formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 30 Dec 2009 16:08:43 -0000
@@ -120,6 +120,7 @@
public static final int R_OUTERMOST = 1;
public static final int R_INNERMOST = 2;
public int tieBreakRule;
+ public int startingColumn = -1;
// alignment effects on a per fragment basis
public static final int NONE = 0;
@@ -351,11 +352,14 @@
}
}
- if (this.fragmentBreaks[this.fragmentIndex] == BREAK) {
- this.scribe.printNewLine();
- }
- if (this.fragmentIndentations[this.fragmentIndex] > 0) {
- this.scribe.indentationLevel = this.fragmentIndentations[this.fragmentIndex];
+ int fragmentIndentation = this.fragmentIndentations[this.fragmentIndex];
+ if (this.startingColumn < 0 || (fragmentIndentation+1) < this.startingColumn) {
+ if (this.fragmentBreaks[this.fragmentIndex] == BREAK) {
+ this.scribe.printNewLine();
+ }
+ if (fragmentIndentation > 0) {
+ this.scribe.indentationLevel = fragmentIndentation;
+ }
}
}
#P org.eclipse.jdt.core.tests.model
Index: src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java,v
retrieving revision 1.15
diff -u -r1.15 FormatterBugsTests.java
--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 21 Dec 2009 14:40:17 -0000 1.15
+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 30 Dec 2009 16:08:47 -0000
@@ -3503,6 +3503,335 @@
}
/**
+ * @bug 264112: [Formatter] Wrap when necessary too aggressive on short qualifiers
+ * @test
+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=264112"
+ */
+// Max line width = 24
+public void testBug264112_w24_S1() {
+ this.formatterPrefs.page_width = 24;
+ String source =
+ "class Sample1 {void foo() {Other.bar( 100,\n" +
+ "200,\n" +
+ "300,\n" +
+ "400,\n" +
+ "500,\n" +
+ "600,\n" +
+ "700,\n" +
+ "800,\n" +
+ "900 );}}\n";
+ formatSource(source,
+ "class Sample1 {\n" +
+ " void foo() {\n" +
+ " Other.bar(100,\n" +
+ " 200,\n" +
+ " 300,\n" +
+ " 400,\n" +
+ " 500,\n" +
+ " 600,\n" +
+ " 700,\n" +
+ " 800,\n" +
+ " 900);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug264112_w24_S2() {
+ this.formatterPrefs.page_width = 24;
+ String source =
+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n";
+ formatSource(source,
+ "class Sample2 {\n" +
+ " int foo(Some a) {\n" +
+ " return a.getFirst();\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Max line width = 25
+public void testBug264112_w25_S1() {
+ this.formatterPrefs.page_width = 25;
+ String source =
+ "class Sample1 {void foo() {Other.bar( 100,\n" +
+ "200,\n" +
+ "300,\n" +
+ "400,\n" +
+ "500,\n" +
+ "600,\n" +
+ "700,\n" +
+ "800,\n" +
+ "900 );}}\n";
+ formatSource(source,
+ "class Sample1 {\n" +
+ " void foo() {\n" +
+ " Other.bar(100,\n" +
+ " 200,\n" +
+ " 300,\n" +
+ " 400,\n" +
+ " 500,\n" +
+ " 600,\n" +
+ " 700,\n" +
+ " 800, 900);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug264112_w25_S2() {
+ this.formatterPrefs.page_width = 25;
+ String source =
+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n";
+ formatSource(source,
+ "class Sample2 {\n" +
+ " int foo(Some a) {\n" +
+ " return a.getFirst();\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+// Max line width = 26
+public void testBug264112_w26_S1() {
+ this.formatterPrefs.page_width = 26;
+ String source =
+ "class Sample1 {void foo() {Other.bar( 100,\n" +
+ "200,\n" +
+ "300,\n" +
+ "400,\n" +
+ "500,\n" +
+ "600,\n" +
+ "700,\n" +
+ "800,\n" +
+ "900 );}}\n";
+ formatSource(source,
+ "class Sample1 {\n" +
+ " void foo() {\n" +
+ " Other.bar(100,\n" +
+ " 200, 300,\n" +
+ " 400, 500,\n" +
+ " 600, 700,\n" +
+ " 800, 900);\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug264112_w26_S2() {
+ this.formatterPrefs.page_width = 26;
+ String source =
+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n";
+ formatSource(source,
+ "class Sample2 {\n" +
+ " int foo(Some a) {\n" +
+ " return a.getFirst();\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+public void testBug264112_wksp1_01() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " public Object foo(Object scope) {\n" +
+ " if (scope != null) {\n" +
+ " if (true) {\n" +
+ " for (int i = 0; i < 10; i++) {\n" +
+ " if (i == 0) {\n" +
+ " } else if (i < 5) {\n" +
+ " } else {\n" +
+ " scope.problemReporter().typeMismatchErrorActualTypeExpectedType(expression, expressionTb, expectedElementsTb);\n" +
+ " return null;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " return null;\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " public Object foo(Object scope) {\n" +
+ " if (scope != null) {\n" +
+ " if (true) {\n" +
+ " for (int i = 0; i < 10; i++) {\n" +
+ " if (i == 0) {\n" +
+ " } else if (i < 5) {\n" +
+ " } else {\n" +
+ " scope.problemReporter()\n" +
+ " .typeMismatchErrorActualTypeExpectedType(\n" +
+ " expression, expressionTb,\n" +
+ " expectedElementsTb);\n" +
+ " return null;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " return null;\n" +
+ " }\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug264112_wksp1_02() {
+ String source =
+ "package wksp1;\n" +
+ "\n" +
+ "public class X02 {\n" +
+ "\n" +
+ " public String toString() {\n" +
+ " StringBuffer buffer = new StringBuffer();\n" +
+ " if (true) {\n" +
+ " buffer.append(\"- possible values: [\"); //$NON-NLS-1$ \n" +
+ " buffer.append(\"]\\n\"); //$NON-NLS-1$ \n" +
+ " buffer.append(\"- curr. val. index: \").append(currentValueIndex).append(\"\\n\"); //$NON-NLS-1$ //$NON-NLS-2$\n" +
+ " }\n" +
+ " buffer.append(\"- description: \").append(description).append(\"\\n\"); //$NON-NLS-1$ //$NON-NLS-2$\n" +
+ " return buffer.toString();\n" +
+ " }\n" +
+ "\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp1;\n" +
+ "\n" +
+ "public class X02 {\n" +
+ "\n" +
+ " public String toString() {\n" +
+ " StringBuffer buffer = new StringBuffer();\n" +
+ " if (true) {\n" +
+ " buffer.append(\"- possible values: [\"); //$NON-NLS-1$ \n" +
+ " buffer.append(\"]\\n\"); //$NON-NLS-1$ \n" +
+ " buffer.append(\"- curr. val. index: \").append(currentValueIndex).append(\"\\n\"); //$NON-NLS-1$ //$NON-NLS-2$\n" +
+ " }\n" +
+ " buffer.append(\"- description: \").append(description).append(\"\\n\"); //$NON-NLS-1$ //$NON-NLS-2$\n" +
+ " return buffer.toString();\n" +
+ " }\n" +
+ "\n" +
+ "}\n"
+ );
+}
+public void testBug264112_wksp2_01() {
+ String source =
+ "package wksp2;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " private static final String PATH_SMOOTH_QUAD_TO = \"SMOOTH\";\n" +
+ " private static final String XML_SPACE = \" \";\n" +
+ " private static final String PATH_CLOSE = \"CLOSE\";\n" +
+ "\n" +
+ " String foo(Point point, Point point_plus1) {\n" +
+ " StringBuffer sb = new StringBuffer();\n" +
+ " while (true) {\n" +
+ " if (point != null) {\n" +
+ " // Following message send was unnecessarily split\n" +
+ " sb.append(PATH_SMOOTH_QUAD_TO)\n" +
+ " .append(String.valueOf(midValue(point.x, point_plus1.x)))\n" +
+ " .append(XML_SPACE)\n" +
+ " .append(String.valueOf(midValue(point.y, point_plus1.y)));\n" +
+ " } else {\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " sb.append(PATH_CLOSE);\n" +
+ "\n" +
+ " return sb.toString();\n" +
+ " }\n" +
+ "\n" +
+ " private int midValue(int x1, int x2) {\n" +
+ " return (x1 + x2) / 2;\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "class Point {\n" +
+ " int x,y;\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp2;\n" +
+ "\n" +
+ "public class X01 {\n" +
+ "\n" +
+ " private static final String PATH_SMOOTH_QUAD_TO = \"SMOOTH\";\n" +
+ " private static final String XML_SPACE = \" \";\n" +
+ " private static final String PATH_CLOSE = \"CLOSE\";\n" +
+ "\n" +
+ " String foo(Point point, Point point_plus1) {\n" +
+ " StringBuffer sb = new StringBuffer();\n" +
+ " while (true) {\n" +
+ " if (point != null) {\n" +
+ " // Following message send was unnecessarily split\n" +
+ " sb.append(PATH_SMOOTH_QUAD_TO)\n" +
+ " .append(\n" +
+ " String.valueOf(midValue(point.x, point_plus1.x)))\n" +
+ " .append(XML_SPACE)\n" +
+ " .append(\n" +
+ " String.valueOf(midValue(point.y, point_plus1.y)));\n" +
+ " } else {\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " sb.append(PATH_CLOSE);\n" +
+ "\n" +
+ " return sb.toString();\n" +
+ " }\n" +
+ "\n" +
+ " private int midValue(int x1, int x2) {\n" +
+ " return (x1 + x2) / 2;\n" +
+ " }\n" +
+ "\n" +
+ "}\n" +
+ "\n" +
+ "class Point {\n" +
+ " int x, y;\n" +
+ "}\n"
+ );
+}
+public void testBug264112_wksp2_02() {
+ String source =
+ "package wksp2;\n" +
+ "\n" +
+ "public class X02 {\n" +
+ " \n" +
+ " void test(X02 indexsc) {\n" +
+ " if (indexsc == null) {\n" +
+ " } else {\n" +
+ "\n" +
+ " indexsc.reopenScan(\n" +
+ " searchRow, // startKeyValue\n" +
+ " ScanController.GE, // startSearchOp\n" +
+ " null, // qualifier\n" +
+ " null, // stopKeyValue\n" +
+ " ScanController.GT // stopSearchOp \n" +
+ " );\n" +
+ " }\n" +
+ " \n" +
+ " }\n" +
+ "}\n";
+ formatSource(source,
+ "package wksp2;\n" +
+ "\n" +
+ "public class X02 {\n" +
+ "\n" +
+ " void test(X02 indexsc) {\n" +
+ " if (indexsc == null) {\n" +
+ " } else {\n" +
+ "\n" +
+ " indexsc.reopenScan(searchRow, // startKeyValue\n" +
+ " ScanController.GE, // startSearchOp\n" +
+ " null, // qualifier\n" +
+ " null, // stopKeyValue\n" +
+ " ScanController.GT // stopSearchOp\n" +
+ " );\n" +
+ " }\n" +
+ "\n" +
+ " }\n" +
+ "}\n"
+ );
+}
+
+/**
* @bug 297225: [formatter] Indentation may be still wrong in certain circumstances after formatting
* @test Verify that comment indentation is correct when there's a mix of tab and spaces in
* existing indentation and all comments formatting is off.
Index: workspace/Formatter/test184/A_out.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test184/A_out.java,v
retrieving revision 1.2
diff -u -r1.2 A_out.java
--- workspace/Formatter/test184/A_out.java 16 Apr 2004 18:15:46 -0000 1.2
+++ workspace/Formatter/test184/A_out.java 30 Dec 2009 16:08:47 -0000
@@ -2,13 +2,11 @@
X(String s) {
}
protected void foo() {
- Main
- .bind(
- "compile.instantTime", //$NON-NLS-1$
- new String[]{
- String.valueOf(this.lineCount),
- String.valueOf(this.time),
- String
- .valueOf(((int) (this.lineCount * 10000.0 / this.time)) / 10.0)});
+ Main.bind(
+ "compile.instantTime", //$NON-NLS-1$
+ new String[]{
+ String.valueOf(this.lineCount),
+ String.valueOf(this.time),
+ String.valueOf(((int) (this.lineCount * 10000.0 / this.time)) / 10.0)});
}
}
\ No newline at end of file
Index: workspace/Formatter/test187/A_out.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/workspace/Formatter/test187/A_out.java,v
retrieving revision 1.4
diff -u -r1.4 A_out.java
--- workspace/Formatter/test187/A_out.java 26 Nov 2003 19:54:48 -0000 1.4
+++ workspace/Formatter/test187/A_out.java 30 Dec 2009 16:08:47 -0000
@@ -240,8 +240,7 @@
.append(_localFilename).append(documentCount)
.append(EXTENTION)).toString();
if (log.isDebugEnabled()) {
- log
- .debug("File already exists. Check to see if we need rename existing file");
+ log.debug("File already exists. Check to see if we need rename existing file");
}
if (documentCount == 1) {
File backupPdfFile = new File(newFilename);