final String text = aRcurly.getText();
final int colNo = aRcurly.getColumnNo();
final int lineNo = aRcurly.getLineNo();
final String currentLine = getLines()[lineNo - 1];
if ((currentLine.substring(0, colNo).trim().length() != 0)
|| currentLine.substring(colNo + text.
length()).trim().length() != 0)
Roman and Max,
I noticed that the aforementioned code and its interpretations are already used in OperatorWrapCheck (and by Max in SeparatorWrapCheck and RightCurlyCheck) checks. It checks whether a token starts the line or finishes the line. Checkstyle already has a method for checking if a token starts the line. For instance:
final boolean startsLine = Utils.whitespaceBefore(rcurly.getColumnNo(), getLines()[rcurly.getLineNo() - 1]);
I looked through the Utils class but it doesn't contain the opposite method for checking if a token finishes the line. I propose to update Utils class with the following method:
public static boolean whitespaceAfter(int aIndex, String aLine)
It will allow us to simplify the logic in our checks and remove copy-paste by playing with both methods.