| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlerror.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | class QQmlErrorPrivate | - | ||||||||||||||||||
| 6 | { | - | ||||||||||||||||||
| 7 | public: | - | ||||||||||||||||||
| 8 | QQmlErrorPrivate(); | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | QUrl url; | - | ||||||||||||||||||
| 11 | QString description; | - | ||||||||||||||||||
| 12 | quint16 line; | - | ||||||||||||||||||
| 13 | quint16 column; | - | ||||||||||||||||||
| 14 | QtMsgType messageType; | - | ||||||||||||||||||
| 15 | QPointer<QObject> object; | - | ||||||||||||||||||
| 16 | }; | - | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | QQmlErrorPrivate::QQmlErrorPrivate() | - | ||||||||||||||||||
| 19 | : line(0), column(0), messageType(QtMsgType::QtWarningMsg), object() | - | ||||||||||||||||||
| 20 | { | - | ||||||||||||||||||
| 21 | } executed 586834 times by 92 tests: end of blockExecuted by:
| 586834 | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | - | |||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | QQmlError::QQmlError() | - | ||||||||||||||||||
| 27 | : d(nullptr) | - | ||||||||||||||||||
| 28 | { | - | ||||||||||||||||||
| 29 | } executed 293524 times by 92 tests: end of blockExecuted by:
| 293524 | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | QQmlError::QQmlError(const QQmlError &other) | - | ||||||||||||||||||
| 35 | : d(nullptr) | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | *this = other; | - | ||||||||||||||||||
| 38 | } executed 293838 times by 91 tests: end of blockExecuted by:
| 293838 | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | QQmlError &QQmlError::operator=(const QQmlError &other) | - | ||||||||||||||||||
| 44 | { | - | ||||||||||||||||||
| 45 | if (!other.d
| 364-294384 | ||||||||||||||||||
| 46 | delete d; | - | ||||||||||||||||||
| 47 | d = nullptr; | - | ||||||||||||||||||
| 48 | } executed 364 times by 15 tests: else {end of blockExecuted by:
| 364 | ||||||||||||||||||
| 49 | if (!d
| 4-294380 | ||||||||||||||||||
| 50 | d = new QQmlErrorPrivate; executed 294380 times by 91 tests: d = new QQmlErrorPrivate;Executed by:
| 294380 | ||||||||||||||||||
| 51 | d->url = other.d->url; | - | ||||||||||||||||||
| 52 | d->description = other.d->description; | - | ||||||||||||||||||
| 53 | d->line = other.d->line; | - | ||||||||||||||||||
| 54 | d->column = other.d->column; | - | ||||||||||||||||||
| 55 | d->object = other.d->object; | - | ||||||||||||||||||
| 56 | d->messageType = other.d->messageType; | - | ||||||||||||||||||
| 57 | } executed 294384 times by 91 tests: end of blockExecuted by:
| 294384 | ||||||||||||||||||
| 58 | return executed 294748 times by 91 tests: *this;return *this;Executed by:
executed 294748 times by 91 tests: return *this;Executed by:
| 294748 | ||||||||||||||||||
| 59 | } | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | QQmlError::~QQmlError() | - | ||||||||||||||||||
| 65 | { | - | ||||||||||||||||||
| 66 | delete d; d = nullptr; | - | ||||||||||||||||||
| 67 | } executed 587358 times by 92 tests: end of blockExecuted by:
| 587358 | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | bool QQmlError::isValid() const | - | ||||||||||||||||||
| 73 | { | - | ||||||||||||||||||
| 74 | return executed 2518 times by 22 tests: d != nullptr;return d != nullptr;Executed by:
executed 2518 times by 22 tests: return d != nullptr;Executed by:
| 2518 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | QUrl QQmlError::url() const | - | ||||||||||||||||||
| 81 | { | - | ||||||||||||||||||
| 82 | if (d
| 170-3526 | ||||||||||||||||||
| 83 | return executed 3526 times by 52 tests: d->url;return d->url;Executed by:
executed 3526 times by 52 tests: return d->url;Executed by:
| 3526 | ||||||||||||||||||
| 84 | return executed 170 times by 4 tests: QUrl();return QUrl();Executed by:
executed 170 times by 4 tests: return QUrl();Executed by:
| 170 | ||||||||||||||||||
| 85 | } | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | void QQmlError::setUrl(const QUrl &url) | - | ||||||||||||||||||
| 91 | { | - | ||||||||||||||||||
| 92 | if (!d
| 792-1030 | ||||||||||||||||||
| 93 | d = new QQmlErrorPrivate; executed 1030 times by 28 tests: d = new QQmlErrorPrivate;Executed by:
| 1030 | ||||||||||||||||||
| 94 | d->url = url; | - | ||||||||||||||||||
| 95 | } executed 1822 times by 55 tests: end of blockExecuted by:
| 1822 | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | QString QQmlError::description() const | - | ||||||||||||||||||
| 101 | { | - | ||||||||||||||||||
| 102 | if (d
| 170-1949 | ||||||||||||||||||
| 103 | return executed 1949 times by 53 tests: d->description;return d->description;Executed by:
executed 1949 times by 53 tests: return d->description;Executed by:
| 1949 | ||||||||||||||||||
| 104 | return executed 170 times by 4 tests: QString();return QString();Executed by:
executed 170 times by 4 tests: return QString();Executed by:
| 170 | ||||||||||||||||||
| 105 | } | - | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | void QQmlError::setDescription(const QString &description) | - | ||||||||||||||||||
| 111 | { | - | ||||||||||||||||||
| 112 | if (!d
| 2106-290376 | ||||||||||||||||||
| 113 | d = new QQmlErrorPrivate; executed 290376 times by 76 tests: d = new QQmlErrorPrivate;Executed by:
| 290376 | ||||||||||||||||||
| 114 | d->description = description; | - | ||||||||||||||||||
| 115 | } executed 292482 times by 92 tests: end of blockExecuted by:
| 292482 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | int QQmlError::line() const | - | ||||||||||||||||||
| 121 | { | - | ||||||||||||||||||
| 122 | if (d
| 170-3566 | ||||||||||||||||||
| 123 | return executed 3566 times by 53 tests: qmlSourceCoordinate(d->line);return qmlSourceCoordinate(d->line);Executed by:
executed 3566 times by 53 tests: return qmlSourceCoordinate(d->line);Executed by:
| 3566 | ||||||||||||||||||
| 124 | return executed 170 times by 4 tests: -1;return -1;Executed by:
executed 170 times by 4 tests: return -1;Executed by:
| 170 | ||||||||||||||||||
| 125 | } | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | void QQmlError::setLine(int line) | - | ||||||||||||||||||
| 131 | { | - | ||||||||||||||||||
| 132 | if (!d
| 8-1637 | ||||||||||||||||||
| 133 | d = new QQmlErrorPrivate; executed 8 times by 3 tests: d = new QQmlErrorPrivate;Executed by:
| 8 | ||||||||||||||||||
| 134 | d->line = qmlSourceCoordinate(line); | - | ||||||||||||||||||
| 135 | } executed 1645 times by 53 tests: end of blockExecuted by:
| 1645 | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | int QQmlError::column() const | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | if (d
| 2-1219 | ||||||||||||||||||
| 143 | return executed 1219 times by 47 tests: qmlSourceCoordinate(d->column);return qmlSourceCoordinate(d->column);Executed by:
executed 1219 times by 47 tests: return qmlSourceCoordinate(d->column);Executed by:
| 1219 | ||||||||||||||||||
| 144 | return executed 2 times by 1 test: -1;return -1;Executed by:
executed 2 times by 1 test: return -1;Executed by:
| 2 | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | void QQmlError::setColumn(int column) | - | ||||||||||||||||||
| 151 | { | - | ||||||||||||||||||
| 152 | if (!d
| 64-1571 | ||||||||||||||||||
| 153 | d = new QQmlErrorPrivate; executed 64 times by 11 tests: d = new QQmlErrorPrivate;Executed by:
| 64 | ||||||||||||||||||
| 154 | d->column = qmlSourceCoordinate(column); | - | ||||||||||||||||||
| 155 | } executed 1635 times by 53 tests: end of blockExecuted by:
| 1635 | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | QObject *QQmlError::object() const | - | ||||||||||||||||||
| 164 | { | - | ||||||||||||||||||
| 165 | if (d
| 0 | ||||||||||||||||||
| 166 | return never executed: d->object;return d->object;never executed: return d->object; | 0 | ||||||||||||||||||
| 167 | return never executed: nullptr;return nullptr;never executed: return nullptr; | 0 | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | void QQmlError::setObject(QObject *object) | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 | if (!d
| 0-94 | ||||||||||||||||||
| 176 | d = new QQmlErrorPrivate; never executed: d = new QQmlErrorPrivate; | 0 | ||||||||||||||||||
| 177 | d->object = object; | - | ||||||||||||||||||
| 178 | } executed 94 times by 9 tests: end of blockExecuted by:
| 94 | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | QtMsgType QQmlError::messageType() const | - | ||||||||||||||||||
| 186 | { | - | ||||||||||||||||||
| 187 | if (d
| 0-1649 | ||||||||||||||||||
| 188 | return executed 1649 times by 40 tests: d->messageType;return d->messageType;Executed by:
executed 1649 times by 40 tests: return d->messageType;Executed by:
| 1649 | ||||||||||||||||||
| 189 | return never executed: QtMsgType::QtWarningMsg;return QtMsgType::QtWarningMsg;never executed: return QtMsgType::QtWarningMsg; | 0 | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | void QQmlError::setMessageType(QtMsgType messageType) | - | ||||||||||||||||||
| 199 | { | - | ||||||||||||||||||
| 200 | if (!d
| 0-976 | ||||||||||||||||||
| 201 | d = new QQmlErrorPrivate; executed 976 times by 30 tests: d = new QQmlErrorPrivate;Executed by:
| 976 | ||||||||||||||||||
| 202 | d->messageType = messageType; | - | ||||||||||||||||||
| 203 | } executed 976 times by 30 tests: end of blockExecuted by:
| 976 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | QString QQmlError::toString() const | - | ||||||||||||||||||
| 209 | { | - | ||||||||||||||||||
| 210 | QString rv; | - | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | QUrl u(url()); | - | ||||||||||||||||||
| 213 | int l(line()); | - | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | if (u.isEmpty()
| 2-1045 | ||||||||||||||||||
| 216 | rv += QLatin1String("<Unknown File>"); executed 900 times by 24 tests: rv += QLatin1String("<Unknown File>");Executed by:
| 900 | ||||||||||||||||||
| 217 | else | - | ||||||||||||||||||
| 218 | rv += u.toString(); executed 1043 times by 39 tests: rv += u.toString();Executed by:
| 1043 | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | if (l != -1
| 808-1135 | ||||||||||||||||||
| 221 | rv += QLatin1Char(':') + QString::number(l); | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | int c(column()); | - | ||||||||||||||||||
| 224 | if (c != -1
| 516-619 | ||||||||||||||||||
| 225 | rv += QLatin1Char(':') + QString::number(c); executed 516 times by 40 tests: rv += QLatin1Char(':') + QString::number(c);Executed by:
| 516 | ||||||||||||||||||
| 226 | } executed 1135 times by 45 tests: end of blockExecuted by:
| 1135 | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | rv += QLatin1String(": ") + description(); | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | return executed 1943 times by 49 tests: rv;return rv;Executed by:
executed 1943 times by 49 tests: return rv;Executed by:
| 1943 | ||||||||||||||||||
| 231 | } | - | ||||||||||||||||||
| 232 | QDebug operator<<(QDebug debug, const QQmlError &error) | - | ||||||||||||||||||
| 233 | { | - | ||||||||||||||||||
| 234 | debug << QtPrivate::asString(error.toString()).toLocal8Bit().constData(); | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | QUrl url = error.url(); | - | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | if (error.line() > 0
| 2-20 | ||||||||||||||||||
| 239 | QString file = url.toLocalFile(); | - | ||||||||||||||||||
| 240 | QFile f(file); | - | ||||||||||||||||||
| 241 | if (f.open(QIODevice::ReadOnly)
| 2-10 | ||||||||||||||||||
| 242 | QByteArray data = f.readAll(); | - | ||||||||||||||||||
| 243 | QTextStream stream(data, QIODevice::ReadOnly); | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | stream.setCodec("UTF-8"); | - | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | const QString code = stream.readAll(); | - | ||||||||||||||||||
| 248 | const auto lines = code.splitRef(QLatin1Char('\n')); | - | ||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | if (lines.count() >= error.line()
| 0-10 | ||||||||||||||||||
| 251 | const QStringRef &line = lines.at(error.line() - 1); | - | ||||||||||||||||||
| 252 | debug << "\n " << line.toLocal8Bit().constData(); | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | if(error.column() > 0
| 0-10 | ||||||||||||||||||
| 255 | int column = qMax(0, error.column() - 1); | - | ||||||||||||||||||
| 256 | column = qMin(column, line.length()); | - | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | QByteArray ind; | - | ||||||||||||||||||
| 259 | ind.reserve(column); | - | ||||||||||||||||||
| 260 | for (int i = 0; i < column
| 10-48 | ||||||||||||||||||
| 261 | const QChar ch = line.at(i); | - | ||||||||||||||||||
| 262 | if (ch.isSpace()
| 8-40 | ||||||||||||||||||
| 263 | ind.append(ch.unicode()); executed 40 times by 3 tests: ind.append(ch.unicode());Executed by:
| 40 | ||||||||||||||||||
| 264 | else | - | ||||||||||||||||||
| 265 | ind.append(' '); executed 8 times by 1 test: ind.append(' ');Executed by:
| 8 | ||||||||||||||||||
| 266 | } | - | ||||||||||||||||||
| 267 | ind.append('^'); | - | ||||||||||||||||||
| 268 | debug << "\n " << ind.constData(); | - | ||||||||||||||||||
| 269 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 270 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 271 | } executed 10 times by 5 tests: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 272 | } executed 12 times by 5 tests: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 273 | return executed 22 times by 6 tests: debug;return debug;Executed by:
executed 22 times by 6 tests: return debug;Executed by:
| 22 | ||||||||||||||||||
| 274 | } | - | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |