|
4 | 4 | #include <odb/query.hxx> |
5 | 5 | #include <model/file.h> |
6 | 6 | #include <model/file-odb.hxx> |
| 7 | +#include <model/cppastnode.h> |
| 8 | +#include <model/cppastnode-odb.hxx> |
7 | 9 |
|
8 | 10 | namespace cc |
9 | 11 | { |
@@ -161,6 +163,46 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( |
161 | 163 | }); |
162 | 164 | } |
163 | 165 |
|
| 166 | +void CppMetricsServiceHandler::getCppAstNodeMetricsDetailedForPath( |
| 167 | + std::map<core::AstNodeId, CppMetricsAstNodeDetailed>& _return, |
| 168 | + const std::string& path_) |
| 169 | +{ |
| 170 | + _transaction([&, this](){ |
| 171 | + typedef odb::query<model::CppAstNodeFilePath> CppAstNodeFilePathQuery; |
| 172 | + typedef odb::result<model::CppAstNodeFilePath> CppAstNodeFilePathResult; |
| 173 | + typedef odb::query<model::CppAstNodeMetricsAndDataForPathView> CppAstNodeMetricsAndDataForPathViewQuery; |
| 174 | + typedef odb::result<model::CppAstNodeMetricsAndDataForPathView> CppAstNodeMetricsAndDataForPathViewResult; |
| 175 | + |
| 176 | + auto nodes = _db->query<model::CppAstNodeMetricsAndDataForPathView>( |
| 177 | + CppAstNodeFilePathQuery::LocFile::path.like(path_ + '%')); |
| 178 | + |
| 179 | + for (const auto& node : nodes) |
| 180 | + { |
| 181 | + auto pair = std::make_pair(static_cast<CppAstNodeMetricsType::type>(node.type), node.value); |
| 182 | + if (_return.count(std::to_string(node.astNodeId))) |
| 183 | + { |
| 184 | + _return[std::to_string(node.astNodeId)].metrics.insert(pair); |
| 185 | + } |
| 186 | + else |
| 187 | + { |
| 188 | + CppMetricsAstNodeDetailed metric; |
| 189 | + std::size_t pos = node.path.find_last_of('/'); |
| 190 | + metric.path = node.path.substr(0, pos + 1); |
| 191 | + metric.file = node.path.substr(pos + 1); |
| 192 | + metric.startLine = node.startLine; |
| 193 | + metric.endLine = node.endLine; |
| 194 | + metric.astValue = node.astValue; |
| 195 | + metric.symbolType = cc::model::symbolTypeToString(node.symbolType); |
| 196 | + metric.astType = cc::model::astTypeToString(node.astType); |
| 197 | + |
| 198 | + std::map<CppAstNodeMetricsType::type, double> metricsList; |
| 199 | + metricsList.insert(pair); |
| 200 | + _return.insert(std::make_pair(std::to_string(node.astNodeId), metric)); |
| 201 | + } |
| 202 | + } |
| 203 | + }); |
| 204 | +} |
| 205 | + |
164 | 206 | void CppMetricsServiceHandler::getCppFileMetricsForPath( |
165 | 207 | std::map<core::FileId, std::vector<CppMetricsModuleSingle>>& _return, |
166 | 208 | const std::string& path_) |
|
0 commit comments