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

Bug 335958

Summary: Duplicate search result
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: unspecified   
Target Milestone: 4.0.6   
Hardware: PC   
OS: Windows XP   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=325385
Whiteboard:
Attachments:
Description Flags
patch to 40* stream vivkong: iplog+

Description John Liu CLA 2011-02-01 09:19:53 EST
Build Identifier: 

If we search student in the following Source code, there will be duplicate search results pointing to "Student <int>".

template <class type> class Student: public Five{
private:


public:
	type ID;
};

class Teacher: public Student <int>{

};

Reproducible: Always
Comment 1 John Liu CLA 2011-02-01 09:36:11 EST
The reason of this problem is stated in the cdt bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=325385.

However, I can't port the cdt fix to rdt directly, since the search classes are very different from cdt.

The fix in rdt will be in RemoteSearchQueryAdapter class by adding a sort MatchesComparator to sort the matches list before adding it to result. The sort order is by file uri first, then offset, then length, make sure a match with a longer length is placed before a match with a shorter length if their file uri and offset are the same.

Then fix in RemoteSearchMatchAdapter updates the equals function, if a match has a same indexfile, a same offset but a shorter length, we will consider it equals to the target match. 

In this way, we can eliminate the duplicate matches with same offset and keep the one which covers longer segment.
Comment 2 John Liu CLA 2011-02-01 10:43:44 EST
Created attachment 188056 [details]
patch to 40* stream
Comment 3 Vivian Kong CLA 2011-02-01 12:56:56 EST
I'll take a look
Comment 4 Vivian Kong CLA 2011-02-01 13:50:19 EST
Applied to ptp_4_0 and HEAD.  Thanks John.