public void groupIncludes(DOMASTNodeLeaf[] treeIncludes) { // loop through the includes and make sure that all of the nodes // that are children of the TU are in the proper include (based on offset) for (int i = treeIncludes.length - 1; i >= 0; i--) { final DOMASTNodeLeaf nodeLeaf = treeIncludes[i]; if (nodeLeaf == null || !(nodeLeaf.getNode() instanceof IASTPreprocessorIncludeStatement)) continue; final String path = ((IASTPreprocessorIncludeStatement) nodeLeaf.getNode()).getPath(); final DOMASTNodeLeaf[] children = root.getChildren(false); for (final DOMASTNodeLeaf child : children) { if (child != null && child != nodeLeaf && child.getNode().getContainingFilename().equals(path)) { root.removeChild(child); ((DOMASTNodeParent) nodeLeaf).addChild(child); } } } }
private DOMASTNodeLeaf createNode(DOMASTNodeParent parent, IASTNode node) { DOMASTNodeParent tree = new DOMASTNodeParent(node); parent.addChild(tree); // set filter flags if (node instanceof IASTProblemHolder || node instanceof IASTProblem) { tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PROBLEM); if (node instanceof IASTProblemHolder) astProblems = (IASTProblem[]) ArrayUtil.append( IASTProblem.class, astProblems, ((IASTProblemHolder) node).getProblem()); else astProblems = (IASTProblem[]) ArrayUtil.append(IASTProblem.class, astProblems, node); } if (node instanceof IASTPreprocessorStatement) tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PREPROCESSOR); if (node instanceof IASTPreprocessorIncludeStatement) tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_INCLUDE_STATEMENTS); return tree; }