Community
Participate
Working Groups
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.
i wrote searchDeclarationsOfReferencedTypes but i meant searchDeclarationsOfSentMessages
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)
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.