error of "Open declaration" [message #673741] |
Tue, 24 May 2011 15:27 |
jin huang Messages: 1 Registered: May 2011 |
Junior Member |
|
|
Build Identifier: eclipse 3.6.0
In a function of c code, when local variable has the same name as another
function A called in this function, if we check the method A's declaration by
clicking "Open declaration", it show the declaration of the local variable, but
not the declaration of function A.
Reproducible: Always
Steps to Reproduce:
when we have the follow source code, in which a local variable has the same
name as a function called,
----------------------------------
1 int methodA(int a, int b){
2 return a+b;
3 }
4
5
6 int method41(int a, int b){
7 int methodA = 2;
8 return methodA(a,b);
9 }
10
11 int method42(int a, int b){
12 return methodA(a,b);
13 }
----------------------------------
if we right click on the function reference "methodA(...)" in line 8, and click
"Open declaration" to get its declaration, eclipse will show you the
declaration "int methodA = 2" in line 7, which is a error.
Then, I use eclipse's "c/c++ search" function
1)search string: "methodA*"
2)search for: Function
3)limitedto: references
But I got nothing !!
Finally, I download the source code of CDT from svn, write programs as below to
get callers of function with name "methodA", I still just got one function
reference from function "method42". The function "method41" is missing.
----------------------------------
void getCallers(ICProject project, IIndex index, IIndexBinding callee)
throws CoreException
{
IIndexName[] callers = index.findReferences(callee);
for (int i = 0; i < callers.length; i++) {
IIndexName rname = callers[i];
IIndexName caller = rname.getEnclosingDefinition();
if (caller != null) {
ICElement elem = IndexUI.getCElementForName(project, index,
caller);
if (elem != null) {
result.add(elem, rname);
}
}
}//for
}//getCallers()
----------------------------------
what happened? PDOM index may have some problem
|
|
|
|
Powered by
FUDForum. Page generated in 0.03184 seconds