I met a problem while using PMD to check my code errors. I do not know how to satisfy two requirements at the same time. For example, if I want to check a method named ABC not existing in file extends from BCD. I know how to check whether ABC exists or whether it extends from BCD separately using PMD.
Like this:
//PrimaryExpression/PrimaryPrefix/Name [@Image = "ABC"];
//ExtendsList/ClassOrInterfaceType [@Image != "BCD"];
now, is there anyway that I can check these two together. For example, I want it no ABC in class extends BCD. It seems I cannot simply use things like and to connect this two Xpath queries. Also, I noticed I can use | to get connected with them, but | works as or. I need an and here instead of or.
Edit:
I tried something like this:
//PrimaryExpression/PrimaryPrefix/Name[@Image = "ABC"]
[//ancestor::ClassOrInterfaceDeclaration/ExtendsList/
ClassOrInterfaceType[@Image != "BCD"]]
Which seems like it works for me at least. But I am still not 100% sure if this is the correct way since I just tried this out.