void ASTree::printNodeAtLevel(NodePtr& node, std::string indent) { std::cout << indent << "Type: " << node->nodeType() << "\n"; std::cout << indent << "Name: " << node->nodeName() << "\n"; if (node->nodeType() == "function") std::cout << indent << "Line Count: " << node->endLine() - node->startLine() - 1 << "\n"; if (node->nodeType() == "function") std::cout << indent << "Complexity : " << node->getNoOfDescendants() << "\n"; std::cout << "\n"; }
//------------Helper function for recursively printing function metrics data -------// void ASTree::recursiveFunctionMetrics(NodePtr& node) { if (node->nodeType() == "function") { std::cout << "\n"; std::cout << "Function: " << node->nodeName() << "\t\t"; std::cout << "Lines: " << node->endLine() - node->startLine() - 1; std::cout << " Complexity: " << node->getNoOfDescendants(); } if (!hasChild(node)) { return; } for each(auto child in node->children()) { recursiveFunctionMetrics(child); } }