File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
plugins/cpp_metrics/parser/include/cppmetricsparser Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,16 @@ class AbstractParser
44
44
* @return Returns true if the parse succeeded, false otherwise.
45
45
*/
46
46
virtual bool parse () = 0;
47
+ /* *
48
+ * Returns true in case database indices are required for the parser, due to performance reasons.
49
+ *
50
+ * Should return the same value on each call for the same object.
51
+ * @return
52
+ */
53
+ virtual bool isDatabaseIndexRequired () const
54
+ {
55
+ return false ;
56
+ }
47
57
48
58
protected:
49
59
ParserContext& _ctx;
Original file line number Diff line number Diff line change @@ -411,18 +411,33 @@ int main(int argc, char* argv[])
411
411
incrementalCleanup (ctx);
412
412
}
413
413
414
+ std::vector<std::string> afterIndexingPlugins;
415
+
414
416
// TODO: Handle errors returned by parse().
415
417
for (const std::string& pluginName : pluginNames)
416
418
{
417
- LOG (info) << " [" << pluginName << " ] parse started!" ;
418
- pHandler.getParser (pluginName)->parse ();
419
+ auto plugin = pHandler.getParser (pluginName);
420
+ if (!plugin->isDatabaseIndexRequired ())
421
+ {
422
+ LOG (info) << " [" << pluginName << " ] parse started!" ;
423
+ plugin->parse ();
424
+ }
425
+ else {
426
+ afterIndexingPlugins.push_back (pluginName);
427
+ }
419
428
}
420
429
421
430
// --- Add indexes to the database ---//
422
431
423
432
if (vm.count (" force" ) || isNewDb)
424
433
cc::util::createIndexes (db, SQL_DIR);
425
434
435
+ for (const std::string& pluginName : afterIndexingPlugins)
436
+ {
437
+ LOG (info) << " [" << pluginName << " ] parse started!" ;
438
+ pHandler.getParser (pluginName)->parse ();
439
+ }
440
+
426
441
// --- Create project config file ---//
427
442
428
443
boost::property_tree::ptree pt;
Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ class CppMetricsParser : public AbstractParser
59
59
virtual bool cleanupDatabase () override ;
60
60
virtual bool parse () override ;
61
61
62
+ virtual bool isDatabaseIndexRequired () const override
63
+ {
64
+ return true ;
65
+ }
66
+
62
67
private:
63
68
// Calculate the count of parameters for every function.
64
69
void functionParameters ();
You can’t perform that action at this time.
0 commit comments