From ddb7f310fb31934c92f73da3ae0c4226f2689b76 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 May 2014 14:55:21 +0300 Subject: Add rule name and improve debuging info. --- src/lintmanager.cpp | 6 ++++-- src/rulebase.cpp | 2 ++ src/rulebase.h | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lintmanager.cpp b/src/lintmanager.cpp index 01c28e8..e7211b3 100644 --- a/src/lintmanager.cpp +++ b/src/lintmanager.cpp @@ -100,7 +100,7 @@ void LintManager::processFile(std::string fileName) void LintManager::applyRulesToFile() { - FOR_EACH (std::vector::iterator, it, mRules) + FOR_EACH (std::vector::iterator, it, mSelectedRules) { RuleBase *const rule = *it; int line = 0; @@ -142,6 +142,8 @@ void LintManager::selectRulesForFile() RuleBase *const rule = *it; if (isMatchFile(rule)) { +// printf("set file %s, for rule %s\n", +// mFileName.c_str(), rule->getName().c_str()); rule->setFile(mFileName); rule->init(); mSelectedRules.push_back(rule); @@ -151,7 +153,7 @@ void LintManager::selectRulesForFile() bool LintManager::isMatchFile(RuleBase *const rule) { -// printf("isMatchFile: %s\n", fileName.c_str()); +// printf("isMatchFile: %s\n", mFileName.c_str()); const std::set &masks = rule->getMasks(); FOR_EACH (std::set::const_iterator, it, masks) { diff --git a/src/rulebase.cpp b/src/rulebase.cpp index c5a795d..1d08986 100644 --- a/src/rulebase.cpp +++ b/src/rulebase.cpp @@ -34,6 +34,8 @@ RuleBase::RuleBase() : void RuleBase::print(const std::string &text) const { printf("[%s:%d]: %s\n", file.c_str(), line, text.c_str()); +// printf("%s [%s:%d]: %s\n", ruleName.c_str(), +// file.c_str(), line, text.c_str()); } void RuleBase::printRaw(const std::string &text) const diff --git a/src/rulebase.h b/src/rulebase.h index a92516b..5fa2f57 100644 --- a/src/rulebase.h +++ b/src/rulebase.h @@ -52,6 +52,12 @@ class RuleBase void setLine(const int line0) { line = line0; } + void setName(const std::string &name) + { ruleName = name; } + + std::string getName() const A_WARN_UNUSED + { return ruleName; } + protected: void print(const std::string &text) const; @@ -64,6 +70,7 @@ class RuleBase std::set mFileMasks; std::string file; + std::string ruleName; int line; }; -- cgit v1.2.3-60-g2f50