[plsql] Fix CodeFormatRule

Node::getEndColumn() is exclusive now with javacc based parsers
See JavaccToken
This commit is contained in:
Andreas Dangel
2020-03-20 10:52:42 +01:00
parent 2f93795609
commit 3399cfe0d4

View File

@ -31,8 +31,12 @@ import net.sourceforge.pmd.properties.PropertyFactory;
public class CodeFormatRule extends AbstractPLSQLRule {
private static final PropertyDescriptor<Integer> INDENTATION_PROPERTY = PropertyFactory.intProperty("indentation")
.desc("Indentation to be used for blocks").defaultValue(2).require(inRange(0, 32)).build();
private static final PropertyDescriptor<Integer> INDENTATION_PROPERTY =
PropertyFactory.intProperty("indentation")
.desc("Indentation to be used for blocks")
.defaultValue(2)
.require(inRange(0, 32))
.build();
private int indentation = INDENTATION_PROPERTY.defaultValue();
@ -207,7 +211,8 @@ public class CodeFormatRule extends AbstractPLSQLRule {
public Object visit(ASTArgumentList node, Object data) {
List<ASTArgument> arguments = node.findChildrenOfType(ASTArgument.class);
if (node.getEndColumn() > 120) {
// note: end column is exclusive
if (node.getEndColumn() >= 120) {
addViolationWithMessage(data, node, "Line is too long, please split parameters on separate lines");
return super.visit(node, data);
}
@ -229,7 +234,7 @@ public class CodeFormatRule extends AbstractPLSQLRule {
if (argument.getChild(0) instanceof ASTUnqualifiedID) {
if (argument.getChild(0).getEndColumn() > longestParameterEndColumn) {
longestParameterEndColumn = argument.getChild(0).getEndColumn();
longestParameterEndColumn = argument.getChild(0).getEndColumn() - 1;
}
}
}