QmlJS: remove qtquick1 leftovers

QT_INSTALL_IMPORTS and the used ProjectInfo.qtImportsPath variable
were only used for QtQuick1.

Change-Id: I34da0cfc77effa84f3a7578e7f91fed0768a9bf4
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Tim Jenssen
2019-01-17 14:06:53 +01:00
parent d4beced19f
commit 372e239d2d
7 changed files with 14 additions and 67 deletions

View File

@@ -2229,12 +2229,6 @@ ImportInfo::ImportInfo()
ImportInfo ImportInfo::moduleImport(QString uri, ComponentVersion version, ImportInfo ImportInfo::moduleImport(QString uri, ComponentVersion version,
const QString &as, UiImport *ast) const QString &as, UiImport *ast)
{ {
// treat Qt 4.7 as QtQuick 1.0
if (uri == QLatin1String("Qt") && version == ComponentVersion(4, 7)) {
uri = QLatin1String("QtQuick");
version = ComponentVersion(1, 0);
}
ImportInfo info; ImportInfo info;
info.m_type = ImportType::Library; info.m_type = ImportType::Library;
info.m_name = uri; info.m_name = uri;

View File

@@ -120,8 +120,6 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
qRegisterMetaType<QmlJS::PathAndLanguage>("QmlJS::PathAndLanguage"); qRegisterMetaType<QmlJS::PathAndLanguage>("QmlJS::PathAndLanguage");
qRegisterMetaType<QmlJS::PathsAndLanguages>("QmlJS::PathsAndLanguages"); qRegisterMetaType<QmlJS::PathsAndLanguages>("QmlJS::PathsAndLanguages");
m_defaultProjectInfo.qtImportsPath = QFileInfo(
QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
m_defaultProjectInfo.qtQmlPath = QFileInfo( m_defaultProjectInfo.qtQmlPath = QFileInfo(
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath(); QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
@@ -410,10 +408,6 @@ bool pInfoLessThanImports(const ModelManagerInterface::ProjectInfo &p1, const Mo
return true; return true;
if (p1.qtQmlPath > p2.qtQmlPath) if (p1.qtQmlPath > p2.qtQmlPath)
return false; return false;
if (p1.qtImportsPath < p2.qtImportsPath)
return true;
if (p1.qtImportsPath > p2.qtImportsPath)
return false;
const PathsAndLanguages &s1 = p1.importPaths; const PathsAndLanguages &s1 = p1.importPaths;
const PathsAndLanguages &s2 = p2.importPaths; const PathsAndLanguages &s2 = p2.importPaths;
if (s1.size() < s2.size()) if (s1.size() < s2.size())
@@ -537,7 +531,6 @@ void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectE
if (oldInfo.qmlDumpPath != pinfo.qmlDumpPath if (oldInfo.qmlDumpPath != pinfo.qmlDumpPath
|| oldInfo.qmlDumpEnvironment != pinfo.qmlDumpEnvironment) { || oldInfo.qmlDumpEnvironment != pinfo.qmlDumpEnvironment) {
m_pluginDumper->scheduleRedumpPlugins(); m_pluginDumper->scheduleRedumpPlugins();
m_pluginDumper->scheduleMaybeRedumpBuiltins(pinfo);
} }
@@ -609,12 +602,8 @@ void ModelManagerInterface::removeProjectInfo(ProjectExplorer::Project *project)
*/ */
ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(const QString &path) const ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(const QString &path) const
{ {
QList<ProjectInfo> infos = allProjectInfosForPath(path);
ProjectInfo res; ProjectInfo res;
foreach (const ProjectInfo &pInfo, infos) { foreach (const ProjectInfo &pInfo, allProjectInfosForPath(path)) {
if (res.qtImportsPath.isEmpty())
res.qtImportsPath = pInfo.qtImportsPath;
if (res.qtQmlPath.isEmpty()) if (res.qtQmlPath.isEmpty())
res.qtQmlPath = pInfo.qtQmlPath; res.qtQmlPath = pInfo.qtQmlPath;
for (int i = 0; i < pInfo.importPaths.size(); ++i) for (int i = 0; i < pInfo.importPaths.size(); ++i)
@@ -1346,12 +1335,10 @@ ModelManagerInterface::CppDataHash ModelManagerInterface::cppData() const
LibraryInfo ModelManagerInterface::builtins(const Document::Ptr &doc) const LibraryInfo ModelManagerInterface::builtins(const Document::Ptr &doc) const
{ {
ProjectInfo info = projectInfoForPath(doc->fileName()); const ProjectInfo info = projectInfoForPath(doc->fileName());
if (!info.isValid()) if (info.isValid() && !info.qtQmlPath.isEmpty())
return LibraryInfo();
if (!info.qtQmlPath.isEmpty())
return m_validSnapshot.libraryInfo(info.qtQmlPath); return m_validSnapshot.libraryInfo(info.qtQmlPath);
return m_validSnapshot.libraryInfo(info.qtImportsPath); return LibraryInfo();
} }
ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx, ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
@@ -1370,8 +1357,6 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
info = projectInfoForPath(doc->fileName()); info = projectInfoForPath(doc->fileName());
ViewerContext defaultVCtx = defaultVContext(res.language, Document::Ptr(nullptr), false); ViewerContext defaultVCtx = defaultVContext(res.language, Document::Ptr(nullptr), false);
ProjectInfo defaultInfo = defaultProjectInfo(); ProjectInfo defaultInfo = defaultProjectInfo();
if (info.qtImportsPath.isEmpty())
info.qtImportsPath = defaultInfo.qtImportsPath;
if (info.qtQmlPath.isEmpty()) if (info.qtQmlPath.isEmpty())
info.qtQmlPath = defaultInfo.qtQmlPath; info.qtQmlPath = defaultInfo.qtQmlPath;
switch (res.flags) { switch (res.flags) {
@@ -1388,7 +1373,6 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
case Dialect::AnyLanguage: case Dialect::AnyLanguage:
case Dialect::Qml: case Dialect::Qml:
res.maybeAddPath(info.qtQmlPath); res.maybeAddPath(info.qtQmlPath);
res.maybeAddPath(info.qtImportsPath);
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case Dialect::QmlQtQuick2: case Dialect::QmlQtQuick2:
case Dialect::QmlQtQuick2Ui: case Dialect::QmlQtQuick2Ui:
@@ -1429,9 +1413,6 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
case ViewerContext::AddDefaultPaths: case ViewerContext::AddDefaultPaths:
foreach (const QString &path, defaultVCtx.paths) foreach (const QString &path, defaultVCtx.paths)
res.maybeAddPath(path); res.maybeAddPath(path);
if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml
|| res.language == Dialect::QmlQtQuick2 || res.language == Dialect::QmlQtQuick2Ui)
res.maybeAddPath(info.qtImportsPath);
if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml) if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml)
res.maybeAddPath(info.qtQmlPath); res.maybeAddPath(info.qtQmlPath);
if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml

View File

@@ -94,7 +94,6 @@ public:
QString qmlDumpPath; QString qmlDumpPath;
::Utils::Environment qmlDumpEnvironment; ::Utils::Environment qmlDumpEnvironment;
QString qtImportsPath;
QString qtQmlPath; QString qtQmlPath;
QString qtVersionString; QString qtVersionString;
QmlJS::QmlLanguageBundles activeBundle; QmlJS::QmlLanguageBundles activeBundle;

View File

@@ -83,42 +83,34 @@ void PluginDumper::scheduleRedumpPlugins()
metaObject()->invokeMethod(this, "dumpAllPlugins", Qt::QueuedConnection); metaObject()->invokeMethod(this, "dumpAllPlugins", Qt::QueuedConnection);
} }
void PluginDumper::scheduleMaybeRedumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info)
{
// move to the owning thread
metaObject()->invokeMethod(this, "dumpBuiltins", Qt::QueuedConnection,
Q_ARG(QmlJS::ModelManagerInterface::ProjectInfo, info));
}
void PluginDumper::onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info, bool force) void PluginDumper::onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info, bool force)
{ {
const QString baseImportsPath = info.qtQmlPath.isEmpty() ? info.qtImportsPath : info.qtQmlPath; if (info.qmlDumpPath.isEmpty() || info.qtQmlPath.isEmpty())
if (info.qmlDumpPath.isEmpty() || baseImportsPath.isEmpty())
return; return;
const QString importsPath = QDir::cleanPath(baseImportsPath); const QString importsPath = QDir::cleanPath(info.qtQmlPath);
if (m_runningQmldumps.values().contains(importsPath)) if (m_runningQmldumps.values().contains(importsPath))
return; return;
LibraryInfo builtinInfo; LibraryInfo builtinInfo;
if (!force) { if (!force) {
const Snapshot snapshot = m_modelManager->snapshot(); const Snapshot snapshot = m_modelManager->snapshot();
builtinInfo = snapshot.libraryInfo(baseImportsPath); builtinInfo = snapshot.libraryInfo(info.qtQmlPath);
if (builtinInfo.isValid()) if (builtinInfo.isValid())
return; return;
} }
builtinInfo = LibraryInfo(LibraryInfo::Found); builtinInfo = LibraryInfo(LibraryInfo::Found);
m_modelManager->updateLibraryInfo(baseImportsPath, builtinInfo); m_modelManager->updateLibraryInfo(info.qtQmlPath, builtinInfo);
// prefer QTDIR/qml/builtins.qmltypes if available // prefer QTDIR/qml/builtins.qmltypes if available
const QString builtinQmltypesPath = baseImportsPath + QLatin1String("/builtins.qmltypes"); const QString builtinQmltypesPath = info.qtQmlPath + QLatin1String("/builtins.qmltypes");
if (QFile::exists(builtinQmltypesPath)) { if (QFile::exists(builtinQmltypesPath)) {
loadQmltypesFile(QStringList(builtinQmltypesPath), baseImportsPath, builtinInfo); loadQmltypesFile(QStringList(builtinQmltypesPath), info.qtQmlPath, builtinInfo);
return; return;
} }
runQmlDump(info, QStringList(QLatin1String("--builtins")), baseImportsPath); runQmlDump(info, QStringList(QLatin1String("--builtins")), info.qtQmlPath);
m_qtToInfo.insert(baseImportsPath, info); m_qtToInfo.insert(info.qtQmlPath, info);
} }
static QString makeAbsolute(const QString &path, const QString &base) static QString makeAbsolute(const QString &path, const QString &base)
@@ -190,19 +182,6 @@ void PluginDumper::onLoadPluginTypes(const QString &libraryPath, const QString &
dump(plugin); dump(plugin);
} }
void PluginDumper::dumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info)
{
// if the builtin types were generated with a different qmldump, regenerate!
if (m_qtToInfo.contains(info.qtImportsPath)) {
QmlJS::ModelManagerInterface::ProjectInfo oldInfo = m_qtToInfo.value(info.qtImportsPath);
if (oldInfo.qmlDumpPath != info.qmlDumpPath
|| oldInfo.qmlDumpEnvironment != info.qmlDumpEnvironment) {
m_qtToInfo.remove(info.qtImportsPath);
onLoadBuiltinTypes(info, true);
}
}
}
void PluginDumper::dumpAllPlugins() void PluginDumper::dumpAllPlugins()
{ {
foreach (const Plugin &plugin, m_plugins) { foreach (const Plugin &plugin, m_plugins) {

View File

@@ -50,14 +50,12 @@ public:
void loadPluginTypes(const QString &libraryPath, const QString &importPath, void loadPluginTypes(const QString &libraryPath, const QString &importPath,
const QString &importUri, const QString &importVersion); const QString &importUri, const QString &importVersion);
void scheduleRedumpPlugins(); void scheduleRedumpPlugins();
void scheduleMaybeRedumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info);
private: private:
Q_INVOKABLE void onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info, Q_INVOKABLE void onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info,
bool force = false); bool force = false);
Q_INVOKABLE void onLoadPluginTypes(const QString &libraryPath, const QString &importPath, Q_INVOKABLE void onLoadPluginTypes(const QString &libraryPath, const QString &importPath,
const QString &importUri, const QString &importVersion); const QString &importUri, const QString &importVersion);
Q_INVOKABLE void dumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info);
Q_INVOKABLE void dumpAllPlugins(); Q_INVOKABLE void dumpAllPlugins();
void qmlPluginTypeDumpDone(int exitCode); void qmlPluginTypeDumpDone(int exitCode);
void qmlPluginTypeDumpError(QProcess::ProcessError error); void qmlPluginTypeDumpError(QProcess::ProcessError error);

View File

@@ -88,7 +88,7 @@ void QmlTaskManager::collectMessages(
QHash<QString, QList<DiagnosticMessage> > linkMessages; QHash<QString, QList<DiagnosticMessage> > linkMessages;
ContextPtr context; ContextPtr context;
if (updateSemantic) { if (updateSemantic) {
QmlJS::Link link(snapshot, vContext, snapshot.libraryInfo(info.qtImportsPath)); QmlJS::Link link(snapshot, vContext, QmlJS::LibraryInfo());
context = link(&linkMessages); context = link(&linkMessages);
} }

View File

@@ -119,11 +119,9 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
if (qtVersion && qtVersion->isValid()) { if (qtVersion && qtVersion->isValid()) {
projectInfo.tryQmlDump = project && qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT); projectInfo.tryQmlDump = project && qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT);
projectInfo.qtQmlPath = qtVersion->qmlPath().toFileInfo().canonicalFilePath(); projectInfo.qtQmlPath = qtVersion->qmlPath().toFileInfo().canonicalFilePath();
projectInfo.qtImportsPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_IMPORTS")).canonicalFilePath();
projectInfo.qtVersionString = qtVersion->qtVersionString(); projectInfo.qtVersionString = qtVersion->qtVersionString();
} else { } else {
projectInfo.qtQmlPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath(); projectInfo.qtQmlPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
projectInfo.qtImportsPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
projectInfo.qtVersionString = QLatin1String(qVersion()); projectInfo.qtVersionString = QLatin1String(qVersion());
} }
@@ -149,9 +147,7 @@ void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
if (projectInfo.project) if (projectInfo.project)
activeTarget = projectInfo.project->activeTarget(); activeTarget = projectInfo.project->activeTarget();
Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit(); Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
QHash<QString, QString> replacements; const QHash<QString, QString> replacements = {{QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath}};
replacements.insert(QLatin1String("$(QT_INSTALL_IMPORTS)"), projectInfo.qtImportsPath);
replacements.insert(QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath);
for (IBundleProvider *bp : IBundleProvider::allBundleProviders()) for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
bp->mergeBundlesForKit(activeKit, projectInfo.activeBundle, replacements); bp->mergeBundlesForKit(activeKit, projectInfo.activeBundle, replacements);