aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qt4projectmanager/qt-s60/rvctparser.cpp
blob: a648cb63a88a33acfe0e2adffa1b38a6522ba672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/

#include "rvctparser.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/taskwindow.h>

#include <QtCore/QDir>

using namespace ProjectExplorer;
using namespace ProjectExplorer::Constants;
using namespace Qt4ProjectManager;

RvctParser::RvctParser() :
    m_task(0)
{
    setObjectName(QLatin1String("RvctParser"));
    // Start of a error or warning:
    m_warningOrError.setPattern("^\"([^\\(\\)]+[^\\d])\", line (\\d+):(\\s(Warning|Error):)\\s+([^\\s].*)$");
    m_warningOrError.setMinimal(true);

    // Last message for any file with warnings/errors.
    m_wrapUpTask.setPattern("^([^\\(\\)]+[^\\d]):\\s(\\d+) warnings?,\\s(\\d+) errors?$");
    m_wrapUpTask.setMinimal(true);

    // linker problems:
    m_genericProblem.setPattern("^(Error|Warning): (.*)$");
    m_genericProblem.setMinimal(true);
}

RvctParser::~RvctParser()
{
    sendTask();
}

void RvctParser::stdError(const QString &line)
{
    QString lne = line.trimmed();
    if (m_genericProblem.indexIn(lne) > -1) {
        sendTask();

        m_task = new Task(Task::Error,
                          m_genericProblem.cap(2) /* description */,
                          QString(),
                          -1 /* linenumber */,
                          TASK_CATEGORY_COMPILE);
        if (m_warningOrError.cap(4) == "Warning")
            m_task->type = Task::Warning;
        else if (m_warningOrError.cap(4) == "Error")
            m_task->type = Task::Error;

        return;
   }
   if (m_warningOrError.indexIn(lne) > -1) {
       sendTask();

       m_task = new Task(Task::Unknown,
                         m_warningOrError.cap(5) /* description */,
                         QDir::fromNativeSeparators(m_warningOrError.cap(1)) /* file */,
                         m_warningOrError.cap(2).toInt() /* line */,
                         TASK_CATEGORY_COMPILE);
       if (m_warningOrError.cap(4) == "Warning")
           m_task->type = Task::Warning;
       else if (m_warningOrError.cap(4) == "Error")
           m_task->type = Task::Error;
       return;
   }

   if (m_wrapUpTask.indexIn(lne) > -1) {
       sendTask();
       return;
   }
   if (m_task) {
       QString description = line;
       if (description.startsWith(QLatin1String("  ")))
           description = description.mid(2);
       if (description.endsWith('\n'))
           description.chop(1);
       if (m_task->formats.isEmpty()) {
           QTextLayout::FormatRange fr;
           fr.start = m_task->description.count(); // incl. '\n' we are about to add!
           fr.length = description.count() - 1;
           fr.format.setFontItalic(true);
           m_task->formats.append(fr);
       } else {
           m_task->formats[0].length += description.count() - 2 + 1;
       }
       m_task->description += QLatin1Char('\n') + description;

       // Wrap up license error:
       if (description.endsWith(QLatin1String("at \"www.macrovision.com\".")))
           sendTask();

       return;
   }
   IOutputParser::stdError(line);
}

void RvctParser::sendTask()
{
    if (!m_task)
        return;
    emit addTask(*m_task);
    delete m_task;
    m_task = 0;
}

// Unit tests:

#ifdef WITH_TESTS
#   include <QTest>

#   include "qt4projectmanagerplugin.h"
#   include <projectexplorer/metatypedeclarations.h>
#   include <projectexplorer/outputparser_test.h>

using namespace Qt4ProjectManager::Internal;

