From daea6d58b56d2facb0476c290a92129c95886b56 Mon Sep 17 00:00:00 2001 From: John Dallaway Date: Fri, 13 Oct 2023 09:14:20 +0100 Subject: [PATCH] Do not handle absent external translation units --- .../cdt/internal/ui/navigator/OpenCElementAction.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java index 81d5e41f809..1e4b1aba7fd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2023 Wind River Systems, Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * Anton Leherbauer (Wind River Systems) - initial API and implementation * Ed Swartz (Nokia) + * John Dallaway - do not handle absent external translation units (#563) *******************************************************************************/ package org.eclipse.cdt.internal.ui.navigator; @@ -76,7 +77,10 @@ protected boolean updateSelection(IStructuredSelection selection) { element = ((IAdaptable) element).getAdapter(ICElement.class); } if (element instanceof ICElement && (element instanceof ISourceReference || element instanceof IBinary)) { - fOpenElement = (ICElement) element; + // do not handle absent external translation units + if (!(element instanceof ITranslationUnit tu) || (null != tu.getResource()) || tu.exists()) { + fOpenElement = (ICElement) element; + } } } return fOpenElement != null || super.updateSelection(selection);