summaryrefslogtreecommitdiff
path: root/src/libs
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-05-17 11:50:45 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2019-05-17 11:50:45 +0000
commit0565457b5c16564d2b230dca8eea6d94024efae2 (patch)
treeded7fa04819e4fc20c743f27c6a7a876a4e9aa01 /src/libs
parented77e105717eb9713a56254375e2646a3a6ddcee (diff)
parent829a08047fdf383e6dbbace85678053c281b0d34 (diff)
downloadqt-creator-0565457b5c16564d2b230dca8eea6d94024efae2.tar.gz
Merge "Merge remote-tracking branch 'origin/4.9'"
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/languageserverprotocol/lsptypes.cpp21
-rw-r--r--src/libs/languageserverprotocol/lsputils.cpp20
-rw-r--r--src/libs/languageserverprotocol/lsputils.h6
3 files changed, 29 insertions, 18 deletions
diff --git a/src/libs/languageserverprotocol/lsptypes.cpp b/src/libs/languageserverprotocol/lsptypes.cpp
index e5abcf8036..9b1ddc079d 100644
--- a/src/libs/languageserverprotocol/lsptypes.cpp
+++ b/src/libs/languageserverprotocol/lsptypes.cpp
@@ -53,8 +53,8 @@ Utils::optional<Diagnostic::Code> Diagnostic::code() const
if (codeValue.isUndefined())
return Utils::nullopt;
QJsonValue::Type type = it.value().type();
- QTC_ASSERT(type == QJsonValue::String || type == QJsonValue::Double,
- return Utils::make_optional(Code(QString())));
+ if (type != QJsonValue::String && type != QJsonValue::Double)
+ return Utils::make_optional(Code(QString()));
return Utils::make_optional(codeValue.isDouble() ? Code(codeValue.toInt())
: Code(codeValue.toString()));
}
@@ -81,8 +81,7 @@ Utils::optional<WorkspaceEdit::Changes> WorkspaceEdit::changes() const
auto it = find(changesKey);
if (it == end())
return Utils::nullopt;
- QTC_ASSERT(it.value().type() == QJsonValue::Object, return Changes());
- QJsonObject changesObject(it.value().toObject());
+ const QJsonObject &changesObject = it.value().toObject();
Changes changesResult;
for (const QString &key : changesObject.keys())
changesResult[DocumentUri::fromProtocol(key)] = LanguageClientArray<TextEdit>(changesObject.value(key)).toList();
@@ -122,11 +121,13 @@ MarkupOrString::MarkupOrString(const MarkupContent &val)
MarkupOrString::MarkupOrString(const QJsonValue &val)
{
- QTC_ASSERT(val.isString() | val.isObject(), return);
- if (val.isString())
+ if (val.isString()) {
emplace<QString>(val.toString());
- else
- emplace<MarkupContent>(MarkupContent(val.toObject()));
+ } else {
+ MarkupContent markupContent(val.toObject());
+ if (markupContent.isValid(nullptr))
+ emplace<MarkupContent>(MarkupContent(val.toObject()));
+ }
}
bool MarkupOrString::isValid(QStringList *error) const
@@ -401,9 +402,7 @@ Utils::Link Location::toLink() const
DocumentUri::DocumentUri(const QString &other)
: QUrl(QUrl::fromPercentEncoding(other.toLocal8Bit()))
-{
- QTC_ASSERT(isValid(), qWarning() << other);
-}
+{ }
DocumentUri::DocumentUri(const Utils::FileName &other)
: QUrl(QUrl::fromLocalFile(other.toString()))
diff --git a/src/libs/languageserverprotocol/lsputils.cpp b/src/libs/languageserverprotocol/lsputils.cpp
index 40d782c9f6..aceeed7392 100644
--- a/src/libs/languageserverprotocol/lsputils.cpp
+++ b/src/libs/languageserverprotocol/lsputils.cpp
@@ -28,42 +28,50 @@
#include <utils/mimetypes/mimedatabase.h>
#include <QHash>
+#include <QLoggingCategory>
#include <QVector>
namespace LanguageServerProtocol {
+Q_LOGGING_CATEGORY(conversionLog, "qtc.languageserverprotocol.conversion", QtWarningMsg)
+
template<>
QString fromJsonValue<QString>(const QJsonValue &value)
{
- QTC_ASSERT(value.isString(), return QString());
+ if (conversionLog().isDebugEnabled() && !value.isString())
+ qCDebug(conversionLog) << "Expected String in json value but got: " << value;
return value.toString();
}
template<>
int fromJsonValue<int>(const QJsonValue &value)
{
- QTC_ASSERT(value.isDouble(), return 0);
- return int(value.toDouble());
+ if (conversionLog().isDebugEnabled() && !value.isDouble())
+ qCDebug(conversionLog) << "Expected double in json value but got: " << value;
+ return value.toInt();
}
template<>
double fromJsonValue<double>(const QJsonValue &value)
{
- QTC_ASSERT(value.isDouble(), return 0);
+ if (conversionLog().isDebugEnabled() && !value.isDouble())
+ qCDebug(conversionLog) << "Expected double in json value but got: " << value;
return value.toDouble();
}
template<>
bool fromJsonValue<bool>(const QJsonValue &value)
{
- QTC_ASSERT(value.isBool(), return false);
+ if (conversionLog().isDebugEnabled() && !value.isBool())
+ qCDebug(conversionLog) << "Expected bool in json value but got: " << value;
return value.toBool();
}
template<>
QJsonArray fromJsonValue<QJsonArray>(const QJsonValue &value)
{
- QTC_ASSERT(value.isArray(), return QJsonArray());
+ if (conversionLog().isDebugEnabled() && !value.isArray())
+ qCDebug(conversionLog) << "Expected Array in json value but got: " << value;
return value.toArray();
}
diff --git a/src/libs/languageserverprotocol/lsputils.h b/src/libs/languageserverprotocol/lsputils.h
index a0ce753325..4646f181e9 100644
--- a/src/libs/languageserverprotocol/lsputils.h
+++ b/src/libs/languageserverprotocol/lsputils.h
@@ -35,13 +35,17 @@
#include <QJsonArray>
#include <QJsonObject>
+#include <QLoggingCategory>
namespace LanguageServerProtocol {
+LANGUAGESERVERPROTOCOL_EXPORT Q_DECLARE_LOGGING_CATEGORY(conversionLog)
+
template <typename T>
T fromJsonValue(const QJsonValue &value)
{
- QTC_ASSERT(value.isObject(), return T());
+ if (conversionLog().isDebugEnabled() && !value.isObject())
+ qCDebug(conversionLog) << "Expected Object in json value but got: " << value;
return T(value.toObject());
}