summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-24 14:55:21 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-24 14:55:21 +0300
commitddb7f310fb31934c92f73da3ae0c4226f2689b76 (patch)
treec330260d9082f3ca32aefb9c6c9c3c30f6523341
parentcb343652934540050a4da3f9a8446463db37b98b (diff)
downloadmplint-ddb7f310fb31934c92f73da3ae0c4226f2689b76.tar.gz
mplint-ddb7f310fb31934c92f73da3ae0c4226f2689b76.tar.bz2
mplint-ddb7f310fb31934c92f73da3ae0c4226f2689b76.tar.xz
mplint-ddb7f310fb31934c92f73da3ae0c4226f2689b76.zip
Add rule name and improve debuging info.
-rw-r--r--src/lintmanager.cpp6
-rw-r--r--src/rulebase.cpp2
-rw-r--r--src/rulebase.h7
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<RuleBase*>::iterator, it, mRules)
+ FOR_EACH (std::vector<RuleBase*>::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<std::string> &masks = rule->getMasks();
FOR_EACH (std::set<std::string>::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<std::string> mFileMasks;
std::string file;
+ std::string ruleName;
int line;
};