My problem
I want to create a custom ruleset for PMD that finds all declared variables that use a specific package. And it should be a XPath ruleset, because that is easier to maintain for me.
What I have so far
I am able to find import
statements and variables. I'm using this XPath to find the declarations:
//VariableDeclarator[../Type
/ReferenceType
/ClassOrInterfaceType
[@Image = 'ClassA']]
However, this is only matching the exact class, but I want to check if this class comes from package my.package
and I don't know how to get that.
Any hints?