Bug 59229 AssertionFailed when restoring from local history
smoke for I20040420 1. open SimpleTest.java 2. select all in editor 3. delete 4. save 5. select SimpleTest.java in Package Explorer 6. context menu > Restore From Local Histore... 7. select all elements 8. click Restore ==> nothing restores and Assertion failure (see below) I looks as if restoring CU children always fails. Restoring elements for types works. org.eclipse.jface.util.Assert$AssertionFailedException: Assertion failed: at org.eclipse.jface.util.Assert.isTrue(Assert.java:168) at org.eclipse.jface.util.Assert.isTrue(Assert.java:154) at org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory.getPlaceHolderType(JavaAddElementFromHistory.java:267) at org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory.createASTNode(JavaAddElementFromHistory.java:204) at org.eclipse.jdt.internal.ui.compare.JavaAddElementFromHistory.run(JavaAddElementFromHistory.java:157) at org.eclipse.jdt.internal.ui.compare.JavaHistoryAction.run(JavaHistoryAction.java:361) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:269) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:550) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:502) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:435) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:769) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1437) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1408) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:244) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:280) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) 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.basicRun(Main.java:267) at org.eclipse.core.launcher.Main.run(Main.java:699) at org.eclipse.core.launcher.Main.main(Main.java:683)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/compare/JavaAddElementFromHistory.java
ASTNode n= NodeFinder.perform(root, sourceRange);
			if (n != null) {
				BodyDeclaration parentNode= (BodyDeclaration)ASTNodes.getParent(n, BodyDeclaration.class);
				if (parentNode != null)
					return ((TypeDeclaration)parentNode).bodyDeclarations();
			}
			return null;
		}
			
		return null;
	}
	
	/**
	 * Returns the corresponding place holder type for the given element.
	 * @return a place holder type (see ASTRewrite)
	 */
	private int getPlaceHolderType(ITypedElement element) {
		
		if (element instanceof DocumentRangeNode) {
			JavaNode jn= (JavaNode) element;
			switch (jn.getTypeCode()) {
				
			case JavaNode.CLASS:
			case JavaNode.INTERFACE:
				return ASTNode.TYPE_DECLARATION;
				
			case JavaNode.CONSTRUCTOR:
			case JavaNode.METHOD:
				return ASTNode.METHOD_DECLARATION;