| Summary: | The C++ search results have duplicate matches for one spot. | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | John Liu <john_ws_liu> | ||||||
| Component: | cdt-indexer | Assignee: | Markus Schorn <mschorn.eclipse> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Markus Schorn <mschorn.eclipse> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | ||||||||
| Version: | 7.0 | ||||||||
| Target Milestone: | 7.0.2 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 178977 [details]
Test project zip
Hmm, I can explain what happens:
For each template-id we have two names, one of which is the template-name the other is the template-id itself (e.g. Student within Student<int>).
For a class template the template-name binds to the class template, the template-id to the class template instance.
For a function template both the template-name and the template-id bind to
the function template instance. This is because the function template cannot
be selected without the template-arguments (you can do that for class templates).
When searching for references of a class or function template we actually
search for references to the template plus to all instances of that template.
Therefore there are two overlapping matches for the template-id.
I am not entirely sure how we should fix that:
(a) When searching for references to a class template we do not search
for references to the specializations. Rather than that rely on the
reference that is made through the template-name in the template-id.
For function template instances do not write the reference associated
with the template-name to the index.
(b) Filter away the matches where one overlaps the other (the match for
the template-id overlaps the one for the template-name).
I tend to solution (a), what do you think?
(In reply to comment #2) > Hmm, I can explain what happens: > For each template-id we have two names, one of which is the template-name the > other is the template-id itself (e.g. Student within Student<int>). > For a class template the template-name binds to the class template, the > template-id to the class template instance. > For a function template both the template-name and the template-id bind to > the function template instance. This is because the function template cannot > be selected without the template-arguments (you can do that for class > templates). > When searching for references of a class or function template we actually > search for references to the template plus to all instances of that template. > Therefore there are two overlapping matches for the template-id. > I am not entirely sure how we should fix that: > (a) When searching for references to a class template we do not search > for references to the specializations. Rather than that rely on the > reference that is made through the template-name in the template-id. > For function template instances do not write the reference associated > with the template-name to the index. > (b) Filter away the matches where one overlaps the other (the match for > the template-id overlaps the one for the template-name). > I tend to solution (a), what do you think? Thanks Markus for looking into this problem. I guess (a) solves the problem from the root cause, but (b) may be safer considering potential regression. Either way would be a decent fix for the problem. (In reply to comment #3) > I guess (a) solves the problem from the root cause, but (b) may be safer > considering potential regression. > Either way would be a decent fix for the problem. I'll go with (a) then, it is early in the release cycle, there is enough time to find potential regressions. (In reply to comment #4) > (In reply to comment #3) > > I guess (a) solves the problem from the root cause, but (b) may be safer > > considering potential regression. > > Either way would be a decent fix for the problem. > I'll go with (a) then, it is early in the release cycle, there is enough time > to find potential regressions. OK, thanks Markus. Do you have an approximate schedule for this fix? We hope it will be fixed as quick as possible :-) (In reply to comment #5) > OK, thanks Markus. Do you have an approximate schedule for this fix? We hope it > will be fixed as quick as possible :-) I have started to work on this issue, however my initial strategy was too simple, so I don't have a fix yet. Created attachment 179657 [details]
testcase + fix
The patch filters away overlapping search results.
Fixed in 7.0.2 > 20100927. *** cdt cvs genie on behalf of mschorn *** Bug 325385: Duplicate search results. [*] LineSearchElement.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java?root=Tools_Project&r1=1.7&r2=1.8 [*] PDOMSearchPatternQuery.java 1.33 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java?root=Tools_Project&r1=1.32&r2=1.33 [*] PDOMSearchQuery.java 1.29 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java?root=Tools_Project&r1=1.28&r2=1.29 [*] BasicSearchTest.java 1.13 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java?root=Tools_Project&r1=1.12&r2=1.13 [*] BasicSearchTest.java 1.12.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/BasicSearchTest.java?root=Tools_Project&r1=1.12&r2=1.12.2.1 [*] LineSearchElement.java 1.7.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java?root=Tools_Project&r1=1.7&r2=1.7.2.1 [*] PDOMSearchPatternQuery.java 1.31.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java?root=Tools_Project&r1=1.31&r2=1.31.2.1 [*] PDOMSearchQuery.java 1.28.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java?root=Tools_Project&r1=1.28&r2=1.28.2.1 |
Build Identifier: Please see Steps to Reproduce for details. Reproducible: Always Steps to Reproduce: 1.Create a C++ project based on the attached project zip file 2.Select the project and click on Search->C/C++, type "Student" in the Search string box, select "Selected resource" as the search scope, and do Search. 3.The search results shows 4 results, however there are only 3 occurrences of "Student" in the file (not counting the one in the comment). The line: class Teacher: public Student <int> { shows up in the search results twice. Use the "Show next match" arrow in the search results view to go to each result, it goes to that line twice.