1818import java .util .Arrays ;
1919import java .util .Iterator ;
2020import java .util .List ;
21+ import java .util .stream .Stream ;
2122
2223import org .eclipse .help .IContextProvider ;
2324
116117
117118import org .eclipse .jdt .ui .IContextMenuConstants ;
118119import org .eclipse .jdt .ui .ITypeHierarchyViewPart ;
120+ import org .eclipse .jdt .ui .JavaElementLabels ;
119121import org .eclipse .jdt .ui .JavaUI ;
120122import org .eclipse .jdt .ui .PreferenceConstants ;
121123import org .eclipse .jdt .ui .actions .CCPActionGroup ;
@@ -1643,7 +1645,7 @@ private void restoreState(final IMemento memento) {
16431645 int i = 0 ;
16441646 while (elementId != null ) {
16451647 input = JavaCore .create (elementId );
1646- if (input == null || ! input . exists () ) {
1648+ if (input == null ) {
16471649 inputList = null ;
16481650 break ;
16491651 }
@@ -1654,23 +1656,33 @@ private void restoreState(final IMemento memento) {
16541656 doRestoreState (memento , input );
16551657 } else {
16561658 final IJavaElement [] hierarchyInput = inputList .toArray (new IJavaElement [inputList .size ()]);
1657-
16581659 synchronized (this ) {
1659- String label = Messages .format (TypeHierarchyMessages .TypeHierarchyViewPart_restoreinput , HistoryAction .getElementLabel (hierarchyInput ));
1660+ long flags = JavaElementLabels .M_APP_TYPE_PARAMETERS | JavaElementLabels .M_PARAMETER_TYPES | JavaElementLabels .ALL_POST_QUALIFIED | JavaElementLabels .P_COMPRESSED ;
1661+ String label = Messages .format (TypeHierarchyMessages .TypeHierarchyViewPart_restoreinput , HistoryAction .getElementLabel (hierarchyInput , flags ));
16601662 fNoHierarchyShownLabel .setText (label );
16611663
16621664 fRestoreStateJob = new Job (label ) {
16631665 @ Override
16641666 protected IStatus run (IProgressMonitor monitor ) {
16651667 try {
1666- doRestoreInBackground (memento , hierarchyInput , monitor );
1668+ Job .getJobManager ().join (JavaUI .ID_PLUGIN , monitor );
1669+ IJavaElement [] existingHierarchyInput = Stream .of (hierarchyInput ).filter (IJavaElement ::exists ).toArray (length -> new IJavaElement [length ]);
1670+ if (existingHierarchyInput .length == 0 ) {
1671+ PlatformUI .getWorkbench ().getDisplay ().asyncExec (() -> {
1672+ doRestoreState (memento , new IJavaElement [0 ]);
1673+ });
1674+ } else {
1675+ doRestoreInBackground (memento , existingHierarchyInput , monitor );
1676+ }
16671677 } catch (JavaModelException e ) {
16681678 return e .getStatus ();
16691679 } catch (OperationCanceledException e ) {
16701680 if (fRestoreJobCanceledExplicitly ) {
16711681 showEmptyViewer ();
16721682 }
16731683 return Status .CANCEL_STATUS ;
1684+ } catch (InterruptedException e ) {
1685+ showEmptyViewer ();
16741686 }
16751687 return Status .OK_STATUS ;
16761688 }
0 commit comments