| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlerror.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | #include "qqmlerror.h" | - | ||||||||||||||||||
| 41 | #include "qqmlglobal_p.h" | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | #include <QtCore/qdebug.h> | - | ||||||||||||||||||
| 44 | #include <QtCore/qfile.h> | - | ||||||||||||||||||
| 45 | #include <QtCore/qstringlist.h> | - | ||||||||||||||||||
| 46 | #include <QtCore/qvector.h> | - | ||||||||||||||||||
| 47 | #include <QtCore/qpointer.h> | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | #include <private/qv4errorobject_p.h> | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | /*! | - | ||||||||||||||||||
| 54 | \class QQmlError | - | ||||||||||||||||||
| 55 | \since 5.0 | - | ||||||||||||||||||
| 56 | \inmodule QtQml | - | ||||||||||||||||||
| 57 | \brief The QQmlError class encapsulates a QML error. | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | QQmlError includes a textual description of the error, as well | - | ||||||||||||||||||
| 60 | as location information (the file, line, and column). The toString() | - | ||||||||||||||||||
| 61 | method creates a single-line, human-readable string containing all of | - | ||||||||||||||||||
| 62 | this information, for example: | - | ||||||||||||||||||
| 63 | \code | - | ||||||||||||||||||
| 64 | file:///home/user/test.qml:7:8: Invalid property assignment: double expected | - | ||||||||||||||||||
| 65 | \endcode | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | You can use qDebug(), qInfo(), or qWarning() to output errors to the console. | - | ||||||||||||||||||
| 68 | This method will attempt to open the file indicated by the error | - | ||||||||||||||||||
| 69 | and include additional contextual information. | - | ||||||||||||||||||
| 70 | \code | - | ||||||||||||||||||
| 71 | file:///home/user/test.qml:7:8: Invalid property assignment: double expected | - | ||||||||||||||||||
| 72 | y: "hello" | - | ||||||||||||||||||
| 73 | ^ | - | ||||||||||||||||||
| 74 | \endcode | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | Note that the \l {Qt Quick 1} version is named QDeclarativeError | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | \sa QQuickView::errors(), QQmlComponent::errors() | - | ||||||||||||||||||
| 79 | */ | - | ||||||||||||||||||
| 80 | class QQmlErrorPrivate | - | ||||||||||||||||||
| 81 | { | - | ||||||||||||||||||
| 82 | public: | - | ||||||||||||||||||
| 83 | QQmlErrorPrivate(); | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | QUrl url; | - | ||||||||||||||||||
| 86 | QString description; | - | ||||||||||||||||||
| 87 | quint16 line; | - | ||||||||||||||||||
| 88 | quint16 column; | - | ||||||||||||||||||
| 89 | QtMsgType messageType; | - | ||||||||||||||||||
| 90 | QPointer<QObject> object; | - | ||||||||||||||||||
| 91 | }; | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | QQmlErrorPrivate::QQmlErrorPrivate() | - | ||||||||||||||||||
| 94 | : line(0), column(0), messageType(QtMsgType::QtWarningMsg), object() | - | ||||||||||||||||||
| 95 | { | - | ||||||||||||||||||
| 96 | } executed 586834 times by 92 tests: end of blockExecuted by:
| 586834 | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | /*! | - | ||||||||||||||||||
| 99 | Creates an empty error object. | - | ||||||||||||||||||
| 100 | */ | - | ||||||||||||||||||
| 101 | QQmlError::QQmlError() | - | ||||||||||||||||||
| 102 | : d(nullptr) | - | ||||||||||||||||||
| 103 | { | - | ||||||||||||||||||
| 104 | } executed 293524 times by 92 tests: end of blockExecuted by:
| 293524 | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | /*! | - | ||||||||||||||||||
| 107 | Creates a copy of \a other. | - | ||||||||||||||||||
| 108 | */ | - | ||||||||||||||||||
| 109 | QQmlError::QQmlError(const QQmlError &other) | - | ||||||||||||||||||
| 110 | : d(nullptr) | - | ||||||||||||||||||
| 111 | { | - | ||||||||||||||||||
| 112 | *this = other; | - | ||||||||||||||||||
| 113 | } executed 293838 times by 91 tests: end of blockExecuted by:
| 293838 | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | /*! | - | ||||||||||||||||||
| 116 | Assigns \a other to this error object. | - | ||||||||||||||||||
| 117 | */ | - | ||||||||||||||||||
| 118 | QQmlError &QQmlError::operator=(const QQmlError &other) | - | ||||||||||||||||||
| 119 | { | - | ||||||||||||||||||
| 120 | if (!other.d) {
| 364-294384 | ||||||||||||||||||
| 121 | delete d; | - | ||||||||||||||||||
| 122 | d = nullptr; | - | ||||||||||||||||||
| 123 | } else { executed 364 times by 15 tests: end of blockExecuted by:
| 364 | ||||||||||||||||||
| 124 | if (!d)
| 4-294380 | ||||||||||||||||||
| 125 | d = new QQmlErrorPrivate; executed 294380 times by 91 tests: d = new QQmlErrorPrivate;Executed by:
| 294380 | ||||||||||||||||||
| 126 | d->url = other.d->url; | - | ||||||||||||||||||
| 127 | d->description = other.d->description; | - | ||||||||||||||||||
| 128 | d->line = other.d->line; | - | ||||||||||||||||||
| 129 | d->column = other.d->column; | - | ||||||||||||||||||
| 130 | d->object = other.d->object; | - | ||||||||||||||||||
| 131 | d->messageType = other.d->messageType; | - | ||||||||||||||||||
| 132 | } executed 294384 times by 91 tests: end of blockExecuted by:
| 294384 | ||||||||||||||||||
| 133 | return *this; executed 294748 times by 91 tests: return *this;Executed by:
| 294748 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | /*! | - | ||||||||||||||||||
| 137 | \internal | - | ||||||||||||||||||
| 138 | */ | - | ||||||||||||||||||
| 139 | QQmlError::~QQmlError() | - | ||||||||||||||||||
| 140 | { | - | ||||||||||||||||||
| 141 | delete d; d = nullptr; | - | ||||||||||||||||||
| 142 | } executed 587358 times by 92 tests: end of blockExecuted by:
| 587358 | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | /*! | - | ||||||||||||||||||
| 145 | Returns true if this error is valid, otherwise false. | - | ||||||||||||||||||
| 146 | */ | - | ||||||||||||||||||
| 147 | bool QQmlError::isValid() const | - | ||||||||||||||||||
| 148 | { | - | ||||||||||||||||||
| 149 | return d != nullptr; executed 2518 times by 22 tests: return d != nullptr;Executed by:
| 2518 | ||||||||||||||||||
| 150 | } | - | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | /*! | - | ||||||||||||||||||
| 153 | Returns the url for the file that caused this error. | - | ||||||||||||||||||
| 154 | */ | - | ||||||||||||||||||
| 155 | QUrl QQmlError::url() const | - | ||||||||||||||||||
| 156 | { | - | ||||||||||||||||||
| 157 | if (d)
| 170-3526 | ||||||||||||||||||
| 158 | return d->url; executed 3526 times by 52 tests: return d->url;Executed by:
| 3526 | ||||||||||||||||||
| 159 | return QUrl(); executed 170 times by 4 tests: return QUrl();Executed by:
| 170 | ||||||||||||||||||
| 160 | } | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | /*! | - | ||||||||||||||||||
| 163 | Sets the \a url for the file that caused this error. | - | ||||||||||||||||||
| 164 | */ | - | ||||||||||||||||||
| 165 | void QQmlError::setUrl(const QUrl &url) | - | ||||||||||||||||||
| 166 | { | - | ||||||||||||||||||
| 167 | if (!d)
| 792-1030 | ||||||||||||||||||
| 168 | d = new QQmlErrorPrivate; executed 1030 times by 28 tests: d = new QQmlErrorPrivate;Executed by:
| 1030 | ||||||||||||||||||
| 169 | d->url = url; | - | ||||||||||||||||||
| 170 | } executed 1822 times by 55 tests: end of blockExecuted by:
| 1822 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | /*! | - | ||||||||||||||||||
| 173 | Returns the error description. | - | ||||||||||||||||||
| 174 | */ | - | ||||||||||||||||||
| 175 | QString QQmlError::description() const | - | ||||||||||||||||||
| 176 | { | - | ||||||||||||||||||
| 177 | if (d)
| 170-1949 | ||||||||||||||||||
| 178 | return d->description; executed 1949 times by 53 tests: return d->description;Executed by:
| 1949 | ||||||||||||||||||
| 179 | return QString(); executed 170 times by 4 tests: return QString();Executed by:
| 170 | ||||||||||||||||||
| 180 | } | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | /*! | - | ||||||||||||||||||
| 183 | Sets the error \a description. | - | ||||||||||||||||||
| 184 | */ | - | ||||||||||||||||||
| 185 | void QQmlError::setDescription(const QString &description) | - | ||||||||||||||||||
| 186 | { | - | ||||||||||||||||||
| 187 | if (!d)
| 2106-290376 | ||||||||||||||||||
| 188 | d = new QQmlErrorPrivate; executed 290376 times by 76 tests: d = new QQmlErrorPrivate;Executed by:
| 290376 | ||||||||||||||||||
| 189 | d->description = description; | - | ||||||||||||||||||
| 190 | } executed 292482 times by 92 tests: end of blockExecuted by:
| 292482 | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | /*! | - | ||||||||||||||||||
| 193 | Returns the error line number. | - | ||||||||||||||||||
| 194 | */ | - | ||||||||||||||||||
| 195 | int QQmlError::line() const | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | if (d)
| 170-3566 | ||||||||||||||||||
| 198 | return qmlSourceCoordinate(d->line); executed 3566 times by 53 tests: return qmlSourceCoordinate(d->line);Executed by:
| 3566 | ||||||||||||||||||
| 199 | return -1; executed 170 times by 4 tests: return -1;Executed by:
| 170 | ||||||||||||||||||
| 200 | } | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | /*! | - | ||||||||||||||||||
| 203 | Sets the error \a line number. | - | ||||||||||||||||||
| 204 | */ | - | ||||||||||||||||||
| 205 | void QQmlError::setLine(int line) | - | ||||||||||||||||||
| 206 | { | - | ||||||||||||||||||
| 207 | if (!d)
| 8-1637 | ||||||||||||||||||
| 208 | d = new QQmlErrorPrivate; executed 8 times by 3 tests: d = new QQmlErrorPrivate;Executed by:
| 8 | ||||||||||||||||||
| 209 | d->line = qmlSourceCoordinate(line); | - | ||||||||||||||||||
| 210 | } executed 1645 times by 53 tests: end of blockExecuted by:
| 1645 | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | /*! | - | ||||||||||||||||||
| 213 | Returns the error column number. | - | ||||||||||||||||||
| 214 | */ | - | ||||||||||||||||||
| 215 | int QQmlError::column() const | - | ||||||||||||||||||
| 216 | { | - | ||||||||||||||||||
| 217 | if (d)
| 2-1219 | ||||||||||||||||||
| 218 | return qmlSourceCoordinate(d->column); executed 1219 times by 47 tests: return qmlSourceCoordinate(d->column);Executed by:
| 1219 | ||||||||||||||||||
| 219 | return -1; executed 2 times by 1 test: return -1;Executed by:
| 2 | ||||||||||||||||||
| 220 | } | - | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | /*! | - | ||||||||||||||||||
| 223 | Sets the error \a column number. | - | ||||||||||||||||||
| 224 | */ | - | ||||||||||||||||||
| 225 | void QQmlError::setColumn(int column) | - | ||||||||||||||||||
| 226 | { | - | ||||||||||||||||||
| 227 | if (!d)
| 64-1571 | ||||||||||||||||||
| 228 | d = new QQmlErrorPrivate; executed 64 times by 11 tests: d = new QQmlErrorPrivate;Executed by:
| 64 | ||||||||||||||||||
| 229 | d->column = qmlSourceCoordinate(column); | - | ||||||||||||||||||
| 230 | } executed 1635 times by 53 tests: end of blockExecuted by:
| 1635 | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | /*! | - | ||||||||||||||||||
| 233 | Returns the nearest object where this error occurred. | - | ||||||||||||||||||
| 234 | Exceptions in bound property expressions set this to the object | - | ||||||||||||||||||
| 235 | to which the property belongs. It will be 0 for all | - | ||||||||||||||||||
| 236 | other exceptions. | - | ||||||||||||||||||
| 237 | */ | - | ||||||||||||||||||
| 238 | QObject *QQmlError::object() const | - | ||||||||||||||||||
| 239 | { | - | ||||||||||||||||||
| 240 | if (d)
| 0 | ||||||||||||||||||
| 241 | return d->object; never executed: return d->object; | 0 | ||||||||||||||||||
| 242 | return nullptr; never executed: return nullptr; | 0 | ||||||||||||||||||
| 243 | } | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | /*! | - | ||||||||||||||||||
| 246 | Sets the nearest \a object where this error occurred. | - | ||||||||||||||||||
| 247 | */ | - | ||||||||||||||||||
| 248 | void QQmlError::setObject(QObject *object) | - | ||||||||||||||||||
| 249 | { | - | ||||||||||||||||||
| 250 | if (!d)
| 0-94 | ||||||||||||||||||
| 251 | d = new QQmlErrorPrivate; never executed: d = new QQmlErrorPrivate; | 0 | ||||||||||||||||||
| 252 | d->object = object; | - | ||||||||||||||||||
| 253 | } executed 94 times by 9 tests: end of blockExecuted by:
| 94 | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | /*! | - | ||||||||||||||||||
| 256 | \since 5.9 | - | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | Returns the message type. | - | ||||||||||||||||||
| 259 | */ | - | ||||||||||||||||||
| 260 | QtMsgType QQmlError::messageType() const | - | ||||||||||||||||||
| 261 | { | - | ||||||||||||||||||
| 262 | if (d)
| 0-1649 | ||||||||||||||||||
| 263 | return d->messageType; executed 1649 times by 40 tests: return d->messageType;Executed by:
| 1649 | ||||||||||||||||||
| 264 | return QtMsgType::QtWarningMsg; never executed: return QtMsgType::QtWarningMsg; | 0 | ||||||||||||||||||
| 265 | } | - | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | /*! | - | ||||||||||||||||||
| 268 | \since 5.9 | - | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | Sets the \a messageType for this message. The message type determines which | - | ||||||||||||||||||
| 271 | QDebug handlers are responsible for receiving the message. | - | ||||||||||||||||||
| 272 | */ | - | ||||||||||||||||||
| 273 | void QQmlError::setMessageType(QtMsgType messageType) | - | ||||||||||||||||||
| 274 | { | - | ||||||||||||||||||
| 275 | if (!d)
| 0-976 | ||||||||||||||||||
| 276 | d = new QQmlErrorPrivate; executed 976 times by 30 tests: d = new QQmlErrorPrivate;Executed by:
| 976 | ||||||||||||||||||
| 277 | d->messageType = messageType; | - | ||||||||||||||||||
| 278 | } executed 976 times by 30 tests: end of blockExecuted by:
| 976 | ||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | /*! | - | ||||||||||||||||||
| 281 | Returns the error as a human readable string. | - | ||||||||||||||||||
| 282 | */ | - | ||||||||||||||||||
| 283 | QString QQmlError::toString() const | - | ||||||||||||||||||
| 284 | { | - | ||||||||||||||||||
| 285 | QString rv; | - | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | QUrl u(url()); | - | ||||||||||||||||||
| 288 | int l(line()); | - | ||||||||||||||||||
| 289 | - | |||||||||||||||||||
| 290 | if (u.isEmpty() || (u.isLocalFile() && u.path().isEmpty()))
| 2-1045 | ||||||||||||||||||
| 291 | rv += QLatin1String("<Unknown File>"); executed 900 times by 24 tests: rv += QLatin1String("<Unknown File>");Executed by:
| 900 | ||||||||||||||||||
| 292 | else | - | ||||||||||||||||||
| 293 | rv += u.toString(); executed 1043 times by 39 tests: rv += u.toString();Executed by:
| 1043 | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | if (l != -1) {
| 808-1135 | ||||||||||||||||||
| 296 | rv += QLatin1Char(':') + QString::number(l); | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | int c(column()); | - | ||||||||||||||||||
| 299 | if (c != -1)
| 516-619 | ||||||||||||||||||
| 300 | rv += QLatin1Char(':') + QString::number(c); executed 516 times by 40 tests: rv += QLatin1Char(':') + QString::number(c);Executed by:
| 516 | ||||||||||||||||||
| 301 | } executed 1135 times by 45 tests: end of blockExecuted by:
| 1135 | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | rv += QLatin1String(": ") + description(); | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | return rv; executed 1943 times by 49 tests: return rv;Executed by:
| 1943 | ||||||||||||||||||
| 306 | } | - | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | /*! | - | ||||||||||||||||||
| 309 | \relates QQmlError | - | ||||||||||||||||||
| 310 | \fn QDebug operator<<(QDebug debug, const QQmlError &error) | - | ||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | Outputs a human readable version of \a error to \a debug. | - | ||||||||||||||||||
| 313 | */ | - | ||||||||||||||||||
| 314 | - | |||||||||||||||||||
| 315 | QDebug operator<<(QDebug debug, const QQmlError &error) | - | ||||||||||||||||||
| 316 | { | - | ||||||||||||||||||
| 317 | debug << qPrintable(error.toString()); | - | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | QUrl url = error.url(); | - | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | if (error.line() > 0 && url.scheme() == QLatin1String("file")) {
| 2-20 | ||||||||||||||||||
| 322 | QString file = url.toLocalFile(); | - | ||||||||||||||||||
| 323 | QFile f(file); | - | ||||||||||||||||||
| 324 | if (f.open(QIODevice::ReadOnly)) {
| 2-10 | ||||||||||||||||||
| 325 | QByteArray data = f.readAll(); | - | ||||||||||||||||||
| 326 | QTextStream stream(data, QIODevice::ReadOnly); | - | ||||||||||||||||||
| 327 | #if QT_CONFIG(textcodec) | - | ||||||||||||||||||
| 328 | stream.setCodec("UTF-8"); | - | ||||||||||||||||||
| 329 | #endif | - | ||||||||||||||||||
| 330 | const QString code = stream.readAll(); | - | ||||||||||||||||||
| 331 | const auto lines = code.splitRef(QLatin1Char('\n')); | - | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | if (lines.count() >= error.line()) {
| 0-10 | ||||||||||||||||||
| 334 | const QStringRef &line = lines.at(error.line() - 1); | - | ||||||||||||||||||
| 335 | debug << "\n " << line.toLocal8Bit().constData(); | - | ||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | if(error.column() > 0) {
| 0-10 | ||||||||||||||||||
| 338 | int column = qMax(0, error.column() - 1); | - | ||||||||||||||||||
| 339 | column = qMin(column, line.length()); | - | ||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | QByteArray ind; | - | ||||||||||||||||||
| 342 | ind.reserve(column); | - | ||||||||||||||||||
| 343 | for (int i = 0; i < column; ++i) {
| 10-48 | ||||||||||||||||||
| 344 | const QChar ch = line.at(i); | - | ||||||||||||||||||
| 345 | if (ch.isSpace())
| 8-40 | ||||||||||||||||||
| 346 | ind.append(ch.unicode()); executed 40 times by 3 tests: ind.append(ch.unicode());Executed by:
| 40 | ||||||||||||||||||
| 347 | else | - | ||||||||||||||||||
| 348 | ind.append(' '); executed 8 times by 1 test: ind.append(' ');Executed by:
| 8 | ||||||||||||||||||
| 349 | } | - | ||||||||||||||||||
| 350 | ind.append('^'); | - | ||||||||||||||||||
| 351 | debug << "\n " << ind.constData(); | - | ||||||||||||||||||
| 352 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 353 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 354 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 355 | } executed 12 times by 5 tests: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 356 | return debug; executed 22 times by 6 tests: return debug;Executed by:
| 22 | ||||||||||||||||||
| 357 | } | - | ||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |