Skip to content

Commit e09e8ff

Browse files
committed
Variable renaming and other small refactorings.
1 parent 0936a19 commit e09e8ff

File tree

3 files changed

+27
-38
lines changed

3 files changed

+27
-38
lines changed

plugins/cpp_metrics/service/cxxmetrics.thrift

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,28 @@ struct CppModuleMetricsTypeName
3535
2:string name
3636
}
3737

38-
struct CppMetricsAstNode
38+
struct CppMetricsAstNodeSingle
3939
{
4040
1:CppAstNodeMetricsType type,
4141
2:double value
4242
}
4343

44-
struct CppAllMetricsAstNode
44+
struct CppMetricsAstNodeAll
4545
{
4646
1:common.AstNodeId id,
47-
2:list<CppMetricsAstNode> metrics
47+
2:list<CppMetricsAstNodeSingle> metrics
4848
}
4949

50-
struct CppMetricsModule
50+
struct CppMetricsModuleSingle
5151
{
5252
1:CppModuleMetricsType type,
5353
2:double value
5454
}
5555

56-
struct CppAllMetricsModule
56+
struct CppMetricsModuleAll
5757
{
5858
1:common.FileId id,
59-
2:list<CppMetricsModule> metrics
60-
}
61-
62-
// Thrift does not provide a union type,
63-
// the ids can remain empty.
64-
struct CppMetricsPath
65-
{
66-
1:CppUnitType type
67-
2:common.AstNodeId astNodeId
68-
3:list<CppMetricsAstNode> astNodeIdMetrics
69-
4:common.FileId fileId
70-
5:list<CppMetricsModule> fileMetrics
59+
2:list<CppMetricsModuleSingle> metrics
7160
}
7261

7362
service CppMetricsService
@@ -84,28 +73,28 @@ service CppMetricsService
8473
* This function returns all available C++ metrics
8574
* for a particular AST node.
8675
*/
87-
list<CppMetricsAstNode> getCppMetricsForAstNode(
76+
list<CppMetricsAstNodeSingle> getCppMetricsForAstNode(
8877
1:common.AstNodeId astNodeId)
8978

9079
/**
9180
* This function returns all available C++ metrics
9281
* for a particular module.
9382
*/
94-
list<CppMetricsModule> getCppMetricsForModule(
83+
list<CppMetricsModuleSingle> getCppMetricsForModule(
9584
1:common.FileId fileId)
9685

9786
/**
9887
* This function returns all available C++ metrics
9988
* (AST node-level) for a particular path.
10089
*/
101-
list<CppAllMetricsAstNode> getCppAstNodeMetricsForPath(
90+
list<CppMetricsAstNodeAll> getCppAstNodeMetricsForPath(
10291
1:string path)
10392

10493
/**
10594
* This function returns all available C++ metrics
10695
* (file-level) for a particular path.
10796
*/
108-
list<CppAllMetricsModule> getCppFileMetricsForPath(
97+
list<CppMetricsModuleAll> getCppFileMetricsForPath(
10998
1:string path)
11099

111100
/**
@@ -116,5 +105,5 @@ service CppMetricsService
116105
/**
117106
* This function returns the names of module-level metrics.
118107
*/
119-
list<CppModuleMetricsTypeName> getCppModuleMetricsTypeNames()
108+
list<CppModuleMetricsTypeName> getCppModuleMetricsTypeNames()
120109
}

plugins/cpp_metrics/service/include/service/cppmetricsservice.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ class CppMetricsServiceHandler : virtual public CppMetricsServiceIf
4141
CppAstNodeMetricsType::type metric_) override;
4242

4343
void getCppMetricsForAstNode(
44-
std::vector<CppMetricsAstNode>& _return,
44+
std::vector<CppMetricsAstNodeSingle>& _return,
4545
const core::AstNodeId& astNodeId_) override;
4646

4747
void getCppMetricsForModule(
48-
std::vector<CppMetricsModule>& _return,
48+
std::vector<CppMetricsModuleSingle>& _return,
4949
const core::FileId& fileId_) override;
5050

5151
void getCppAstNodeMetricsForPath(
52-
std::vector<CppAllMetricsAstNode>& _return,
52+
std::vector<CppMetricsAstNodeAll>& _return,
5353
const std::string& path_) override;
5454

5555
void getCppFileMetricsForPath(
56-
std::vector<CppAllMetricsModule>& _return,
56+
std::vector<CppMetricsModuleAll>& _return,
5757
const std::string& path_) override;
5858

5959
void getCppAstNodeMetricsTypeNames(

plugins/cpp_metrics/service/src/cppmetricsservice.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ void CppMetricsServiceHandler::getCppModuleMetricsTypeNames(
5454
}
5555

5656
void CppMetricsServiceHandler::getCppMetricsForAstNode(
57-
std::vector<CppMetricsAstNode>& _return,
57+
std::vector<CppMetricsAstNodeSingle>& _return,
5858
const core::AstNodeId& astNodeId_)
5959
{
60-
CppMetricsAstNode metric;
60+
CppMetricsAstNodeSingle metric;
6161

6262
_transaction([&, this](){
6363
typedef odb::query<model::CppAstNodeMetrics> CppAstNodeMetricsQuery;
@@ -97,10 +97,10 @@ double CppMetricsServiceHandler::getSingleCppMetricForAstNode(
9797
}
9898

9999
void CppMetricsServiceHandler::getCppMetricsForModule(
100-
std::vector<CppMetricsModule>& _return,
100+
std::vector<CppMetricsModuleSingle>& _return,
101101
const core::FileId& fileId_)
102102
{
103-
CppMetricsModule metric;
103+
CppMetricsModuleSingle metric;
104104

105105
_transaction([&, this](){
106106
typedef odb::query<model::CppFileMetrics> CppModuleMetricsQuery;
@@ -118,7 +118,7 @@ void CppMetricsServiceHandler::getCppMetricsForModule(
118118
}
119119

120120
void CppMetricsServiceHandler::getCppAstNodeMetricsForPath(
121-
std::vector<CppAllMetricsAstNode>& _return,
121+
std::vector<CppMetricsAstNodeAll>& _return,
122122
const std::string& path_)
123123
{
124124
_transaction([&, this]()
@@ -142,9 +142,9 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath(
142142
{
143143
auto metricsQuery = _db->query<model::CppAstNodeMetrics>(
144144
CppAstNodeMetricsQuery::astNodeId == node.id);
145-
std::vector<CppMetricsAstNode> metrics;
145+
std::vector<CppMetricsAstNodeSingle> metrics;
146146

147-
CppMetricsAstNode metricsAstNode;
147+
CppMetricsAstNodeSingle metricsAstNode;
148148
for (const auto& metric : metricsQuery)
149149
{
150150
metricsAstNode.type = static_cast<CppAstNodeMetricsType::type>(metric.type);
@@ -155,7 +155,7 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath(
155155
if (metrics.empty())
156156
continue;
157157

158-
CppAllMetricsAstNode nodeMetric;
158+
CppMetricsAstNodeAll nodeMetric;
159159
nodeMetric.id = std::to_string(node.id);
160160
nodeMetric.metrics = metrics;
161161
_return.push_back(nodeMetric);
@@ -164,7 +164,7 @@ void CppMetricsServiceHandler::getCppAstNodeMetricsForPath(
164164
}
165165

166166
void CppMetricsServiceHandler::getCppFileMetricsForPath(
167-
std::vector<CppAllMetricsModule>& _return,
167+
std::vector<CppMetricsModuleAll>& _return,
168168
const std::string& path_)
169169
{
170170
_transaction([&, this]()
@@ -188,9 +188,9 @@ void CppMetricsServiceHandler::getCppFileMetricsForPath(
188188
{
189189
CppFileMetricsResult metricsQuery = _db->query<model::CppFileMetrics>(
190190
CppFileMetricsQuery::file == file.id);
191-
std::vector<CppMetricsModule> metrics;
191+
std::vector<CppMetricsModuleSingle> metrics;
192192

193-
CppMetricsModule metricsModule;
193+
CppMetricsModuleSingle metricsModule;
194194
for (const auto& metric : metricsQuery)
195195
{
196196
metricsModule.type = static_cast<CppModuleMetricsType::type>(metric.type);
@@ -201,7 +201,7 @@ void CppMetricsServiceHandler::getCppFileMetricsForPath(
201201
if (metrics.empty())
202202
continue;
203203

204-
CppAllMetricsModule nodeMetric;
204+
CppMetricsModuleAll nodeMetric;
205205
nodeMetric.id = std::to_string(file.id);
206206
nodeMetric.metrics = metrics;
207207
_return.push_back(nodeMetric);

0 commit comments

Comments
 (0)