Community
Participate
Working Groups
Java code formated fails for the attached file with the following stacktrace: org.eclipse.text.edits.MalformedTreeException: Overlapping text edits at org.eclipse.text.edits.TextEdit$InsertionComparator.compare(TextEdit.java:118) at java.util.Collections.indexedBinarySearch(Collections.java:313) at java.util.Collections.binarySearch(Collections.java:301) at org.eclipse.text.edits.TextEdit.computeInsertionIndex(TextEdit.java:757) at org.eclipse.text.edits.TextEdit.internalAdd(TextEdit.java:742) at org.eclipse.text.edits.TextEdit.addChild(TextEdit.java:332) at org.eclipse.jdt.internal.formatter.Scribe.getRootEdit(Scribe.java:518) at org.eclipse.jdt.internal.formatter.comment.CommentRegion.format(CommentRegion.java:190) at org.eclipse.jdt.internal.formatter.CodeFormatterVisitor.format(CodeFormatterVisitor.java:856) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.formatComment(DefaultCodeFormatter.java:154) at org.eclipse.jdt.internal.formatter.DefaultCodeFormatter.format(DefaultCodeFormatter.java:127) at org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy.format(CommentFormattingStrategy.java:92) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlave(MultiPassContentFormatter.java:220) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlaves(MultiPassContentFormatter.java:267) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:143) at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:761) at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1472) at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation(JavaSourceViewer.java:177) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:211) at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:122) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:120) at org.eclipse.jface.action.Action.runWithEvent(Action.java:996) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:108) at org.eclipse.core.commands.Command.execute(Command.java:311) at org.eclipse.core.commands.ParameterizedCommand.execute(ParameterizedCommand.java:396) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:459) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:781) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:828) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:550) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:493) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:117) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:917) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:880) at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:876) at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1190) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3135) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3038) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1656) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2711) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)
Created attachment 27735 [details] Java file that JDT fails to format
I am investigating.
The problem seems to come from the formatting of the comment. If the formatting of comment is disabled, it works fine.
The absence of closing <pre> tag is confusing the comment formatter.
(In reply to comment #4) > The absence of closing <pre> tag is confusing the comment formatter. I totally forgot to include my formating options, sorry for that. I'm using then builtin profile Eclipse with 0 lines before atributes. Closing the <pre> tag allowed formating to work again. Thanks.
Ok, but this is only a workaround. The heuristic to determine the "end" of a missing <pre> block is not good. This seems to be related to a fix for bug 57011.
*** Bug 153261 has been marked as a duplicate of this bug. ***
*** Bug 123518 has been marked as a duplicate of this bug. ***
Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA
I can reproduce using 3.3.2 but not using 3.4.0. As it also was not reprodcible using 3.4M7, I guess this issue has been fixed since the new comment formatter has been enabled... *** This bug has been marked as a duplicate of bug 102780 ***
Verified for 3.4.0 using I20080617-2000.