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

Bug 327673

Summary: A workspace scope index causes parsing result with incorrect bindings
Product: [Tools] PTP Reporter: John Liu <john_ws_liu>
Component: RDTAssignee: Vivian Kong <vivkong>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: vivkong
Version: 4.0.4   
Target Milestone: 4.0.4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
fix patch applied to org.eclipse.ptp.internal.rdt.core.miners.OpenDeclarationHandler
none
proposed patch for remote type hierarchy
none
a completed patch applied to rdt.core and rct.ui
vivkong: iplog+
John's patch for HEAD
none
an updated patch to be applied on top of the previous patch vivkong: iplog+

Description John Liu CLA 2010-10-13 10:54:59 EDT
Build Identifier: 

For two remote projects that share a same header file, OpenDeclaration can't find a class decalared in the shared header file properly in one of these two projects. 



Reproducible: Always
Comment 1 John Liu CLA 2010-10-13 11:05:54 EDT
The problem is becuase OpenDeclarationHandler uses a global index which contains all of projects index fragments to parse the given working copy to interpret the selection, since the hearder file is shared between two projects, two bindings (from two projects) will be found out to a selection which binds to a class declaration in the hearder file, these two bindings will be finially merged into one by CDT index binding look up process. As a result of this merge, one of bindings (from one of two projects) is lost, then OpenDeclarationHandler won't be able to interpret the selection that binds to the lost binding.
Comment 2 John Liu CLA 2010-10-13 11:11:01 EDT
Created attachment 180778 [details]
fix patch applied to org.eclipse.ptp.internal.rdt.core.miners.OpenDeclarationHandler

The fix modifies OpenDeclarationHandler to use project specific index to parse the given working copy to interpret the selection.
Comment 3 Vivian Kong CLA 2010-10-14 11:37:44 EDT
Created attachment 180888 [details]
proposed patch for remote type hierarchy
Comment 4 Vivian Kong CLA 2010-10-14 11:38:22 EDT
There is a similar problem for remote type hierarchy.  I have attached a patch for that as well.
Comment 5 John Liu CLA 2010-10-26 14:04:52 EDT
Update the summary since this is not an only open declaration problem.
Comment 6 John Liu CLA 2010-10-26 14:06:34 EDT
Update Vivian's fix by update the code at server side, CDTMinner, need a workspace scope index to do the search.
Comment 7 John Liu CLA 2010-10-26 16:06:08 EDT
Also found this problem in content assistant, search,

Fix for content assist is in AbstractCompletionProposalAdapter, line 82.

Fix for search:

org.eclipse.ptp.internal.rdt.ui.search.actions.FindAction
RemoteSearchQuery, RemoteSearchElementQuery, RemoteSearchPatternQuery, RemoteSearchTextSelectionQuery, CDTMinner - handleRunQuery
Comment 8 John Liu CLA 2010-10-29 15:18:50 EDT
Created attachment 182077 [details]
a completed patch applied to rdt.core and rct.ui

This is a completed patch to fix the problem in this files:

org/eclipse/ptp/internal/rdt/ui/typehierarchy/TypeHierarchyUtil.java
org/eclipse/ptp/internal/rdt/ui/contentassist/AbstractCompletionProposalAdapter.java
org.eclipse.ptp.internal.rdt.ui.search.actions.FindAction
org.eclipse.ptp.internal.rdt.ui.callhierarchy.CHContentProvider


Under package, org.eclipse.ptp.internal.rdt.core.search:
RemoteSearchQuery, 
RemoteSearchElementQuery, 
RemoteSearchPatternQuery,
RemoteSearchTextSelectionQuery

Under package, org.eclipse.ptp.internal.rdt.core.miners:
CDTMinner,
RemoteIndexManager
org/eclipse/ptp/internal/rdt/core/miners/OpenDeclarationHandler.java
Comment 9 Vivian Kong CLA 2010-11-01 10:23:37 EDT
Created attachment 182139 [details]
John's patch for HEAD

Modified John's patch for HEAD
Comment 10 Vivian Kong CLA 2010-11-01 10:26:19 EDT
Patch applied to ptp_4_0 and HEAD.  Thanks John.
Comment 11 John Liu CLA 2010-11-03 13:46:44 EDT
Created attachment 182314 [details]
an updated patch to be applied on top of the previous patch

Update the index acquiring lock and releasing lock sequence to keep a sequential sequence.
Comment 12 Vivian Kong CLA 2010-11-03 14:32:26 EDT
(In reply to comment #11)
> Created an attachment (id=182314) [details]
> an updated patch to be applied on top of the previous patch
> 
> Update the index acquiring lock and releasing lock sequence to keep a
> sequential sequence.

Thanks John.  I have applied your patch to ptp_4_0 and a modified version to HEAD.