* @param sentence The text being checked
* @return The RuleMatch object with adjustments.
*/
public RuleMatch adjustRuleMatchPos(final RuleMatch match, int sentLen,
int columnCount, int lineCount, final String sentence) {
final RuleMatch thisMatch = new RuleMatch(match.getRule(),
match.getFromPos() + sentLen, match.getToPos() + sentLen, match.getMessage(), match.getShortMessage());
thisMatch.setSuggestedReplacements(match.getSuggestedReplacements());
final String sentencePartToError = sentence.substring(0, match.getFromPos());
final String sentencePartToEndOfError = sentence.substring(0,match.getToPos());
final int lastLineBreakPos = sentencePartToError.lastIndexOf('\n');
final int column;
final int endColumn;
if (lastLineBreakPos == -1) {
column = sentencePartToError.length() + columnCount;
} else {
column = sentencePartToError.length() - lastLineBreakPos;
}
final int lastLineBreakPosInError = sentencePartToEndOfError.lastIndexOf('\n');
if (lastLineBreakPosInError == -1) {
endColumn = sentencePartToEndOfError.length() + columnCount;
} else {
endColumn = sentencePartToEndOfError.length() - lastLineBreakPosInError;
}
final int lineBreaksToError = countLineBreaks(sentencePartToError);
final int lineBreaksToEndOfError = countLineBreaks(sentencePartToEndOfError);
thisMatch.setLine(lineCount + lineBreaksToError);
thisMatch.setEndLine(lineCount + lineBreaksToEndOfError);
thisMatch.setColumn(column);
thisMatch.setEndColumn(endColumn);
thisMatch.setOffset(match.getFromPos() + sentLen);
return thisMatch;
}