} else if (node.getParent() instanceof ICPPASTNamespaceDefinition) {
writer.newLine();
}
final String code = writer.toString();
if (endOffset > offset) {
addChildEdit(new DeleteEdit(offset, endOffset - offset));
}
if (!code.isEmpty()) {
addChildEdit(new InsertEdit(endOffset, code));
}
} else {
node.accept(writer);
String code = writer.toString();
final int offset = fileLocation.getNodeOffset();
final int endOffset = offset + fileLocation.getNodeLength();
final String lineSeparator = writer.getScribe().getLineSeparator();
if (code.endsWith(lineSeparator)) {
code = code.substring(0, code.length() - lineSeparator.length());
}
addChildEdit(new ReplaceEdit(offset, endOffset - offset, code));
if ((node instanceof IASTStatement) || (node instanceof IASTDeclaration)) {
// Include trailing comments in the area to be replaced.
final int commentEnd = getEndOffsetIncludingTrailingComments(node);
if (commentEnd > endOffset) {
addChildEdit(new DeleteEdit(endOffset, commentEnd - endOffset));
}
}
}
}