Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315664

Summary: When using an external PDOM, Open Declaration sometimes pops up dialog with two identical choices
Product: [Tools] CDT Reporter: Steve Kennedy <Steve.Kennedy>
Component: cdt-source-navAssignee: Markus Schorn <mschorn.eclipse>
Status: RESOLVED FIXED QA Contact: Markus Schorn <mschorn.eclipse>
Severity: normal    
Priority: P3 CC: yevshif
Version: 7.0   
Target Milestone: 7.0.1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
fix mschorn.eclipse: iplog-

Description Steve Kennedy CLA 2010-06-03 16:09:49 EDT
Build Identifier: M20100211-1343

This happens in the following specific scenario:

header file (external to current project):
#define FOO(p) foo(42, p)
...
// this declaration is required to trigger the problem
extern void foo(int, int);

Function "foo" is defined in a source file external to the current project.  This file is indexed in an external PDOM that has been attached to the project using the org.eclipse.cdt.core.CINDEX ReadOnlyPDOMProvider extension point.

Invoking "Open Declaration" on "foo" in the #define line results in "Open Declaration" dialog with two choices for "foo(int, int) - /path/to/source/file".
"Open Declaration" on the "foo" in the extern statement goes directly to the source file.

Using the debugger I've traced what happens to the method "navigationFallBack" in org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsJob.

The block of code using the ASTNameCollector puts a CPPFunction binding in the primaryBindings set and a CompositeCPPFunction binding in the ignoreIndexBindings set.  The CompositeCPPFunction has a linkage to the *local* index pdom.

The block of code with the "Search the index, also" comment adds a CompositeCPPFunction binding to the primaryBindings set.  This CompositeCPPFunction has a linkage to the *external* index pdom and thus isn't ignored by the !ignoreIndexBindings.contains(idxBinding) test.

In the block of code with the "Convert bindings to CElements" comment, the two bindings both end up getting resolved by the external pdom into duplicate elements.


Reproducible: Always
Comment 1 Markus Schorn CLA 2010-06-18 04:19:25 EDT
Created attachment 172200 [details]
fix

Changed to a more robust strategy to remove duplicate elements.
Comment 2 Markus Schorn CLA 2010-06-18 04:21:23 EDT
Fixed in 7.0.1 > 20100618.