Bug 85544 [projection] AFE when folding a method after editing multi-line modifiers
I20050215-2300 public class Collapse { @SuppressWarnings("all") //1 @Deprecated() void foo(Integer i) { } } - folding is correct (triangle on line //1, displayed line when folded contains method name) - insert "public " (no quotes) before @SuppressWarnings -> folding is wrong: triangle still on line //1, displayed line when folded is: @Deprecated() ..., which is wrong. The wrong folding persists while the editor is not closed. - save, close, and reopen editor -> folding is correct again - delete "public " and delete line " @Deprecated()" (Ctrl+D) - collapsing the folding now results in this AFE: Error 2005-02-16 21:10:51.421 Assertion failed: caption line is greater than the last folded line org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: caption line is greater than the last folded line at org.eclipse.jface.text.Assert.isTrue(Assert.java:189) at org.eclipse.jface.text.source.projection.ProjectionViewer.computeCollapsedRegions(ProjectionViewer.java:1116) at org.eclipse.jface.text.source.projection.ProjectionViewer.processChanges(ProjectionViewer.java:1198) 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.AnnotationModel.modifyAnnotation(AnnotationModel.java:724) at org.eclipse.jface.text.source.projection.ProjectionAnnotationModel.toggleExpansionState(ProjectionAnnotationModel.java:86) at org.eclipse.jface.text.source.projection.ProjectionRulerColumn.mouseClicked(ProjectionRulerColumn.java:74) at org.eclipse.jface.text.source.AnnotationRulerColumn$3.mouseUp(AnnotationRulerColumn.java:299) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:136) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2908) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2541) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1612) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1578) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:293) 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
List newChanges= new ArrayList();
		
		Iterator deletionIterator= deletions.iterator();
		outer: while (deletionIterator.hasNext()) {
			JavaProjectionAnnotation deleted= (JavaProjectionAnnotation) deletionIterator.next();
			Position deletedPosition= model.getPosition(deleted);
			if (deletedPosition == null)
				continue;
			
			Iterator changesIterator= changes.iterator();
			while (changesIterator.hasNext()) {
				JavaProjectionAnnotation changed= (JavaProjectionAnnotation) changesIterator.next();
				if (deleted.isComment() == changed.isComment()) {
					Position changedPosition= model.getPosition(changed);
					if (changedPosition == null)
						continue;
					
					if (deletedPosition.getOffset() == changedPosition.getOffset()) {
						
						deletedPosition.setLength(changedPosition.getLength());
						deleted.setElement(changed.getElement());
						deleted.setCaptionOffset(changed.getCaptionOffset());
						
						deletionIterator.remove();
						newChanges.add(deleted);
						
						changesIterator.remove();
						newDeletions.add(changed);
						
						continue outer;