I'm writing custom lint check to ban some methods. So if someone calls banned method foo
on instance of class A
, lint should report error.
I achieved this for static methods like this (inside visitCallExpression(UCallExpression)
:
node.receiver as UReferenceExpression).getQualifiedName()
From qualified name I can get the Class
object and run my check but I can't get the qualified name for methods called on instantiated object. I can get the name of the class to which the objects belongs but not the qualified name.
How do I get qualified name of class of method that is called on instance of that class? If I'm being unclear, here is an example.
import android.view.Button;
class ButtonSetTextIntClass {
private Button button;
public void bannedSetText (){
button.setText(123);
}
}
And I need in visitCallExpression (UCallExpression)
get qualified name/class of button
.