### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v retrieving revision 1.219 diff -u -r1.219 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 3 Sep 2010 15:44:26 -0000 1.219 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 24 Oct 2010 13:38:42 -0000 @@ -3784,7 +3784,7 @@ newLineString = this.tempBuffer.toString(); } addReplaceEdit(end+1, this.scanner.getCurrentTokenEndPosition(), newLineString); - textLineStart++; + textLineStart = Util.getLineNumber(this.scanner.currentPosition-1, this.lineEnds, textLineStart, this.maxLines); } } } #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.37 diff -u -r1.37 FormatterBugsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 3 Sep 2010 14:49:22 -0000 1.37 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 24 Oct 2010 13:38:45 -0000 @@ -7552,4 +7552,56 @@ ); } +/** + * @bug 328240: org.eclipse.text.edits.MalformedTreeException: Overlapping text edits + * @test Ensure that no exception occurs while formatting the given sample + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=328240" + */ +public void testBug328240() { + String source = + "package com.example;\n" + + "\n" + + "public class FormatterError {\n" + + "\n" + + " /**\n" + + " * Create a paragraph element suited to be a header of the report. Headers\n" + + " * are the elements such as \"created by\" on \"created on\" that appear\n" + + " * underneath the title.\n" + + " * \n" + + " * @param reportHeader\n" + + " * a String value that will be the text of\n" + + "\n" + + "* the paragraph.\n" + + " * @return a Paragraph containing the the text passed as the\n" + + " * reportHeader parameter.\n" + + " */\n" + + "\n" + + " public static String createReportHeader(String reportHeader) {\n" + + " return reportHeader;\n" + + " }\n" + + "}\n"; + formatSource(source, + "package com.example;\n" + + "\n" + + "public class FormatterError {\n" + + "\n" + + " /**\n" + + " * Create a paragraph element suited to be a header of the report. Headers\n" + + " * are the elements such as \"created by\" on \"created on\" that appear\n" + + " * underneath the title.\n" + + " * \n" + + " * @param reportHeader\n" + + " * a String value that will be the text of\n" + + " * the paragraph.\n" + + " * @return a Paragraph containing the the text passed as the\n" + + " * reportHeader parameter.\n" + + " */\n" + + "\n" + + " public static String createReportHeader(String reportHeader) {\n" + + " return reportHeader;\n" + + " }\n" + + "}\n" + ); +} + }