diff --git a/plugins/cpp_metrics/service/cxxmetrics.thrift b/plugins/cpp_metrics/service/cxxmetrics.thrift index ce0758da6..c3789c554 100644 --- a/plugins/cpp_metrics/service/cxxmetrics.thrift +++ b/plugins/cpp_metrics/service/cxxmetrics.thrift @@ -35,39 +35,28 @@ struct CppModuleMetricsTypeName 2:string name } -struct CppMetricsAstNode +struct CppMetricsAstNodeSingle { 1:CppAstNodeMetricsType type, 2:double value } -struct CppAllMetricsAstNode +struct CppMetricsAstNodeAll { 1:common.AstNodeId id, - 2:list metrics + 2:list metrics } -struct CppMetricsModule +struct CppMetricsModuleSingle { 1:CppModuleMetricsType type, 2:double value } -struct CppAllMetricsModule +struct CppMetricsModuleAll { 1:common.FileId id, - 2:list metrics -} - -// Thrift does not provide a union type, -// the ids can remain empty. -struct CppMetricsPath -{ - 1:CppUnitType type - 2:common.AstNodeId astNodeId - 3:list astNodeIdMetrics - 4:common.FileId fileId - 5:list fileMetrics + 2:list metrics } service CppMetricsService @@ -84,28 +73,28 @@ service CppMetricsService * This function returns all available C++ metrics * for a particular AST node. */ - list getCppMetricsForAstNode( + list getCppMetricsForAstNode( 1:common.AstNodeId astNodeId) /** * This function returns all available C++ metrics * for a particular module. */ - list getCppMetricsForModule( + list getCppMetricsForModule( 1:common.FileId fileId) /** * This function returns all available C++ metrics * (AST node-level) for a particular path. */ - list getCppAstNodeMetricsForPath( + list getCppAstNodeMetricsForPath( 1:string path) /** * This function returns all available C++ metrics * (file-level) for a particular path. */ - list getCppFileMetricsForPath( + list getCppFileMetricsForPath( 1:string path) /** @@ -116,5 +105,5 @@ service CppMetricsService /** * This function returns the names of module-level metrics. */ - list getCppModuleMetricsTypeNames() + list getCppModuleMetricsTypeNames() } \ No newline at end of file diff --git a/plugins/cpp_metrics/service/include/service/cppmetricsservice.h b/plugins/cpp_metrics/service/include/service/cppmetricsservice.h index a0a173eb3..24a39f4af 100644 --- a/plugins/cpp_metrics/service/include/service/cppmetricsservice.h +++ b/plugins/cpp_metrics/service/include/service/cppmetricsservice.h @@ -41,19 +41,19 @@ class CppMetricsServiceHandler : virtual public CppMetricsServiceIf CppAstNodeMetricsType::type metric_) override; void getCppMetricsForAstNode( - std::vector& _return, + std::vector& _return, const core::AstNodeId& astNodeId_) override; void getCppMetricsForModule( - std::vector& _return, + std::vector& _return, const core::FileId& fileId_) override; void getCppAstNodeMetricsForPath( - std::vector& _return, + std::vector& _return, const std::string& path_) override; void getCppFileMetricsForPath( - std::vector& _return, + std::vector& _return, const std::string& path_) override; void getCppAstNodeMetricsTypeNames( diff --git a/plugins/cpp_metrics/service/src/cppmetricsservice.cpp b/plugins/cpp_metrics/service/src/cppmetricsservice.cpp index 4aa9b5c4c..21bf7a21c 100644 --- a/plugins/cpp_metrics/service/src/cppmetricsservice.cpp +++ b/plugins/cpp_metrics/service/src/cppmetricsservice.cpp @@ -54,10 +54,10 @@ void CppMetricsServiceHandler::getCppModuleMetricsTypeNames( } void CppMetricsServiceHandler::getCppMetricsForAstNode( - std::vector& _return, + std::vector& _return, const core::AstNodeId& astNodeId_) { - CppMetricsAstNode metric; + CppMetricsAstNodeSingle metric; _transaction([&, this](){ typedef odb::query CppAstNodeMetricsQuery; @@ -97,10 +97,10 @@ double CppMetricsServiceHandler::getSingleCppMetricForAstNode( } void CppMetricsServiceHandler::getCppMetricsForModule( - std::vector& _return, + std::vector& _return, const core::FileId& fileId_) { - CppMetricsModule metric; + CppMetricsModuleSingle metric; _transaction([&, this](){ typedef odb::query CppModuleMetricsQuery; @@ -118,7 +118,7 @@ void CppMetricsServiceHandler::getCppMetricsForModule( } void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( - std::vector& _return, + std::vector& _return, const std::string& path_) { _transaction([&, this]() @@ -142,9 +142,9 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( { auto metricsQuery = _db->query( CppAstNodeMetricsQuery::astNodeId == node.id); - std::vector metrics; + std::vector metrics; - CppMetricsAstNode metricsAstNode; + CppMetricsAstNodeSingle metricsAstNode; for (const auto& metric : metricsQuery) { metricsAstNode.type = static_cast(metric.type); @@ -155,7 +155,7 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( if (metrics.empty()) continue; - CppAllMetricsAstNode nodeMetric; + CppMetricsAstNodeAll nodeMetric; nodeMetric.id = std::to_string(node.id); nodeMetric.metrics = metrics; _return.push_back(nodeMetric); @@ -164,7 +164,7 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath( } void CppMetricsServiceHandler::getCppFileMetricsForPath( - std::vector& _return, + std::vector& _return, const std::string& path_) { _transaction([&, this]() @@ -188,9 +188,9 @@ void CppMetricsServiceHandler::getCppFileMetricsForPath( { CppFileMetricsResult metricsQuery = _db->query( CppFileMetricsQuery::file == file.id); - std::vector metrics; + std::vector metrics; - CppMetricsModule metricsModule; + CppMetricsModuleSingle metricsModule; for (const auto& metric : metricsQuery) { metricsModule.type = static_cast(metric.type); @@ -201,7 +201,7 @@ void CppMetricsServiceHandler::getCppFileMetricsForPath( if (metrics.empty()) continue; - CppAllMetricsModule nodeMetric; + CppMetricsModuleAll nodeMetric; nodeMetric.id = std::to_string(file.id); nodeMetric.metrics = metrics; _return.push_back(nodeMetric);