aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qtsupport/qtparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qtsupport/qtparser.cpp')
-rw-r--r--src/plugins/qtsupport/qtparser.cpp78
1 files changed, 46 insertions, 32 deletions
diff --git a/src/plugins/qtsupport/qtparser.cpp b/src/plugins/qtsupport/qtparser.cpp
index 7b01fb874d..7265f45c64 100644
--- a/src/plugins/qtsupport/qtparser.cpp
+++ b/src/plugins/qtsupport/qtparser.cpp
@@ -28,64 +28,74 @@
#include <projectexplorer/task.h>
#include <projectexplorer/projectexplorerconstants.h>
-using namespace QtSupport;
+#include <QFileInfo>
+
+#ifdef WITH_TESTS
+#include "qtsupportplugin.h"
+#include <projectexplorer/outputparser_test.h>
+#include <QTest>
+#endif
+
using namespace ProjectExplorer;
+namespace QtSupport {
+
// opt. drive letter + filename: (2 brackets)
#define FILE_PATTERN "^(([A-Za-z]:)?[^:]+\\.[^:]+)"
QtParser::QtParser() :
- m_mocRegExp(QLatin1String(FILE_PATTERN"[:\\(](\\d+)\\)?:\\s([Ww]arning|[Ee]rror|[Nn]ote):\\s(.+)$")),
- m_translationRegExp(QLatin1String("^([Ww]arning|[Ee]rror):\\s+(.*) in '(.*)'$"))
+ m_mocRegExp(QLatin1String(FILE_PATTERN"[:\\(](\\d+?)\\)?:\\s([Ww]arning|[Ee]rror|[Nn]ote):\\s(.+?)$")),
+ m_translationRegExp(QLatin1String("^([Ww]arning|[Ee]rror):\\s+(.*?) in '(.*?)'$"))
{
setObjectName(QLatin1String("QtParser"));
- m_mocRegExp.setMinimal(true);
- m_translationRegExp.setMinimal(true);
}
-void QtParser::stdError(const QString &line)
+Utils::OutputLineParser::Result QtParser::handleLine(const QString &line, Utils::OutputFormat type)
{
+ if (type != Utils::StdErrFormat)
+ return Status::NotHandled;
+
QString lne = rightTrimmed(line);
- if (m_mocRegExp.indexIn(lne) > -1) {
+ QRegularExpressionMatch match = m_mocRegExp.match(lne);
+ if (match.hasMatch()) {
bool ok;
- int lineno = m_mocRegExp.cap(3).toInt(&ok);
+ int lineno = match.captured(3).toInt(&ok);
if (!ok)
lineno = -1;
Task::TaskType type = Task::Error;
- const QString level = m_mocRegExp.cap(4);
+ const QString level = match.captured(4);
if (level.compare(QLatin1String("Warning"), Qt::CaseInsensitive) == 0)
type = Task::Warning;
if (level.compare(QLatin1String("Note"), Qt::CaseInsensitive) == 0)
type = Task::Unknown;
- CompileTask task(type, m_mocRegExp.cap(5).trimmed() /* description */,
- Utils::FilePath::fromUserInput(m_mocRegExp.cap(1)) /* filename */,
- lineno);
- emit addTask(task, 1);
- return;
+ LinkSpecs linkSpecs;
+ const Utils::FilePath file
+ = absoluteFilePath(Utils::FilePath::fromUserInput(match.captured(1)));
+ addLinkSpecForAbsoluteFilePath(linkSpecs, file, lineno, match, 1);
+ CompileTask task(type, match.captured(5).trimmed() /* description */, file, lineno);
+ scheduleTask(task, 1);
+ return {Status::Done, linkSpecs};
}
- if (m_translationRegExp.indexIn(lne) > -1) {
+ match = m_translationRegExp.match(line);
+ if (match.hasMatch()) {
Task::TaskType type = Task::Warning;
- if (m_translationRegExp.cap(1) == QLatin1String("Error"))
+ if (match.captured(1) == QLatin1String("Error"))
type = Task::Error;
- CompileTask task(type, m_translationRegExp.cap(2),
- Utils::FilePath::fromUserInput(m_translationRegExp.cap(3)));
- emit addTask(task, 1);
- return;
+ LinkSpecs linkSpecs;
+ const Utils::FilePath file
+ = absoluteFilePath(Utils::FilePath::fromUserInput(match.captured(3)));
+ addLinkSpecForAbsoluteFilePath(linkSpecs, file, 0, match, 3);
+ CompileTask task(type, match.captured(2), file);
+ scheduleTask(task, 1);
+ return {Status::Done, linkSpecs};
}
- IOutputParser::stdError(line);
+ return Status::NotHandled;
}
// Unit tests:
#ifdef WITH_TESTS
-# include <QTest>
-
-# include "qtsupportplugin.h"
-# include <projectexplorer/projectexplorerconstants.h>
-# include <projectexplorer/outputparser_test.h>
-
-using namespace ProjectExplorer;
-using namespace QtSupport::Internal;
+namespace Internal {
void QtSupportPlugin::testQtOutputParser_data()
{
@@ -136,7 +146,7 @@ void QtSupportPlugin::testQtOutputParser_data()
<< QString() << QString()
<< (Tasks() << CompileTask(Task::Warning,
QLatin1String("No relevant classes found. No output generated."),
- Utils::FilePath::fromUserInput(QLatin1String("..\\untitled\\errorfile.h")), 0))
+ Utils::FilePath::fromUserInput(QLatin1String("..\\untitled\\errorfile.h")), -1))
<< QString();
QTest::newRow("moc warning 2")
<< QString::fromLatin1("c:\\code\\test.h(96): Warning: Property declaration ) has no READ accessor function. The property will be invalid.")
@@ -152,7 +162,7 @@ void QtSupportPlugin::testQtOutputParser_data()
<< QString() << QString()
<< (Tasks() << CompileTask(Task::Unknown,
QLatin1String("No relevant classes found. No output generated."),
- Utils::FilePath::fromUserInput(QLatin1String("/home/qtwebkithelpviewer.h")), 0))
+ Utils::FilePath::fromUserInput(QLatin1String("/home/qtwebkithelpviewer.h")), -1))
<< QString();
QTest::newRow("ninja with moc")
<< QString::fromLatin1("E:/sandbox/creator/loaden/src/libs/utils/iwelcomepage.h(54): Error: Undefined interface")
@@ -175,7 +185,7 @@ void QtSupportPlugin::testQtOutputParser_data()
void QtSupportPlugin::testQtOutputParser()
{
OutputParserTester testbench;
- testbench.appendOutputParser(new QtParser);
+ testbench.addLineParser(new QtParser);
QFETCH(QString, input);
QFETCH(OutputParserTester::Channel, inputChannel);
QFETCH(Tasks, tasks);
@@ -185,4 +195,8 @@ void QtSupportPlugin::testQtOutputParser()
testbench.testParsing(input, inputChannel, tasks, childStdOutLines, childStdErrLines, outputLines);
}
+
+} // namespace Internal
#endif
+
+} // namespace QtSupport