Bug 86840 AFE in DefaultJavaFoldingStructureProvider after undoing refactoring
HEAD - take an 1.5 project with junit 3.8.1 - open type TestResult and set caret to the beginning of the file - Refactor > Infer Generic Argument Types, click OK - Refactor > Undo => Log: Error 2005-02-28 16:09:14.434 Exception occurred in listener of Java element change notification org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: first folded line is greater than the caption line at org.eclipse.jface.text.Assert.isTrue(Assert.java:189) at org.eclipse.jdt.internal.ui.text.folding.DefaultJavaFoldingStructureProvider$JavaElementPosition.computeProjectionRegions(DefaultJavaFoldingStructureProvider.java:309) at org.eclipse.jface.text.source.projection.ProjectionViewer.computeCollapsedRegions(ProjectionViewer.java:1115) at org.eclipse.jface.text.source.projection.ProjectionViewer.expand(ProjectionViewer.java:794) at org.eclipse.jface.text.source.projection.ProjectionViewer.processChanges(ProjectionViewer.java:1178) at org.eclipse.jface.text.source.projection.ProjectionViewer.catchupWithProjectionAnnotationModel(ProjectionViewer.java:917) at org.eclipse.jface.text.source.projection.ProjectionViewer.processCatchupRequest(ProjectionViewer.java:818) at org.eclipse.jface.text.source.projection.ProjectionViewer$AnnotationModelListener.processModelChanged(ProjectionViewer.java:110) at org.eclipse.jface.text.source.projection.ProjectionViewer$AnnotationModelListener.modelChanged(ProjectionViewer.java:102) at org.eclipse.jface.text.source.AnnotationModel.fireModelChanged(AnnotationModel.java:452) at org.eclipse.jface.text.source.AnnotationModel$InternalModelListener.modelChanged(AnnotationModel.java:106) at org.eclipse.jface.text.source.AnnotationModel.fireModelChanged(AnnotationModel.java:452) at org.eclipse.jface.text.source.AnnotationModel.fireModelChanged(AnnotationModel.java:418) at org.eclipse.jface.text.source.projection.ProjectionAnnotationModel.modifyAnnotations(ProjectionAnnotationModel.java:150) at org.eclipse.jdt.internal.ui.text.folding.DefaultJavaFoldingStructureProvider.processDelta(DefaultJavaFoldingStructureProvider.java:804) at org.eclipse.jdt.internal.ui.text.folding.DefaultJavaFoldingStructureProvider$ElementChangedListener.elementChanged(DefaultJavaFoldingStructureProvider.java:132) at org.eclipse.jdt.internal.core.DeltaProcessor$2.run(DeltaProcessor.java:1426) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1015) at org.eclipse.core.runtime.Platform.run(Platform.java:757) at org.eclipse.jdt.internal.core.DeltaProcessor.notifyListeners(DeltaProcessor.java:1421) at org.eclipse.jdt.internal.core.DeltaProcessor.firePostChangeDelta(DeltaProcessor.java:1269) at org.eclipse.jdt.internal.core.DeltaProcessor.fire(DeltaProcessor.java:1248) at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:1791) at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:414) at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:285) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:1015) at org.eclipse.core.runtime.Platform.run(Platform.java:757) at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:279) at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:153) at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:177) at org.eclipse.core.internal.resources.Workspace.checkpoint(Workspace.java:240) at org.eclipse.ltk.internal.core.refactoring.UndoManager$3.run(UndoManager.java:276) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1702) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1722) at org.eclipse.ltk.internal.core.refactoring.UndoManager.executeChange(UndoManager.java:310) at org.eclipse.ltk.internal.core.refactoring.UndoManager.performUndo(UndoManager.java:202) at org.eclipse.ltk.ui.refactoring.UndoRefactoringAction$2.run(UndoRefactoringAction.java:84) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:344) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:289) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:447) at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1061) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69) at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1057) at org.eclipse.ltk.internal.ui.refactoring.UndoManagerAction.run(UndoManagerAction.java:143) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:244) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:220) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182) at org.eclipse.ui.internal.commands.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:107) at org.eclipse.core.commands.Command.execute(Command.java:260) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:418) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:698) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:741) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:510) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2(WorkbenchKeyboard.java:453) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:229) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:783) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:841) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:866) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:851) at org.eclipse.swt.widgets.Control.traverse(Control.java:2765) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2606) at org.eclipse.swt.widgets.Composite.translateMnemonic(Composite.java:786) at org.eclipse.swt.widgets.Control.translateMnemonic(Control.java:2624) at org.eclipse.swt.widgets.Display.translateMnemonic(Display.java:3328) at org.eclipse.swt.widgets.Display.filterMessage(Display.java:797) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2537) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1611) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1577) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:292) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:144) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:102) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:228) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:333) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:150) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) at java.lang.reflect.Method.invoke(Method.java:391) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:268) at org.eclipse.core.launcher.Main.basicRun(Main.java:260) at org.eclipse.core.launcher.Main.run(Main.java:887) at org.eclipse.core.launcher.Main.main(Main.java:871)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/folding/DefaultJavaFoldingStructureProvider.java
CommentPosition(int offset, int length) {
			super(offset, length);
		}
		
		/*
		 * @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeFoldingRegions(org.eclipse.jface.text.IDocument)
		 */
		public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
			DocumentCharacterIterator sequence= new DocumentCharacterIterator(document, offset, offset + length);
			
			int prefixEnd= 0;
			int contentStart;
				contentStart= findFirstContent(sequence, prefixEnd);
			
			int firstLine= document.getLineOfOffset(offset + prefixEnd);
			int captionLine= document.getLineOfOffset(offset + contentStart);
			int lastLine= document.getLineOfOffset(offset + length);
			
			Assert.isTrue(firstLine <= captionLine, "first folded line is greater than the caption line"); 
			Assert.isTrue(captionLine <= lastLine, "caption line is greater than the last folded line"); 
			
			IRegion preRegion;
			if (firstLine < captionLine) {