forked from qt-creator/qt-creator
Output parsers: Replace the chaining approach
Use "flat" aggregation instead. This is another step towards the formatter/parser merger. Along the way, also fix some some subclasses (mostly in BareMetal) that erroneously forwarded handled output to other parsers. Task-number: QTCREATORBUG-22665 Change-Id: I12947349ca663d2e6bbfc99efd069d69e2b54969 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -112,9 +112,7 @@ bool AndroidPackageInstallationStep::init()
|
||||
pp->setCommandLine(cmd);
|
||||
|
||||
setOutputParser(new GnuMakeParser());
|
||||
IOutputParser *parser = target()->kit()->createOutputParser();
|
||||
if (parser)
|
||||
appendOutputParser(parser);
|
||||
appendOutputParsers(target()->kit()->createOutputParsers());
|
||||
outputParser()->addSearchDir(pp->effectiveWorkingDirectory());
|
||||
|
||||
m_androidDirsToClean.clear();
|
||||
|
||||
@@ -51,39 +51,33 @@ void JavaParser::setSourceDirectory(const Utils::FilePath &sourceDirectory)
|
||||
m_sourceDirectory = sourceDirectory;
|
||||
}
|
||||
|
||||
void JavaParser::handleLine(const QString &line, Utils::OutputFormat type)
|
||||
IOutputParser::Status JavaParser::doHandleLine(const QString &line, Utils::OutputFormat type)
|
||||
{
|
||||
parse(line);
|
||||
IOutputParser::handleLine(line, type);
|
||||
}
|
||||
Q_UNUSED(type);
|
||||
if (m_javaRegExp.indexIn(line) == -1)
|
||||
return Status::NotHandled;
|
||||
|
||||
void JavaParser::parse(const QString &line)
|
||||
{
|
||||
if (m_javaRegExp.indexIn(line) > -1) {
|
||||
bool ok;
|
||||
int lineno = m_javaRegExp.cap(3).toInt(&ok);
|
||||
if (!ok)
|
||||
lineno = -1;
|
||||
Utils::FilePath file = Utils::FilePath::fromUserInput(m_javaRegExp.cap(2));
|
||||
if (file.isChildOf(m_buildDirectory)) {
|
||||
Utils::FilePath relativePath = file.relativeChildPath(m_buildDirectory);
|
||||
file = m_sourceDirectory.pathAppended(relativePath.toString());
|
||||
}
|
||||
|
||||
if (file.toFileInfo().isRelative()) {
|
||||
for (int i = 0; i < m_fileList.size(); i++)
|
||||
if (m_fileList[i].endsWith(file.toString())) {
|
||||
file = Utils::FilePath::fromString(m_fileList[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CompileTask task(Task::Error,
|
||||
m_javaRegExp.cap(4).trimmed(),
|
||||
absoluteFilePath(file),
|
||||
lineno);
|
||||
emit addTask(task, 1);
|
||||
return;
|
||||
bool ok;
|
||||
int lineno = m_javaRegExp.cap(3).toInt(&ok);
|
||||
if (!ok)
|
||||
lineno = -1;
|
||||
Utils::FilePath file = Utils::FilePath::fromUserInput(m_javaRegExp.cap(2));
|
||||
if (file.isChildOf(m_buildDirectory)) {
|
||||
Utils::FilePath relativePath = file.relativeChildPath(m_buildDirectory);
|
||||
file = m_sourceDirectory.pathAppended(relativePath.toString());
|
||||
}
|
||||
if (file.toFileInfo().isRelative()) {
|
||||
for (int i = 0; i < m_fileList.size(); i++)
|
||||
if (m_fileList[i].endsWith(file.toString())) {
|
||||
file = Utils::FilePath::fromString(m_fileList[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CompileTask task(Task::Error,
|
||||
m_javaRegExp.cap(4).trimmed(),
|
||||
absoluteFilePath(file),
|
||||
lineno);
|
||||
emit addTask(task, 1);
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,7 @@ public:
|
||||
void setSourceDirectory(const Utils::FilePath &sourceDirectory);
|
||||
|
||||
private:
|
||||
void handleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
void parse(const QString &line);
|
||||
Status doHandleLine(const QString &line, Utils::OutputFormat type) override;
|
||||
|
||||
QRegExp m_javaRegExp;
|
||||
QStringList m_fileList;
|
||||
|
||||
Reference in New Issue
Block a user