summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/linguist/lupdate/qdeclarative.cpp31
-rw-r--r--src/qdoc/qmlcodeparser.cpp11
2 files changed, 21 insertions, 21 deletions
diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp
index fa8ad260e..ddf7d2f35 100644
--- a/src/linguist/lupdate/qdeclarative.cpp
+++ b/src/linguist/lupdate/qdeclarative.cpp
@@ -274,25 +274,20 @@ QString createErrorString(const QString &filename, const QString &code, Parser &
if (m.isWarning())
continue;
- QString error = filename + QLatin1Char(':') + QString::number(m.loc.startLine)
- + QLatin1Char(':') + QString::number(m.loc.startColumn) + QLatin1String(": error: ")
- + m.message + QLatin1Char('\n');
-
- int line = 0;
- if (m.loc.startLine > 0)
- line = m.loc.startLine - 1;
-
- const QString textLine = lines.at(line);
-
+#if Q_QML_PRIVATE_API_VERSION < 5
+ const int line = m.loc.startLine;
+ const int column = m.loc.startColumn;
+#else
+ const int line = m.line;
+ const int column = m.column;
+#endif
+ QString error = filename + QLatin1Char(':')
+ + QString::number(line) + QLatin1Char(':') + QString::number(column)
+ + QLatin1String(": error: ") + m.message + QLatin1Char('\n');
+
+ const QString textLine = lines.at(line > 0 ? line - 1 : 0);
error += textLine + QLatin1Char('\n');
-
- int column = m.loc.startColumn - 1;
- if (column < 0)
- column = 0;
-
- column = qMin(column, textLine.length());
-
- for (int i = 0; i < column; ++i) {
+ for (int i = 0, end = qMin(column > 0 ? column - 1 : 0, textLine.length()); i < end; ++i) {
const QChar ch = textLine.at(i);
if (ch.isSpace())
error += ch.unicode();
diff --git a/src/qdoc/qmlcodeparser.cpp b/src/qdoc/qmlcodeparser.cpp
index 437bcfd21..5539d5b80 100644
--- a/src/qdoc/qmlcodeparser.cpp
+++ b/src/qdoc/qmlcodeparser.cpp
@@ -147,9 +147,14 @@ void QmlCodeParser::parseSourceFile(const Location& location, const QString& fil
<< "The output is incomplete.";
}
}
- foreach (const QQmlJS::DiagnosticMessage &msg, parser->diagnosticMessages()) {
- qDebug().nospace() << qPrintable(filePath) << ':' << msg.loc.startLine
- << ": QML syntax error at col " << msg.loc.startColumn
+ foreach (const QQmlJS::DiagnosticMessage &msg, parser->diagnosticMessages()) {
+ qDebug().nospace() << qPrintable(filePath) << ':'
+#if Q_QML_PRIVATE_API_VERSION < 5
+ << msg.loc.startLine << ": QML syntax error at col "
+ << msg.loc.startColumn
+#else
+ << msg.line << ": QML syntax error at col " << msg.column
+#endif
<< ": " << qPrintable(msg.message);
}
currentFile_.clear();