From a29bbf5568bf651b076f051720a98e9d0297faa9 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 22 Sep 2022 17:14:55 +0200 Subject: Make handling of deprecated items and properties configurable As of now, a newly deprecated property leads to users getting bombarded with warnings, even though they did not yet have a chance to adapt their project. Now the warnings appear by default one minor version before removal, which together with our convention of keeping deprecated properties for at least two minor versions gives users enough time to adapt without getting spammed. There is also a mode for switching to the previous behavior (for early detection), as well as the possibility to trigger errors instead of warnings, which should be helpful in CI configurations. To support the case where the user cannot do anything about them, the warnings can also be suppressed altogether. Change-Id: I295f816758f0f111fcb0351581a4328be3af5668 Reviewed-by: Leena Miettinen Reviewed-by: Ivan Komissarov --- src/lib/corelib/language/item.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/lib/corelib/language/item.cpp') diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp index 178a34b00..c58d2058d 100644 --- a/src/lib/corelib/language/item.cpp +++ b/src/lib/corelib/language/item.cpp @@ -246,7 +246,7 @@ bool Item::isPresentModule() const return v && v->type() == Value::JSSourceValueType; } -void Item::setupForBuiltinType(Logger &logger) +void Item::setupForBuiltinType(DeprecationWarningMode deprecationMode, Logger &logger) { const BuiltinDeclarations &builtins = BuiltinDeclarations::instance(); const auto properties = builtins.declarationsForType(type()).properties(); @@ -263,23 +263,9 @@ void Item::setupForBuiltinType(Logger &logger) ? StringConstants::undefinedValue() : pd.initialValueSource()); m_properties.insert(pd.name(), sourceValue); - } else if (pd.isDeprecated()) { - const DeprecationInfo &di = pd.deprecationInfo(); - if (di.removalVersion() <= LanguageInfo::qbsVersion()) { - QString message = Tr::tr("The property '%1' is no longer valid for %2 items. " - "It was removed in qbs %3.") - .arg(pd.name(), typeName(), di.removalVersion().toString()); - ErrorInfo error(message, value->location()); - if (!di.additionalUserInfo().isEmpty()) - error.append(di.additionalUserInfo()); - throw error; - } - QString warning = Tr::tr("The property '%1' is deprecated and will be removed in " - "qbs %2.").arg(pd.name(), di.removalVersion().toString()); - ErrorInfo error(warning, value->location()); - if (!di.additionalUserInfo().isEmpty()) - error.append(di.additionalUserInfo()); - logger.printWarning(error); + } else if (ErrorInfo error = pd.checkForDeprecation(deprecationMode, value->location(), + logger); error.hasError()) { + throw error; } } } -- cgit v1.2.3