forked from qt-creator/qt-creator
BareMetal: Improve IAR parser code a bit
It is makes sense to move a handing code of each regexp to the separate method to simplify maintenance. Change-Id: I59d9c23ec1c1c4dabb8de8eb295353b4df072a33 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -101,18 +101,12 @@ void IarParser::amendFilePath()
|
||||
m_expectFilePath = false;
|
||||
}
|
||||
|
||||
void IarParser::stdError(const QString &line)
|
||||
bool IarParser::parseErrorOrFatalErrorDetailsMessage1(const QString &lne)
|
||||
{
|
||||
IOutputParser::stdError(line);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
QRegularExpression re;
|
||||
QRegularExpressionMatch match;
|
||||
|
||||
re.setPattern("^(Error|Fatal error)\\[(.+)\\]:\\s(.+)\\s\\[(.+)$");
|
||||
match = re.match(lne);
|
||||
if (match.hasMatch()) {
|
||||
const QRegularExpression re("^(Error|Fatal error)\\[(.+)\\]:\\s(.+)\\s\\[(.+)$");
|
||||
const QRegularExpressionMatch match = re.match(lne);
|
||||
if (!match.hasMatch())
|
||||
return false;
|
||||
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex,
|
||||
DescriptionIndex, FilepathBeginIndex };
|
||||
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
||||
@@ -128,12 +122,15 @@ void IarParser::stdError(const QString &line)
|
||||
m_filePathParts.push_back(firstPart);
|
||||
m_expectFilePath = true;
|
||||
m_expectSnippet = false;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
re.setPattern("^.*(Error|Fatal error)\\[(.+)\\]:\\s(.+)$");
|
||||
match = re.match(lne);
|
||||
if (match.hasMatch()) {
|
||||
bool IarParser::parseErrorOrFatalErrorDetailsMessage2(const QString &lne)
|
||||
{
|
||||
const QRegularExpression re("^.*(Error|Fatal error)\\[(.+)\\]:\\s(.+)$");
|
||||
const QRegularExpressionMatch match = re.match(lne);
|
||||
if (!match.hasMatch())
|
||||
return false;
|
||||
enum CaptureIndex { MessageTypeIndex = 1, MessageCodeIndex,
|
||||
DescriptionIndex };
|
||||
const Task::TaskType type = taskType(match.captured(MessageTypeIndex));
|
||||
@@ -146,12 +143,15 @@ void IarParser::stdError(const QString &line)
|
||||
m_expectSnippet = true;
|
||||
m_expectFilePath = false;
|
||||
m_expectDescription = false;
|
||||
return;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
re.setPattern("^\"(.+)\",(\\d+)?\\s+(Warning|Error|Fatal error)\\[(.+)\\].+$");
|
||||
match = re.match(lne);
|
||||
if (match.hasMatch()) {
|
||||
bool IarParser::parseWarningOrErrorOrFatalErrorDetailsMessage1(const QString &lne)
|
||||
{
|
||||
const QRegularExpression re("^\"(.+)\",(\\d+)?\\s+(Warning|Error|Fatal error)\\[(.+)\\].+$");
|
||||
const QRegularExpressionMatch match = re.match(lne);
|
||||
if (!match.hasMatch())
|
||||
return false;
|
||||
enum CaptureIndex { FilePathIndex = 1, LineNumberIndex,
|
||||
MessageTypeIndex, MessageCodeIndex };
|
||||
const Utils::FilePath fileName = Utils::FilePath::fromUserInput(
|
||||
@@ -166,8 +166,31 @@ void IarParser::stdError(const QString &line)
|
||||
m_expectDescription = true;
|
||||
m_expectSnippet = false;
|
||||
m_expectFilePath = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IarParser::parseErrorInCommandLineMessage(const QString &lne)
|
||||
{
|
||||
if (!lne.startsWith("Error in command line"))
|
||||
return false;
|
||||
const Task task(Task::TaskType::Error, lne.trimmed(), {},
|
||||
-1, Constants::TASK_CATEGORY_COMPILE);
|
||||
newTask(task);
|
||||
return true;
|
||||
}
|
||||
|
||||
void IarParser::stdError(const QString &line)
|
||||
{
|
||||
IOutputParser::stdError(line);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
|
||||
if (parseErrorOrFatalErrorDetailsMessage1(lne))
|
||||
return;
|
||||
if (parseErrorOrFatalErrorDetailsMessage2(lne))
|
||||
return;
|
||||
if (parseWarningOrErrorOrFatalErrorDetailsMessage1(lne))
|
||||
return;
|
||||
}
|
||||
|
||||
if (lne.isEmpty()) {
|
||||
//
|
||||
@@ -201,12 +224,10 @@ void IarParser::stdOutput(const QString &line)
|
||||
IOutputParser::stdOutput(line);
|
||||
|
||||
const QString lne = rightTrimmed(line);
|
||||
if (!lne.startsWith("Error in command line"))
|
||||
|
||||
if (!parseErrorInCommandLineMessage(lne))
|
||||
return;
|
||||
|
||||
const Task task(Task::TaskType::Error, line.trimmed(), {},
|
||||
-1, Constants::TASK_CATEGORY_COMPILE);
|
||||
newTask(task);
|
||||
doFlush();
|
||||
}
|
||||
|
||||
|
@@ -46,6 +46,11 @@ private:
|
||||
void amendDescription();
|
||||
void amendFilePath();
|
||||
|
||||
bool parseErrorOrFatalErrorDetailsMessage1(const QString &lne);
|
||||
bool parseErrorOrFatalErrorDetailsMessage2(const QString &lne);
|
||||
bool parseWarningOrErrorOrFatalErrorDetailsMessage1(const QString &lne);
|
||||
bool parseErrorInCommandLineMessage(const QString &lne);
|
||||
|
||||
void stdError(const QString &line) final;
|
||||
void stdOutput(const QString &line) final;
|
||||
void doFlush() final;
|
||||
|
Reference in New Issue
Block a user