Topic
  • No replies
SystemAdmin
SystemAdmin
746 Posts

Pinned topic Possible to use XPath?

‏2012-04-26T12:50:07Z |
Hi,

I am using PMD and will implement a new rule. The rule needs to make sure that if we have the following line:

if(Logger.enabled()){
Logger.fine();
}

The rule needs to make sure that when we have a Logger.fine() the previous line must be:

if(Logger.enabled())

Is it possible to check this with an xpath expression? I have no problems in matching the Logger.fine() - method.

//MethodDeclaration//StatementExpression//PrimaryExpression//PrimaryPrefix

Then when this condition is fullfilled I need to check if the previous line is a if(Logger.enabled()). Is even possible?

All advice is appreciated.

br,

//mike