if ((groupCategory != null) && (groupCategory.size() > 1)) {
if (errors == null) {
return true;
}
result = true;
PageElementCategory keepCategory = keepCategory(groupCategory, lastTitle);
if (keepCategory == category) {
CheckErrorResult errorResult = createCheckErrorResult(
analysis,
category.getBeginIndex(),
category.getEndIndex(),
CheckErrorResult.ErrorLevel.CORRECT);
errors.add(errorResult);
} else {
int beginIndex = category.getBeginIndex();
while ((beginIndex > 0) && (contents.charAt(beginIndex - 1) == ' ')) {
beginIndex--;
}
boolean beginLine = (beginIndex == 0) || (contents.charAt(beginIndex - 1) == '\n');
int endIndex = category.getEndIndex();
while ((endIndex < contents.length()) && (contents.charAt(endIndex) == ' ')) {
endIndex++;
}
boolean endLine = (endIndex >= contents.length()) || (contents.charAt(endIndex) == '\n');
if (beginLine && endLine) {
endIndex = Math.min(endIndex + 1, contents.length());
}
if (!beginLine) {
beginIndex = category.getBeginIndex();
}
if (!endLine) {
endIndex = category.getEndIndex();
}
// Decide in the fix can be automatic
boolean automatic = false;
if (category.getBeginIndex() > keepCategory.getBeginIndex()) {
int currentIndex = keepCategory.getEndIndex();
boolean finished = false;
while (!finished && (currentIndex < category.getBeginIndex())) {
char currentChar = contents.charAt(currentIndex);
if ((currentChar == ' ') || (currentChar == '\n')) {
currentIndex++;
} else {
PageElementCategory nextCategory = analysis.isInCategory(currentIndex);
if (nextCategory != null) {
currentIndex = nextCategory.getEndIndex();
} else {
finished = true;
}
}
}