/** * Returns a replace edit whose offset is the position where child appended nodes should be * inserted at. The text contains the content of the code region that will be disturbed by the * insertion. * * @param node The node to append children to. * @return a ReplaceEdit object, or <code>null</code> if the node does not support appending * children to it. */ private ReplaceEdit getAppendAnchor(IASTNode node) { if (!(node instanceof IASTCompositeTypeSpecifier || node instanceof IASTCompoundStatement || node instanceof ICPPASTNamespaceDefinition)) { return null; } String code = node.getRawSignature(); IASTFileLocation location = node.getFileLocation(); int pos = location.getNodeOffset() + location.getNodeLength(); int len = code.endsWith("}") ? 1 : 0; // $NON-NLS-1$ int insertPos = code.length() - len; int startOfLine = skipPrecedingBlankLines(code, insertPos); if (startOfLine == insertPos) { // Include the closing brace in the region that will be reformatted. return new ReplaceEdit(pos - len, len, code.substring(insertPos)); } return new ReplaceEdit( location.getNodeOffset() + startOfLine, insertPos - startOfLine, ""); // $NON-NLS-1$ }
@Override protected void prepareIsFriend(IASTNode astNode) { isFriend = astNode.getRawSignature().contains(KEYWORD_FRIEND); }