// perform final changes to the open and close body ranges
int openBodyEnd, openBodyStart, closeBodyStart, closeBodyEnd;
DOMNode first = (DOMNode) getFirstChild();
DOMNode lastNode = null;
// look for the open body
Scanner scanner = new Scanner();
scanner.setSource(this.fDocument);
scanner.resetTo(this.fNameRange[1] + 1, this.fDocument.length);
try {
int currentToken = scanner.getNextToken();
while(currentToken != TerminalTokens.TokenNameLBRACE &&
currentToken != TerminalTokens.TokenNameEOF) {
currentToken = scanner.getNextToken();
}
if(currentToken == TerminalTokens.TokenNameLBRACE) {
openBodyEnd = scanner.currentPosition - 1;
openBodyStart = scanner.startPosition;
} else {
openBodyEnd = this.fDocument.length;
openBodyStart = this.fDocument.length;
}
} catch(InvalidInputException e) {
openBodyEnd = this.fDocument.length;
openBodyStart = this.fDocument.length;
}
if (first != null) {
int lineStart = finder.getLineStart(first.getStartPosition());
if (lineStart > openBodyEnd) {
openBodyEnd = lineStart - 1;
} else {
openBodyEnd = first.getStartPosition() - 1;
}
lastNode = (DOMNode) first.getNextNode();
if (lastNode == null) {
lastNode = first;
} else {
while (lastNode.getNextNode() != null) {
lastNode = (DOMNode) lastNode.getNextNode();
}
}
scanner.setSource(this.fDocument);
scanner.resetTo(lastNode.getEndPosition() + 1, this.fDocument.length);
try {
int currentToken = scanner.getNextToken();
while(currentToken != TerminalTokens.TokenNameRBRACE &&
currentToken != TerminalTokens.TokenNameEOF) {
currentToken = scanner.getNextToken();
}
if(currentToken == TerminalTokens.TokenNameRBRACE) {
closeBodyStart = scanner.startPosition;
closeBodyEnd = scanner.currentPosition - 1;
} else {
closeBodyStart = this.fDocument.length;
closeBodyEnd = this.fDocument.length;
}
} catch(InvalidInputException e) {
closeBodyStart = this.fDocument.length;
closeBodyEnd = this.fDocument.length;
}
} else {
scanner.resetTo(openBodyEnd, this.fDocument.length);
try {
int currentToken = scanner.getNextToken();
while(currentToken != TerminalTokens.TokenNameRBRACE &&
currentToken != TerminalTokens.TokenNameEOF) {
currentToken = scanner.getNextToken();
}
if(currentToken == TerminalTokens.TokenNameRBRACE) {
closeBodyStart = scanner.startPosition;
closeBodyEnd = scanner.currentPosition - 1;
} else {