Bug 111270 - [formatter] Code Formater fails due to overlapping edits
Summary: [formatter] Code Formater fails due to overlapping edits
Status: VERIFIED DUPLICATE of bug 102780
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P5 major (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 123518 153261 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-30 18:19 EDT by Rodrigo Kumpera CLA
Modified: 2008-10-27 13:01 EDT (History)
3 users (show)

See Also:


Attachments
Java file that JDT fails to format (1.82 KB, text/plain)
2005-09-30 18:20 EDT, Rodrigo Kumpera CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rodrigo Kumpera CLA 2005-09-30 18:19:08 EDT
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)
Comment 1 Rodrigo Kumpera CLA 2005-09-30 18:20:59 EDT
Created attachment 27735 [details]
Java file that JDT fails to format
Comment 2 Olivier Thomann CLA 2005-10-03 08:49:55 EDT
I am investigating.
Comment 3 Olivier Thomann CLA 2005-10-03 09:57:01 EDT
The problem seems to come from the formatting of the comment. If the formatting
of comment is disabled, it works fine.
Comment 4 Olivier Thomann CLA 2005-10-03 10:03:27 EDT
The absence of closing <pre> tag is confusing the comment formatter.
Comment 5 Rodrigo Kumpera CLA 2005-10-03 10:24:47 EDT
(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.
Comment 6 Olivier Thomann CLA 2005-10-03 10:29:09 EDT
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.
Comment 7 Olivier Thomann CLA 2006-08-13 19:49:45 EDT
*** Bug 153261 has been marked as a duplicate of this bug. ***
Comment 8 Olivier Thomann CLA 2007-02-13 15:44:38 EST
*** Bug 123518 has been marked as a duplicate of this bug. ***
Comment 9 Frederic Fusier CLA 2008-08-18 08:07:06 EDT
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
Comment 10 Frederic Fusier CLA 2008-09-25 06:03:56 EDT
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 ***
Comment 11 Frederic Fusier CLA 2008-10-27 13:01:24 EDT
Verified for 3.4.0 using I20080617-2000.