GUI: Split up parsers for addons/clang
This commit is contained in:
parent
ac08e216a4
commit
14efd2fdf5
|
@ -109,8 +109,7 @@ void CheckThread::run()
|
||||||
qDebug() << cmd;
|
qDebug() << cmd;
|
||||||
process.start(cmd);
|
process.start(cmd);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
QString err(process.readAllStandardError());
|
parseAddonErrors(process.readAllStandardError(), addon);
|
||||||
parseErrors(err, addon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit fileChecked(file);
|
emit fileChecked(file);
|
||||||
|
@ -145,6 +144,7 @@ void CheckThread::run()
|
||||||
qDebug() << cmd;
|
qDebug() << cmd;
|
||||||
process.start(cmd);
|
process.start(cmd);
|
||||||
process.waitForFinished(600*1000);
|
process.waitForFinished(600*1000);
|
||||||
|
parseClangErrors(process.readAllStandardError());
|
||||||
} else {
|
} else {
|
||||||
QString a;
|
QString a;
|
||||||
if (QFileInfo(addonPath + '/' + addon + ".py").exists())
|
if (QFileInfo(addonPath + '/' + addon + ".py").exists())
|
||||||
|
@ -158,9 +158,8 @@ void CheckThread::run()
|
||||||
qDebug() << cmd;
|
qDebug() << cmd;
|
||||||
process.start(cmd);
|
process.start(cmd);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
|
parseAddonErrors(process.readAllStandardError(), addon);
|
||||||
}
|
}
|
||||||
QString err(process.readAllStandardError());
|
|
||||||
parseErrors(err, addon);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit fileChecked(file);
|
emit fileChecked(file);
|
||||||
|
@ -183,45 +182,49 @@ void CheckThread::stop()
|
||||||
mCppcheck.terminate();
|
mCppcheck.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckThread::parseErrors(QString err, QString tool)
|
void CheckThread::parseAddonErrors(QString err, QString tool)
|
||||||
{
|
{
|
||||||
QTextStream in(&err, QIODevice::ReadOnly);
|
QTextStream in(&err, QIODevice::ReadOnly);
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
QString line = in.readLine();
|
QString line = in.readLine();
|
||||||
|
QRegExp r1("\\[([^:]+):([0-9]+)\\](.*)");
|
||||||
|
if (!r1.exactMatch(line))
|
||||||
|
continue;
|
||||||
|
const std::string &filename = r1.cap(1).toStdString();
|
||||||
|
const int lineNumber = r1.cap(2).toInt();
|
||||||
|
|
||||||
if (tool == "clang") {
|
std::string message, id;
|
||||||
QRegExp r("([^:]+):([0-9]+):[0-9]+: (warning|error): (.*)");
|
QRegExp r2("(.*)\\[([a-zA-Z0-9\\-\\._]+)\\]");
|
||||||
if (!r.exactMatch(line))
|
if (r2.exactMatch(r1.cap(3))) {
|
||||||
continue;
|
message = r2.cap(1).toStdString();
|
||||||
const std::string filename = r.cap(1).toStdString();
|
id = tool.toStdString() + '-' + r2.cap(2).toStdString();
|
||||||
const int lineNumber = r.cap(2).toInt();
|
|
||||||
Severity::SeverityType severity = (r.cap(3) == "error") ? Severity::error : Severity::warning;
|
|
||||||
const std::string message = r.cap(4).toStdString();
|
|
||||||
const std::string id = tool.toStdString();
|
|
||||||
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
|
|
||||||
callstack.push_back(ErrorLogger::ErrorMessage::FileLocation(filename, lineNumber));
|
|
||||||
ErrorLogger::ErrorMessage errmsg(callstack, filename, severity, message, id, false);
|
|
||||||
mResult.reportErr(errmsg);
|
|
||||||
} else {
|
} else {
|
||||||
QRegExp r1("\\[([^:]+):([0-9]+)\\](.*)");
|
message = r1.cap(3).toStdString();
|
||||||
if (!r1.exactMatch(line))
|
id = tool.toStdString();
|
||||||
continue;
|
|
||||||
const std::string &filename = r1.cap(1).toStdString();
|
|
||||||
const int lineNumber = r1.cap(2).toInt();
|
|
||||||
|
|
||||||
std::string message, id;
|
|
||||||
QRegExp r2("(.*)\\[([a-zA-Z0-9\\-\\._]+)\\]");
|
|
||||||
if (r2.exactMatch(r1.cap(3))) {
|
|
||||||
message = r2.cap(1).toStdString();
|
|
||||||
id = tool.toStdString() + '-' + r2.cap(2).toStdString();
|
|
||||||
} else {
|
|
||||||
message = r1.cap(3).toStdString();
|
|
||||||
id = tool.toStdString();
|
|
||||||
}
|
|
||||||
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
|
|
||||||
callstack.push_back(ErrorLogger::ErrorMessage::FileLocation(filename, lineNumber));
|
|
||||||
ErrorLogger::ErrorMessage errmsg(callstack, filename, Severity::style, message, id, false);
|
|
||||||
mResult.reportErr(errmsg);
|
|
||||||
}
|
}
|
||||||
|
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
|
||||||
|
callstack.push_back(ErrorLogger::ErrorMessage::FileLocation(filename, lineNumber));
|
||||||
|
ErrorLogger::ErrorMessage errmsg(callstack, filename, Severity::style, message, id, false);
|
||||||
|
mResult.reportErr(errmsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckThread::parseClangErrors(QString err)
|
||||||
|
{
|
||||||
|
QTextStream in(&err, QIODevice::ReadOnly);
|
||||||
|
while (!in.atEnd()) {
|
||||||
|
QString line = in.readLine();
|
||||||
|
QRegExp r("([^:]+):([0-9]+):[0-9]+: (warning|error): (.*)");
|
||||||
|
if (!r.exactMatch(line))
|
||||||
|
continue;
|
||||||
|
const std::string filename = r.cap(1).toStdString();
|
||||||
|
const int lineNumber = r.cap(2).toInt();
|
||||||
|
Severity::SeverityType severity = (r.cap(3) == "error") ? Severity::error : Severity::warning;
|
||||||
|
const std::string message = r.cap(4).toStdString();
|
||||||
|
const std::string id = "clang";
|
||||||
|
std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;
|
||||||
|
callstack.push_back(ErrorLogger::ErrorMessage::FileLocation(filename, lineNumber));
|
||||||
|
ErrorLogger::ErrorMessage errmsg(callstack, filename, severity, message, id, false);
|
||||||
|
mResult.reportErr(errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,8 @@ protected:
|
||||||
CppCheck mCppcheck;
|
CppCheck mCppcheck;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseErrors(QString err, QString tool);
|
void parseAddonErrors(QString err, QString tool);
|
||||||
|
void parseClangErrors(QString err);
|
||||||
|
|
||||||
QStringList mFiles;
|
QStringList mFiles;
|
||||||
bool mAnalyseWholeProgram;
|
bool mAnalyseWholeProgram;
|
||||||
|
|
Loading…
Reference in New Issue