void Qt4ProjectManagerPlugin::testRvctOutputParser_data()
{
    QTest::addColumn<QString>("input");
    QTest::addColumn<OutputParserTester::Channel>("inputChannel");
    QTest::addColumn<QString>("childStdOutLines");
    QTest::addColumn<QString>("childStdErrLines");
    QTest::addColumn<QList<ProjectExplorer::Task> >("tasks");
    QTest::addColumn<QString>("outputLines");


    QTest::newRow("pass-through stdout")
            << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT
            << QString::fromLatin1("Sometext") << QString()
            << QList<ProjectExplorer::Task>()
            << QString();
    QTest::newRow("pass-through stderr")
            << QString::fromLatin1("Sometext") << OutputParserTester::STDERR
            << QString() << QString::fromLatin1("Sometext")
            << QList<ProjectExplorer::Task>()
            << QString();

    QTest::newRow("Rvct warning")
            << QString::fromLatin1("\"../../../../s60-sdk/epoc32/include/stdapis/stlport/stl/_limits.h\", line 256: Warning:  #68-D: integer conversion resulted in a change of sign\n"
                                   "    : public _Integer_limits<char, CHAR_MIN, CHAR_MAX, -1, true>\n"
                                   "                                   ^")
            << OutputParserTester::STDERR
            << QString() << QString()
            << (QList<ProjectExplorer::Task>()
                << Task(Task::Warning,
                        QLatin1String("#68-D: integer conversion resulted in a change of sign\n"
                                      "  : public _Integer_limits<char, CHAR_MIN, CHAR_MAX, -1, true>\n"
                                      "                                 ^"),
                        QLatin1String("../../../../s60-sdk/epoc32/include/stdapis/stlport/stl/_limits.h"), 256,
                        Constants::TASK_CATEGORY_COMPILE)
                )
            << QString();
    QTest::newRow("Rvct error")
            << QString::fromLatin1("\"mainwindow.cpp\", line 22: Error:  #20: identifier \"e\" is undefined\n"
                                   "      delete ui;e\n"
                                   "                ^")
            << OutputParserTester::STDERR
            << QString() << QString()
            << (QList<ProjectExplorer::Task>()
                << Task(Task::Error,
                        QLatin1String("#20: identifier \"e\" is undefined\n"
                                      "    delete ui;e\n"
                                      "              ^"),
                        QLatin1String("mainwindow.cpp"), 22,
                        Constants::TASK_CATEGORY_COMPILE)
                )
            << QString();
    QTest::newRow("Rvct linking error")
            << QString::fromLatin1("Error: L6218E: Undefined symbol MainWindow::sth() (referred from mainwindow.o)")
            << OutputParserTester::STDERR
            << QString() << QString()
            << (QList<ProjectExplorer::Task>()
                << Task(Task::Error,
                        QLatin1String("L6218E: Undefined symbol MainWindow::sth() (referred from mainwindow.o)"),
                        QString(), -1,
                        Constants::TASK_CATEGORY_COMPILE)
                )
            << QString();
    QTest::newRow("Rvct license error")
            << QString::fromLatin1("Error: C3397E: Cannot obtain license for Compiler (feature compiler) with license version >= 2.2:\n"
                                   "Cannot find license file.\n"
                                   " The license files (or license server system network addresses) attempted are \n"
                                   "listed below.  Use LM_LICENSE_FILE to use a different license file,\n"
                                   " or contact your software provider for a license file.\n"
                                   "Feature:       compiler\n"
                                   "Filename:      /usr/local/flexlm/licenses/license.dat\n"
                                   "License path:  /usr/local/flexlm/licenses/license.dat\n"
                                   "FLEXnet Licensing error:-1,359.  System Error: 2 \"No such file or directory\"\n"
                                   "For further information, refer to the FLEXnet Licensing End User Guide,\n"
                                   "available at \"www.macrovision.com\".")
            << OutputParserTester::STDERR
            << QString() << QString()
            << (QList<ProjectExplorer::Task>()
                << Task(Task::Error,
                        QLatin1String("C3397E: Cannot obtain license for Compiler (feature compiler) with license version >= 2.2:\n"
                                      "Cannot find license file.\n"
                                      " The license files (or license server system network addresses) attempted are \n"
                                      "listed below.  Use LM_LICENSE_FILE to use a different license file,\n"
                                      " or contact your software provider for a license file.\n"
                                      "Feature:       compiler\n"
                                      "Filename:      /usr/local/flexlm/licenses/license.dat\n"
                                      "License path:  /usr/local/flexlm/licenses/license.dat\n"
                                      "FLEXnet Licensing error:-1,359.  System Error: 2 \"No such file or directory\"\n"
                                      "For further information, refer to the FLEXnet Licensing End User Guide,\n"
                                      "available at \"www.macrovision.com\"."),
                        QString(), -1,
                        Constants::TASK_CATEGORY_COMPILE)
                )
            << QString();
}

void Qt4ProjectManagerPlugin::testRvctOutputParser()
{
    OutputParserTester testbench;
    testbench.appendOutputParser(new RvctParser);
    QFETCH(QString, input);
    QFETCH(OutputParserTester::Channel, inputChannel);
    QFETCH(QList<Task>, tasks);
    QFETCH(QString, childStdOutLines);
    QFETCH(QString, childStdErrLines);
    QFETCH(QString, outputLines);

    testbench.testParsing(input, inputChannel,
                          tasks, childStdOutLines, childStdErrLines,
                          outputLines);
}
#endif