OSDN Git Service

ApplicationOutput: Also linkify qml errors without column.
authorKai Koehne <kai.koehne@nokia.com>
Mon, 8 Nov 2010 13:55:50 +0000 (14:55 +0100)
committerKai Koehne <kai.koehne@nokia.com>
Mon, 8 Nov 2010 14:42:39 +0000 (15:42 +0100)
I didn't manage to find one regular expression that matches both lines with and
without column correctly. Instead use two distinct ones ...

Task-number: QTCREATORBUG-3022

src/plugins/qt4projectmanager/qtoutputformatter.cpp

index 4917a93..c993cf2 100644 (file)
@@ -42,7 +42,10 @@ using namespace Qt4ProjectManager;
 
 QtOutputFormatter::QtOutputFormatter(ProjectExplorer::Project *project)
     : OutputFormatter()
-    , m_qmlError(QLatin1String("(file:///.+:\\d+:\\d+):"))
+    , m_qmlError(QLatin1String("^(file:///.+"    // file url
+                               ":\\d+"           // colon, line
+                               "(?::\\d+)?)"     // colon, column (optional)
+                               ":"))             // colon
     , m_qtError(QLatin1String("Object::.*in (.*:\\d+)"))
     , m_qtAssert(QLatin1String("^ASSERT: .* in file (.+, line \\d+)$"))
     , m_qtTestFail(QLatin1String("^   Loc: \\[(.*)\\]$"))
@@ -176,16 +179,28 @@ void QtOutputFormatter::appendLine(QTextCursor &cursor, LinkResult lr, const QSt
 void QtOutputFormatter::handleLink(const QString &href)
 {
     if (!href.isEmpty()) {
-        const QRegExp qmlErrorLink(QLatin1String("^(file:///.+):(\\d+):(\\d+)"));
-
-        if (qmlErrorLink.indexIn(href) != -1) {
-            const QString fileName = QUrl(qmlErrorLink.cap(1)).toLocalFile();
-            const int line = qmlErrorLink.cap(2).toInt();
-            const int column = qmlErrorLink.cap(3).toInt();
+        const QRegExp qmlLineColumnLink(QLatin1String("^(file:///.+)" // file url
+                                                 ":(\\d+)"            // line
+                                                 ":(\\d+)$"));        // column
+
+        if (qmlLineColumnLink.indexIn(href) != -1) {
+            const QString fileName = QUrl(qmlLineColumnLink.cap(1)).toLocalFile();
+            const int line = qmlLineColumnLink.cap(2).toInt();
+            const int column = qmlLineColumnLink.cap(3).toInt();
             TextEditor::BaseTextEditor::openEditorAt(fileName, line, column - 1);
             return;
         }
 
+        const QRegExp qmlLineLink(QLatin1String("^(file:///.+)" // file url
+                                                 ":(\\d+)$"));  // line
+
+        if (qmlLineLink.indexIn(href) != -1) {
+            const QString fileName = QUrl(qmlLineLink.cap(1)).toLocalFile();
+            const int line = qmlLineLink.cap(2).toInt();
+            TextEditor::BaseTextEditor::openEditorAt(fileName, line);
+            return;
+        }
+
         QString fileName;
         int line = -1;