| Summary: | Could not find a parameter symbol when used with operator or copy ctor | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Marc-André Laperle <malaperle> | ||||||
| Component: | cdt-source-nav | Assignee: | Markus Schorn <mschorn.eclipse> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | Markus Schorn <mschorn.eclipse> | ||||||
| Severity: | normal | ||||||||
| Priority: | P3 | ||||||||
| Version: | 6.0 | ||||||||
| Target Milestone: | 7.0.2 | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
(In reply to comment #0) > const Bar& name; Oops, this line should be 'Bar name;' This worked in CDT 5.0.2, the bug was introduced in 6.0.0
No need to use a struct, it works with a simple int:
void bug(int var)
{
// cannot find symbol
int foo = var;
int foo2(var);
// can find symbol
var;
foo = var;
if(foo == var);
foo * var;
foo *= var;
}
void nobug()
{
// can find symbol
int var;
int foo = var;
int foo2(var);
}
Created attachment 178993 [details]
Open declaration parameter patch + test
I think the problem is OpenDeclarationsJob.isInSameFunction calling getEnclosingDeclaration. getEnclosingDeclaration searches for an IASTDeclaration which 'int foo = var;' matches. I think it should look for IASTFunctionDefinition.
Created attachment 179003 [details]
extended testcase + fix
Thanks Marc!
There is a related problem with template parameters. Therefore I have extended your patch. Also I have changed the implementation of isInSameFunction, such that it is as similar as possible to isInSameTemplate.
Fixed in 8.0 > 20100916. *** cdt cvs genie on behalf of mschorn *** Bug 325135: Navigation of function and template parameters. [*] OpenDeclarationsJob.java 1.20 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java?root=Tools_Project&r1=1.19&r2=1.20 [*] CPPSelectionTestsNoIndexer.java 1.31 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java?root=Tools_Project&r1=1.30&r2=1.31 (In reply to comment #5) > Fixed in 8.0 > 20100916. Thanks! Would it be possible to apply this to 7.0.2? (In reply to comment #7) > Thanks! Would it be possible to apply this to 7.0.2? Sure, I'll wait until 7.0.1 has been released, though. Fixed in 7.0.2 > 20100928. *** cdt cvs genie on behalf of mschorn *** Bug 325135: Navigation of parameters. [*] CPPSelectionTestsNoIndexer.java 1.30.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/CPPSelectionTestsNoIndexer.java?root=Tools_Project&r1=1.30&r2=1.30.2.1 [*] OpenDeclarationsJob.java 1.16.2.2 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java?root=Tools_Project&r1=1.16.2.1&r2=1.16.2.2 |
If I Ctrl+click on a variable used with an operator or the copy constructor and it is declared as a parameter, the symbol cannot be found. Example: struct Bar; void bug(Bar name) { Bar foo = name; // cannot find symbol Bar foo2(name); // cannot find symbol name; // can find symbol if(foo == name); // can find symbol } void nobug() { const Bar& name; Bar foo = name; // can find symbol Bar foo2(name); // can find symbol }