QmlJS: Fix initializing static analyzer

...when using a customized analyzer that has no customization.
If there is no customization we do not store the value inside
the settings, so we get empty lists instead of the default
lists for disabled messages.
Amends 427640063e.

Change-Id: Idea560176b0a9caa93dca7a3a2d01cc3aa3a6d2f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Christian Stenger
2023-06-12 09:01:12 +02:00
parent 860b204e38
commit 97a97b3019

View File

@@ -697,12 +697,19 @@ Check::Check(Document::Ptr doc, const ContextPtr &context, Utils::QtcSettings *q
_enabledMessages = Utils::toSet(Message::allMessageTypes());
if (qtcSettings && qtcSettings->value("J.QtQuick/QmlJSEditor.useCustomAnalyzer").toBool()) {
auto disabled = qtcSettings->value("J.QtQuick/QmlJSEditor.disabledMessages").toList();
auto toIntList = [](const QList<StaticAnalysis::Type> list) {
return Utils::transform(list, [](StaticAnalysis::Type t) { return int(t); });
};
auto disabled = qtcSettings->value("J.QtQuick/QmlJSEditor.disabledMessages",
QVariant::fromValue(
toIntList(defaultDisabledMessages()))).toList();
for (const QVariant &disabledNumber : disabled)
disableMessage(StaticAnalysis::Type(disabledNumber.toInt()));
if (!isQtQuick2Ui()) {
auto disabled = qtcSettings->value("J.QtQuick/QmlJSEditor.disabledMessagesNonQuickUI").toList();
auto disabled = qtcSettings->value("J.QtQuick/QmlJSEditor.disabledMessagesNonQuickUI",
QVariant::fromValue(
toIntList(defaultDisabledMessagesForNonQuickUi()))).toList();
for (const QVariant &disabledNumber : disabled)
disableMessage(StaticAnalysis::Type(disabledNumber.toInt()));
}