Bug 167668 [Viewers] Changing logical structures using the Show Structure As.. menu breaks view
When stopped at a breakpoint and viewing logical structures I used the Show Structure As... menu item to change to a custom structure and variables would disappear leading to the following exception: org.eclipse.core.runtime.AssertionFailedException: null argument: at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:84) at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:72) at org.eclipse.jface.viewers.AbstractTreeViewer.getTreePathFromItem(AbstractTreeViewer.java:2667) at org.eclipse.jface.viewers.TreeViewer.virtualLazyUpdateWidget(TreeViewer.java:937) at org.eclipse.jface.viewers.TreeViewer.access$2(TreeViewer.java:933) at org.eclipse.jface.viewers.TreeViewer$2.handleEvent(TreeViewer.java:325) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1097) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1121) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1106) at org.eclipse.swt.widgets.Tree.checkData(Tree.java:317) at org.eclipse.swt.widgets.Tree.cellDataProc(Tree.java:252) at org.eclipse.swt.widgets.Display.cellDataProc(Display.java:663) at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method) at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:5533) at org.eclipse.swt.widgets.Display.eventProc(Display.java:1154) at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method) at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:1472) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2896) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1945) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1909) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:425) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) 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:585) at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethod(EclipseAppContainer.java:522) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:147) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:104) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:170) 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:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:339) at org.eclipse.core.launcher.Main.basicRun(Main.java:283) at org.eclipse.core.launcher.Main.run(Main.java:984) at org.eclipse.core.launcher.Main.main(Main.java:959) Steps to reproduce: 1. create a custom logical structure MyStruct for type List and simply make it return toArray() 2. debug the following code snippet 3. turn on logical structures 4. expand list[0] and select fName 5. right-click 'list' and use Show Structure As to show as MyStruct...boom Sometimes only the labels disappear for fName and this$0, sometimes the whole item vanishes, and sometimes the item won't disappear until you mouse over it. Code snippet: public static void main(String[] args) { Clazz clzz = new Clazz(); ArrayList<Var> list = new ArrayList<Var>(); list.add(clzz.new Var("one")); list.add(clzz.new Var("two")); list.add(clzz.new Var("three")); list.add(clzz.new Var("four")); list.add(clzz.new Var("five")); //BREAKPOINT for(Var num : list) { System.err.println(num.getName()); } }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
/**
 * A concrete viewer based on an SWT <code>Tree</code> control.
 * <p>
 * This class is not intended to be subclassed outside the viewer framework. It
 * is designed to be instantiated with a pre-existing SWT tree control and
 * configured with a domain-specific content provider, label provider, element
 * filter (optional), and element sorter (optional).
 * </p>
 * <p>
 * Content providers for tree viewers must implement either the
 * {@link ITreeContentProvider} interface, (as of 3.2) the
 * {@link ILazyTreeContentProvider} interface, or (as of 3.3) the
 * {@link ILazyTreePathContentProvider}. If the content provider is an
 * <code>ILazyTreeContentProvider</code> or an
 * <code>ILazyTreePathContentProvider</code>, the underlying Tree must be
 * created using the {@link SWT#VIRTUAL} style bit, and the tree viewer will not
 * support sorting or filtering.
 * </p>
 */
public class TreeViewer extends AbstractTreeViewer {