use of mrmathami.cia.cpp.ast.IBodyContainer in project Cpp4CIA by thanhminhmr.
the class AstBuilder method mergeDuplicate.
private void mergeDuplicate(@Nonnull CppNode.Matcher matcher, @Nonnull CppNode node) {
final Map<CppNode.Wrapper, CppNode> nodeMap = new HashMap<>();
for (final CppNode childNode : List.copyOf(node.getChildren())) {
final CppNode.Wrapper wrapper = new CppNode.Wrapper(childNode, CppNode.MatchLevel.SIMILAR, matcher);
final CppNode existingNode = nodeMap.putIfAbsent(wrapper, childNode);
if (existingNode == null)
continue;
if (existingNode instanceof IBodyContainer) {
if (((IBodyContainer) existingNode).getBody() == null) {
existingNode.transfer(childNode);
nodeMap.put(wrapper, childNode);
} else {
childNode.transfer(existingNode);
}
} else {
childNode.transfer(existingNode);
if (childNode instanceof IntegralNode) {
integralNodeMap.remove(childNode.getName());
}
}
}
}
Aggregations