From 4e7f132020439df84567c3669b75dcfead56e70f Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Tue, 6 Dec 2016 03:08:34 -0500 Subject: [PATCH] Bug 379623 - Follow includes in inactive code paths Change-Id: Iafc03eea7443b1d58a1521071783c39bbf3cdbcb --- .../ui/search/actions/OpenDeclarationsJob.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index e809b368d83..ab38d6d7f51 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -779,8 +779,23 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { if (incStmt.isResolved()) name = incStmt.getPath(); + IPath path = null; if (name != null) { - final IPath path = new Path(name); + path = new Path(name); + } else if (!incStmt.isActive()) { + // Includes inside inactive preprocessor branches will not be resolved in the AST. + // For these, attempt resolving the include via the C model as a fallback. + try { + ICElement element = SelectionConverter.getElementAtOffset(fTranslationUnit, fTextSelection); + if (element instanceof IInclude) { + path = CElementIncludeResolver.resolveInclude((IInclude) element); + } + } catch (CModelException e) { + } catch (CoreException e) { + } + } + + if (path != null) { openInclude(path); } else { fAction.reportIncludeLookupFailure(new String(incStmt.getName().toCharArray()));