aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2022-05-02 11:13:14 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2022-05-03 10:16:28 +0200
commita428c19244973f1552d00e6866f506545b53f050 (patch)
tree961cc1469830c27c7a552cbb154a5b22e737985b /tools
parente2015e7ad38cfaca0d0eda32f4d902d9205f21de (diff)
qmlls/qmllintsuggestions: Use versioned TextDocument in CodeActions
Previously we used unversioned text documents to generate our qmllint suggestions. This caused issues when the document was updated. Now with versions being used the suggestions should update properly. Change-Id: Ic436a843b8a342d0fe46720b98d402ec80bd3e4f Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlls/qmllintsuggestions.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/qmlls/qmllintsuggestions.cpp b/tools/qmlls/qmllintsuggestions.cpp
index e47ba874b5..d858d875e0 100644
--- a/tools/qmlls/qmllintsuggestions.cpp
+++ b/tools/qmlls/qmllintsuggestions.cpp
@@ -69,7 +69,10 @@ static void codeActionHandler(
if (!diagnostic.data.has_value())
continue;
- QJsonArray suggestions = diagnostic.data.value().toArray();
+ const auto &data = diagnostic.data.value();
+
+ int version = data[u"version"].toInt();
+ QJsonArray suggestions = data[u"suggestions"].toArray();
QList<TextDocumentEdit> edits;
QString message;
@@ -85,7 +88,7 @@ static void codeActionHandler(
textEdit.newText = replacement.toUtf8();
TextDocumentEdit textDocEdit;
- textDocEdit.textDocument = { params.textDocument };
+ textDocEdit.textDocument = { params.textDocument, version };
textDocEdit.edits.append(textEdit);
edits.append(textDocEdit);
@@ -199,7 +202,7 @@ void QmlLintSuggestions::diagnose(const QByteArray &url)
}
};
- auto messageToDiagnostic = [&addLength](const Message &message) {
+ auto messageToDiagnostic = [&addLength, &version](const Message &message) {
Diagnostic diagnostic;
diagnostic.severity = severityFromMsgType(message.type);
Range &range = diagnostic.range;
@@ -241,7 +244,13 @@ void QmlLintSuggestions::diagnose(const QByteArray &url)
fixedSuggestions << object;
}
- diagnostic.data = fixedSuggestions;
+ QJsonObject data;
+ data[u"suggestions"] = fixedSuggestions;
+
+ Q_ASSERT(version.has_value());
+ data[u"version"] = version.value();
+
+ diagnostic.data = data;
}
return diagnostic;
};