forked from qt-creator/qt-creator
QmlJS: Stop suggesting versions for imports if possible
Fixes: QTCREATORBUG-28649 Change-Id: I918b229855c18519800a54a73b56eaffa40524e5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -25,7 +25,8 @@ BasicBundleProvider::BasicBundleProvider(QObject *parent) :
|
||||
IBundleProvider(parent)
|
||||
{ }
|
||||
|
||||
QmlBundle BasicBundleProvider::defaultBundle(const QString &bundleInfoName)
|
||||
QmlBundle BasicBundleProvider::defaultBundle(const QString &bundleInfoName,
|
||||
QtSupport::QtVersion *qtVersion)
|
||||
{
|
||||
static bool wroteErrors = false;
|
||||
QmlBundle res;
|
||||
@@ -37,7 +38,8 @@ QmlBundle BasicBundleProvider::defaultBundle(const QString &bundleInfoName)
|
||||
return res;
|
||||
}
|
||||
QStringList errors;
|
||||
if (!res.readFrom(defaultBundlePath.toString(), &errors) && !wroteErrors) {
|
||||
bool stripVersions = qtVersion && qtVersion->qtVersion().majorVersion() > 5;
|
||||
if (!res.readFrom(defaultBundlePath.toString(), stripVersions, &errors) && !wroteErrors) {
|
||||
qWarning() << "BasicBundleProvider: ERROR reading " << defaultBundlePath
|
||||
<< " : " << errors;
|
||||
wroteErrors = true;
|
||||
@@ -45,31 +47,31 @@ QmlBundle BasicBundleProvider::defaultBundle(const QString &bundleInfoName)
|
||||
return res;
|
||||
}
|
||||
|
||||
QmlBundle BasicBundleProvider::defaultQt5QtQuick2Bundle(bool enhance)
|
||||
QmlBundle BasicBundleProvider::defaultQt5QtQuick2Bundle(QtSupport::QtVersion *qtVersion)
|
||||
{
|
||||
QmlBundle result = defaultBundle(QLatin1String("qt5QtQuick2-bundle.json"));
|
||||
if (!enhance)
|
||||
QmlBundle result = defaultBundle(QLatin1String("qt5QtQuick2-bundle.json"), qtVersion);
|
||||
if (!qtVersion || qtVersion->qtVersion().majorVersion() < 6)
|
||||
return result;
|
||||
if (Utils::HostOsInfo::isMacHost())
|
||||
result.merge(defaultBundle(QLatin1String("qt5QtQuick2ext-macos-bundle.json")));
|
||||
result.merge(defaultBundle(QLatin1String("qt5QtQuick2ext-macos-bundle.json"), qtVersion));
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
result.merge(defaultBundle(QLatin1String("qt5QtQuick2ext-win-bundle.json")));
|
||||
result.merge(defaultBundle(QLatin1String("qt5QtQuick2ext-win-bundle.json"), qtVersion));
|
||||
return result;
|
||||
}
|
||||
|
||||
QmlBundle BasicBundleProvider::defaultQbsBundle()
|
||||
{
|
||||
return defaultBundle(QLatin1String("qbs-bundle.json"));
|
||||
return defaultBundle(QLatin1String("qbs-bundle.json"), nullptr);
|
||||
}
|
||||
|
||||
QmlBundle BasicBundleProvider::defaultQmltypesBundle()
|
||||
{
|
||||
return defaultBundle(QLatin1String("qmltypes-bundle.json"));
|
||||
return defaultBundle(QLatin1String("qmltypes-bundle.json"), nullptr);
|
||||
}
|
||||
|
||||
QmlBundle BasicBundleProvider::defaultQmlprojectBundle()
|
||||
{
|
||||
return defaultBundle(QLatin1String("qmlproject-bundle.json"));
|
||||
return defaultBundle(QLatin1String("qmlproject-bundle.json"), nullptr);
|
||||
}
|
||||
|
||||
void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
@@ -84,7 +86,7 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
|
||||
QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit);
|
||||
if (!qtVersion) {
|
||||
QmlBundle b2(defaultQt5QtQuick2Bundle(false));
|
||||
QmlBundle b2(defaultQt5QtQuick2Bundle(qtVersion));
|
||||
bundles.mergeBundleForLanguage(Dialect::Qml, b2);
|
||||
bundles.mergeBundleForLanguage(Dialect::QmlQtQuick2, b2);
|
||||
bundles.mergeBundleForLanguage(Dialect::QmlQtQuick2Ui, b2);
|
||||
@@ -97,17 +99,18 @@ void BasicBundleProvider::mergeBundlesForKit(ProjectExplorer::Kit *kit
|
||||
qtQuick2Bundles.setNameFilters(QStringList(QLatin1String("*-bundle.json")));
|
||||
QmlBundle qtQuick2Bundle;
|
||||
QFileInfoList list = qtQuick2Bundles.entryInfoList();
|
||||
bool stripVersions = qtVersion->qtVersion().majorVersion() > 5;
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
QmlBundle bAtt;
|
||||
QStringList errors;
|
||||
if (!bAtt.readFrom(list.value(i).filePath(), &errors))
|
||||
if (!bAtt.readFrom(list.value(i).filePath(), stripVersions, &errors))
|
||||
qWarning() << "BasicBundleProvider: ERROR reading " << list[i].filePath() << " : "
|
||||
<< errors;
|
||||
qtQuick2Bundle.merge(bAtt);
|
||||
}
|
||||
if (!qtQuick2Bundle.supportedImports().contains(QLatin1String("QtQuick 2."),
|
||||
PersistentTrie::Partial)) {
|
||||
qtQuick2Bundle.merge(defaultQt5QtQuick2Bundle(qtVersion->qtVersion().majorVersion() >= 6));
|
||||
qtQuick2Bundle.merge(defaultQt5QtQuick2Bundle(qtVersion));
|
||||
}
|
||||
qtQuick2Bundle.replaceVars(myReplacements);
|
||||
bundles.mergeBundleForLanguage(Dialect::Qml, qtQuick2Bundle);
|
||||
|
||||
@@ -19,6 +19,10 @@ class QmlLanguageBundles;
|
||||
class QmlBundle;
|
||||
} // namespace QmlJS
|
||||
|
||||
namespace QtSupport {
|
||||
class QtVersion;
|
||||
}
|
||||
|
||||
namespace QmlJSTools {
|
||||
|
||||
class QMLJSTOOLS_EXPORT IBundleProvider : public QObject
|
||||
@@ -43,8 +47,9 @@ public:
|
||||
void mergeBundlesForKit(ProjectExplorer::Kit *kit, QmlJS::QmlLanguageBundles &bundles,
|
||||
const QHash<QString,QString> &replacements) override;
|
||||
|
||||
static QmlJS::QmlBundle defaultBundle(const QString &bundleInfoName);
|
||||
static QmlJS::QmlBundle defaultQt5QtQuick2Bundle(bool enhance);
|
||||
static QmlJS::QmlBundle defaultBundle(const QString &bundleInfoName,
|
||||
QtSupport::QtVersion *qtVersion);
|
||||
static QmlJS::QmlBundle defaultQt5QtQuick2Bundle(QtSupport::QtVersion *qtVersion);
|
||||
static QmlJS::QmlBundle defaultQbsBundle();
|
||||
static QmlJS::QmlBundle defaultQmltypesBundle();
|
||||
static QmlJS::QmlBundle defaultQmlprojectBundle();
|
||||
|
||||
Reference in New Issue
Block a user