forked from qt-creator/qt-creator
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:
@@ -2229,12 +2229,6 @@ ImportInfo::ImportInfo()
|
||||
ImportInfo ImportInfo::moduleImport(QString uri, ComponentVersion version,
|
||||
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;
|
||||
info.m_type = ImportType::Library;
|
||||
info.m_name = uri;
|
||||
|
||||
@@ -120,8 +120,6 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
||||
qRegisterMetaType<QmlJS::PathAndLanguage>("QmlJS::PathAndLanguage");
|
||||
qRegisterMetaType<QmlJS::PathsAndLanguages>("QmlJS::PathsAndLanguages");
|
||||
|
||||
m_defaultProjectInfo.qtImportsPath = QFileInfo(
|
||||
QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
|
||||
m_defaultProjectInfo.qtQmlPath = QFileInfo(
|
||||
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
||||
|
||||
@@ -410,10 +408,6 @@ bool pInfoLessThanImports(const ModelManagerInterface::ProjectInfo &p1, const Mo
|
||||
return true;
|
||||
if (p1.qtQmlPath > p2.qtQmlPath)
|
||||
return false;
|
||||
if (p1.qtImportsPath < p2.qtImportsPath)
|
||||
return true;
|
||||
if (p1.qtImportsPath > p2.qtImportsPath)
|
||||
return false;
|
||||
const PathsAndLanguages &s1 = p1.importPaths;
|
||||
const PathsAndLanguages &s2 = p2.importPaths;
|
||||
if (s1.size() < s2.size())
|
||||
@@ -537,7 +531,6 @@ void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectE
|
||||
if (oldInfo.qmlDumpPath != pinfo.qmlDumpPath
|
||||
|| oldInfo.qmlDumpEnvironment != pinfo.qmlDumpEnvironment) {
|
||||
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
|
||||
{
|
||||
QList<ProjectInfo> infos = allProjectInfosForPath(path);
|
||||
|
||||
ProjectInfo res;
|
||||
foreach (const ProjectInfo &pInfo, infos) {
|
||||
if (res.qtImportsPath.isEmpty())
|
||||
res.qtImportsPath = pInfo.qtImportsPath;
|
||||
foreach (const ProjectInfo &pInfo, allProjectInfosForPath(path)) {
|
||||
if (res.qtQmlPath.isEmpty())
|
||||
res.qtQmlPath = pInfo.qtQmlPath;
|
||||
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
|
||||
{
|
||||
ProjectInfo info = projectInfoForPath(doc->fileName());
|
||||
if (!info.isValid())
|
||||
return LibraryInfo();
|
||||
if (!info.qtQmlPath.isEmpty())
|
||||
const ProjectInfo info = projectInfoForPath(doc->fileName());
|
||||
if (info.isValid() && !info.qtQmlPath.isEmpty())
|
||||
return m_validSnapshot.libraryInfo(info.qtQmlPath);
|
||||
return m_validSnapshot.libraryInfo(info.qtImportsPath);
|
||||
return LibraryInfo();
|
||||
}
|
||||
|
||||
ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
|
||||
@@ -1370,8 +1357,6 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
|
||||
info = projectInfoForPath(doc->fileName());
|
||||
ViewerContext defaultVCtx = defaultVContext(res.language, Document::Ptr(nullptr), false);
|
||||
ProjectInfo defaultInfo = defaultProjectInfo();
|
||||
if (info.qtImportsPath.isEmpty())
|
||||
info.qtImportsPath = defaultInfo.qtImportsPath;
|
||||
if (info.qtQmlPath.isEmpty())
|
||||
info.qtQmlPath = defaultInfo.qtQmlPath;
|
||||
switch (res.flags) {
|
||||
@@ -1388,7 +1373,6 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
|
||||
case Dialect::AnyLanguage:
|
||||
case Dialect::Qml:
|
||||
res.maybeAddPath(info.qtQmlPath);
|
||||
res.maybeAddPath(info.qtImportsPath);
|
||||
Q_FALLTHROUGH();
|
||||
case Dialect::QmlQtQuick2:
|
||||
case Dialect::QmlQtQuick2Ui:
|
||||
@@ -1429,9 +1413,6 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
|
||||
case ViewerContext::AddDefaultPaths:
|
||||
foreach (const QString &path, defaultVCtx.paths)
|
||||
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)
|
||||
res.maybeAddPath(info.qtQmlPath);
|
||||
if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml
|
||||
|
||||
@@ -94,7 +94,6 @@ public:
|
||||
QString qmlDumpPath;
|
||||
::Utils::Environment qmlDumpEnvironment;
|
||||
|
||||
QString qtImportsPath;
|
||||
QString qtQmlPath;
|
||||
QString qtVersionString;
|
||||
QmlJS::QmlLanguageBundles activeBundle;
|
||||
|
||||
@@ -83,42 +83,34 @@ void PluginDumper::scheduleRedumpPlugins()
|
||||
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)
|
||||
{
|
||||
const QString baseImportsPath = info.qtQmlPath.isEmpty() ? info.qtImportsPath : info.qtQmlPath;
|
||||
if (info.qmlDumpPath.isEmpty() || baseImportsPath.isEmpty())
|
||||
if (info.qmlDumpPath.isEmpty() || info.qtQmlPath.isEmpty())
|
||||
return;
|
||||
|
||||
const QString importsPath = QDir::cleanPath(baseImportsPath);
|
||||
const QString importsPath = QDir::cleanPath(info.qtQmlPath);
|
||||
if (m_runningQmldumps.values().contains(importsPath))
|
||||
return;
|
||||
|
||||
LibraryInfo builtinInfo;
|
||||
if (!force) {
|
||||
const Snapshot snapshot = m_modelManager->snapshot();
|
||||
builtinInfo = snapshot.libraryInfo(baseImportsPath);
|
||||
builtinInfo = snapshot.libraryInfo(info.qtQmlPath);
|
||||
if (builtinInfo.isValid())
|
||||
return;
|
||||
}
|
||||
builtinInfo = LibraryInfo(LibraryInfo::Found);
|
||||
m_modelManager->updateLibraryInfo(baseImportsPath, builtinInfo);
|
||||
m_modelManager->updateLibraryInfo(info.qtQmlPath, builtinInfo);
|
||||
|
||||
// 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)) {
|
||||
loadQmltypesFile(QStringList(builtinQmltypesPath), baseImportsPath, builtinInfo);
|
||||
loadQmltypesFile(QStringList(builtinQmltypesPath), info.qtQmlPath, builtinInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
runQmlDump(info, QStringList(QLatin1String("--builtins")), baseImportsPath);
|
||||
m_qtToInfo.insert(baseImportsPath, info);
|
||||
runQmlDump(info, QStringList(QLatin1String("--builtins")), info.qtQmlPath);
|
||||
m_qtToInfo.insert(info.qtQmlPath, info);
|
||||
}
|
||||
|
||||
static QString makeAbsolute(const QString &path, const QString &base)
|
||||
@@ -190,19 +182,6 @@ void PluginDumper::onLoadPluginTypes(const QString &libraryPath, const QString &
|
||||
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()
|
||||
{
|
||||
foreach (const Plugin &plugin, m_plugins) {
|
||||
|
||||
@@ -50,14 +50,12 @@ public:
|
||||
void loadPluginTypes(const QString &libraryPath, const QString &importPath,
|
||||
const QString &importUri, const QString &importVersion);
|
||||
void scheduleRedumpPlugins();
|
||||
void scheduleMaybeRedumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info);
|
||||
|
||||
private:
|
||||
Q_INVOKABLE void onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info,
|
||||
bool force = false);
|
||||
Q_INVOKABLE void onLoadPluginTypes(const QString &libraryPath, const QString &importPath,
|
||||
const QString &importUri, const QString &importVersion);
|
||||
Q_INVOKABLE void dumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info);
|
||||
Q_INVOKABLE void dumpAllPlugins();
|
||||
void qmlPluginTypeDumpDone(int exitCode);
|
||||
void qmlPluginTypeDumpError(QProcess::ProcessError error);
|
||||
|
||||
@@ -88,7 +88,7 @@ void QmlTaskManager::collectMessages(
|
||||
QHash<QString, QList<DiagnosticMessage> > linkMessages;
|
||||
ContextPtr context;
|
||||
if (updateSemantic) {
|
||||
QmlJS::Link link(snapshot, vContext, snapshot.libraryInfo(info.qtImportsPath));
|
||||
QmlJS::Link link(snapshot, vContext, QmlJS::LibraryInfo());
|
||||
context = link(&linkMessages);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,11 +119,9 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
|
||||
if (qtVersion && qtVersion->isValid()) {
|
||||
projectInfo.tryQmlDump = project && qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT);
|
||||
projectInfo.qtQmlPath = qtVersion->qmlPath().toFileInfo().canonicalFilePath();
|
||||
projectInfo.qtImportsPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_IMPORTS")).canonicalFilePath();
|
||||
projectInfo.qtVersionString = qtVersion->qtVersionString();
|
||||
} else {
|
||||
projectInfo.qtQmlPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
||||
projectInfo.qtImportsPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
|
||||
projectInfo.qtVersionString = QLatin1String(qVersion());
|
||||
}
|
||||
|
||||
@@ -149,9 +147,7 @@ void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
|
||||
if (projectInfo.project)
|
||||
activeTarget = projectInfo.project->activeTarget();
|
||||
Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
|
||||
QHash<QString, QString> replacements;
|
||||
replacements.insert(QLatin1String("$(QT_INSTALL_IMPORTS)"), projectInfo.qtImportsPath);
|
||||
replacements.insert(QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath);
|
||||
const QHash<QString, QString> replacements = {{QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath}};
|
||||
|
||||
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
||||
bp->mergeBundlesForKit(activeKit, projectInfo.activeBundle, replacements);
|
||||
|
||||
Reference in New Issue
Block a user