Bug 6538 - searchDeclarationsOf* incorrect
Summary: searchDeclarationsOf* incorrect
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-12-04 04:45 EST by Adam Kiezun CLA
Modified: 2002-01-14 10:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2001-12-04 04:45:28 EST
in a file 'B.java' i have:

package p;

import java.util.ArrayList;
import java.util.List;

class A{
	int i(){
		return 0;
	}
}

class B {
	int f;
	void i(){
		y();
		List l= new ArrayList(f);
	}
	private void y(){
	}

}

class C extends A{
	public  int i(){
		return 0;
	}
}

now, use searchDeclarationsOfAccessedFields on method C::i() and you'll get
B.f for example

searchDeclarationsOfReferencedTypes on the same method gives you B::y()

both are incorrect
note also that the results are correct if the file is called, for instance, 
X.java.
Comment 1 Adam Kiezun CLA 2001-12-04 04:47:05 EST
i wrote searchDeclarationsOfReferencedTypes but i meant 
searchDeclarationsOfSentMessages
Comment 2 Adam Kiezun CLA 2001-12-07 10:50:39 EST
this might be related so i'll paste it here:
if you have sth like this in one cu:
package p;

class A {
}

class B extends A {
	private int f;
	private class P{}
	private void a(){}
	void m() { 
		f++;
		P p= new P();
		a();
	}	
}

and searchDeclarationsOfAccessedFields - you find none!
same for the other 2 searchDeclarationsOf* methods (in their respective test 
cases)
Comment 3 Jerome Lanneluc CLA 2001-12-10 09:55:28 EST
These are actually 2 different problems:
1. In the original test case, we did not restrict the search to the given method 
but to its compilation unit
2. In the second one, the declaration is found in a secondary type (thus not 
visible)

Fixed the first problem by passing the given element to the DeclarationOf* 
pattern.
Fixed the second problem by looking at the compilation unit of the given element 
to find the declaring type.