OSDN Git Service

qmake: Improve parser
authorTobias Hunger <tobias.hunger@nokia.com>
Thu, 25 Nov 2010 10:13:17 +0000 (11:13 +0100)
committerTobias Hunger <tobias.hunger@nokia.com>
Thu, 25 Nov 2010 10:14:39 +0000 (11:14 +0100)
Improve qmake parser to handle yet another way it marks up warnings.

Add unit test for this case.

src/plugins/qt4projectmanager/qmakeparser.cpp

index ec1d334..45ac265 100644 (file)
@@ -69,9 +69,17 @@ void QMakeParser::stdError(const QString &line)
         return;
     }
     if (m_error.indexIn(lne) > -1) {
-       emit addTask(Task(Task::Error,
+        QString fileName = QDir::fromNativeSeparators(m_error.cap(1));
+        Task::TaskType type = Task::Error;
+        if (fileName.startsWith("WARNING: ")) {
+            type = Task::Warning;
+            fileName = fileName.mid(9);
+        } else if (fileName.startsWith("ERROR: ")) {
+            fileName = fileName.mid(7);
+        }
+        emit addTask(Task(type,
                           m_error.cap(3) /* description */,
-                          QDir::fromNativeSeparators(m_error.cap(1)) /* file */,
+                          fileName,
                           m_error.cap(2).toInt() /* line */,
                           ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
         return;
@@ -146,6 +154,17 @@ void Qt4ProjectManagerPlugin::testQmakeOutputParsers_data()
                         QString(), -1,
                         ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))
             << QString();
+
+    QTest::newRow("qMake warning with location")
+            << QString::fromLatin1("WARNING: e:\\NokiaQtSDK\\Simulator\\Qt\\msvc2008\\lib\\qtmaind.prl:1: Unescaped backslashes are deprecated.")
+            << OutputParserTester::STDERR
+            << QString() << QString()
+            << (QList<ProjectExplorer::Task>()
+                << Task(Task::Warning,
+                        QLatin1String("Unescaped backslashes are deprecated."),
+                        QLatin1String("e:/NokiaQtSDK/Simulator/Qt/msvc2008/lib/qtmaind.prl"), 1,
+                        ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))
+            << QString();
 }
 
 void Qt4ProjectManagerPlugin::testQmakeOutputParsers()