diff --git a/org.eclipse.jdt.ui/.settings/.api_filters b/org.eclipse.jdt.ui/.settings/.api_filters index b181190c4ad..ab29fec0ba9 100644 --- a/org.eclipse.jdt.ui/.settings/.api_filters +++ b/org.eclipse.jdt.ui/.settings/.api_filters @@ -137,6 +137,14 @@ + + + + + + + + diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/HierarchyInformationControl.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/HierarchyInformationControl.java index fe4cf55e3ad..a4a9b3a447e 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/HierarchyInformationControl.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/HierarchyInformationControl.java @@ -14,6 +14,9 @@ package org.eclipse.jdt.internal.ui.typehierarchy; import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyAdapter; @@ -23,6 +26,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.Widget; import org.eclipse.jface.bindings.TriggerSequence; import org.eclipse.jface.bindings.keys.KeySequence; @@ -130,7 +134,23 @@ protected TreeViewer createTreeViewer(Composite parent, int style) { gd.heightHint= tree.getItemHeight() * 12; tree.setLayoutData(gd); - TreeViewer treeViewer= new TreeViewer(tree); + TreeViewer treeViewer= new TreeViewer(tree) { + @Override + protected Predicate getShouldWigdetExpand() { + + Set expanded= new HashSet<>(); + + // Expand every class/interface only once + return w -> { + if (w == null) { + return false; + } + + Object data= w.getData(); + return data == null || expanded.add(data); + }; + } + }; treeViewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java index f8f3c9d72dd..eeae1754069 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/TypeHierarchyViewer.java @@ -13,10 +13,15 @@ *******************************************************************************/ package org.eclipse.jdt.internal.ui.typehierarchy; +import java.util.HashSet; +import java.util.Set; +import java.util.function.Predicate; + import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.Widget; import org.eclipse.core.runtime.Assert; @@ -182,4 +187,19 @@ protected TypeHierarchyContentProvider getHierarchyContentProvider() { return (TypeHierarchyContentProvider)getContentProvider(); } + @Override + protected Predicate getShouldWigdetExpand() { + Set expanded= new HashSet<>(); + + // Expand every class/interface only once + return w -> { + if (w == null) { + return false; + } + + Object data= w.getData(); + return data == null || expanded.add(data); + }; + } + }