2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-02-15 13:49:00 +01:00
|
|
|
#include "qmljsmodelmanager.h"
|
2010-11-11 10:05:05 +01:00
|
|
|
#include "qmljstoolsconstants.h"
|
2012-04-13 11:57:34 +02:00
|
|
|
#include "qmljssemanticinfo.h"
|
2012-12-06 17:20:58 +01:00
|
|
|
#include "qmljsbundleprovider.h"
|
2009-09-04 16:51:11 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2015-02-26 13:22:35 +01:00
|
|
|
#include <coreplugin/editormanager/documentmodel.h>
|
2015-03-05 08:22:48 +01:00
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2011-05-30 12:56:24 +02:00
|
|
|
#include <coreplugin/messagemanager.h>
|
2014-01-23 14:28:31 +01:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2017-12-08 17:20:48 +01:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
#include <cppeditor/cppmodelmanager.h>
|
2017-12-08 17:20:48 +01:00
|
|
|
|
2012-12-06 17:20:58 +01:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2020-03-23 14:14:03 +01:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2010-06-22 12:54:19 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2014-11-19 17:58:33 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2017-03-27 14:57:24 +02:00
|
|
|
#include <projectexplorer/projectnodes.h>
|
2014-11-19 17:58:33 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2019-10-22 16:29:40 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2012-12-06 17:20:58 +01:00
|
|
|
#include <projectexplorer/target.h>
|
2020-03-23 14:14:03 +01:00
|
|
|
|
2014-01-23 14:28:31 +01:00
|
|
|
#include <qmljs/qmljsbind.h>
|
|
|
|
|
#include <qmljs/qmljsfindexportedcpptypes.h>
|
|
|
|
|
#include <qmljs/qmljsplugindumper.h>
|
|
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-12-06 17:20:58 +01:00
|
|
|
#include <qtsupport/qtsupportconstants.h>
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
2017-12-06 10:27:27 +01:00
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
2014-01-23 14:28:31 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2022-02-23 17:11:20 +01:00
|
|
|
#include <utils/mimeutils.h>
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QFileInfo>
|
2023-01-27 03:32:13 +01:00
|
|
|
#include <QLibraryInfo>
|
2013-07-17 11:27:46 +02:00
|
|
|
#include <QTextDocument>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QTimer>
|
2017-03-27 14:57:24 +02:00
|
|
|
#include <QSet>
|
|
|
|
|
#include <QString>
|
2014-04-11 23:07:52 +02:00
|
|
|
#include <qglobal.h>
|
2009-10-01 16:38:08 +02:00
|
|
|
|
2015-02-27 09:02:42 +02:00
|
|
|
using namespace Utils;
|
2013-08-30 09:22:42 +02:00
|
|
|
using namespace Core;
|
2015-02-27 09:02:42 +02:00
|
|
|
using namespace ProjectExplorer;
|
2010-01-25 14:18:53 +01:00
|
|
|
using namespace QmlJS;
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2015-02-27 09:02:42 +02:00
|
|
|
namespace QmlJSTools {
|
|
|
|
|
namespace Internal {
|
2012-12-06 17:20:58 +01:00
|
|
|
|
2019-10-23 14:53:01 +02:00
|
|
|
static void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &projectInfo)
|
|
|
|
|
{
|
|
|
|
|
Target *activeTarget = nullptr;
|
|
|
|
|
if (projectInfo.project)
|
|
|
|
|
activeTarget = projectInfo.project->activeTarget();
|
|
|
|
|
Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
|
2021-10-12 17:32:48 +02:00
|
|
|
const QHash<QString, QString> replacements = {{QLatin1String("$(QT_INSTALL_QML)"), projectInfo.qtQmlPath.toString()}};
|
2019-10-23 14:53:01 +02:00
|
|
|
|
|
|
|
|
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
|
|
|
|
bp->mergeBundlesForKit(activeKit, projectInfo.activeBundle, replacements);
|
|
|
|
|
|
|
|
|
|
projectInfo.extendedBundle = projectInfo.activeBundle;
|
|
|
|
|
|
|
|
|
|
if (projectInfo.project) {
|
|
|
|
|
QSet<Kit *> currentKits;
|
2022-05-31 16:42:57 +02:00
|
|
|
const QList<Target *> targets = projectInfo.project->targets();
|
|
|
|
|
for (const Target *t : targets)
|
2019-10-23 14:53:01 +02:00
|
|
|
currentKits.insert(t->kit());
|
|
|
|
|
currentKits.remove(activeKit);
|
2022-10-07 14:46:06 +02:00
|
|
|
for (Kit *kit : std::as_const(currentKits)) {
|
2019-10-23 14:53:01 +02:00
|
|
|
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
|
|
|
|
bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-25 08:57:49 +02:00
|
|
|
static void findAllQrcFiles(const FilePath &filePath, FilePaths &out)
|
|
|
|
|
{
|
|
|
|
|
filePath.iterateDirectory(
|
|
|
|
|
[&out](const FilePath &path) {
|
|
|
|
|
out.append(path.canonicalPath());
|
2023-01-24 11:23:47 +01:00
|
|
|
return IterationPolicy::Continue;
|
2022-10-25 08:57:49 +02:00
|
|
|
},
|
|
|
|
|
{{"*.qrc"}, QDir::Files});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static FilePaths findGeneratedQrcFiles(const ModelManagerInterface::ProjectInfo &pInfo,
|
|
|
|
|
const FilePaths &hiddenRccFolders)
|
|
|
|
|
{
|
|
|
|
|
FilePaths result;
|
|
|
|
|
// Search in Application Directories for directories named ".rcc"
|
|
|
|
|
// and add all .qrc files in there to the resource file list.
|
|
|
|
|
for (const Utils::FilePath &path : pInfo.applicationDirectories) {
|
|
|
|
|
Utils::FilePath generatedQrcDir = path.pathAppended(".rcc");
|
|
|
|
|
findAllQrcFiles(generatedQrcDir, result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const Utils::FilePath &hiddenRccFolder : hiddenRccFolders) {
|
|
|
|
|
findAllQrcFiles(hiddenRccFolder, result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
|
2022-10-25 08:57:49 +02:00
|
|
|
Project *project, const FilePaths &hiddenRccFolders) const
|
2012-12-06 17:20:58 +01:00
|
|
|
{
|
2019-10-23 14:03:13 +02:00
|
|
|
ModelManagerInterface::ProjectInfo projectInfo;
|
|
|
|
|
projectInfo.project = project;
|
2017-06-08 15:20:11 +02:00
|
|
|
projectInfo.qmlDumpEnvironment = Utils::Environment::systemEnvironment();
|
2017-03-27 14:57:24 +02:00
|
|
|
Target *activeTarget = nullptr;
|
2012-12-06 17:20:58 +01:00
|
|
|
if (project) {
|
2017-03-27 14:57:24 +02:00
|
|
|
const QSet<QString> qmlTypeNames = { Constants::QML_MIMETYPE ,Constants::QBS_MIMETYPE,
|
|
|
|
|
Constants::QMLPROJECT_MIMETYPE,
|
|
|
|
|
Constants::QMLTYPES_MIMETYPE,
|
|
|
|
|
Constants::QMLUI_MIMETYPE };
|
2022-06-20 12:35:13 +02:00
|
|
|
projectInfo.sourceFiles = project->files([&qmlTypeNames](const Node *n) {
|
2017-12-06 10:58:59 +01:00
|
|
|
if (!Project::SourceFiles(n))
|
|
|
|
|
return false;
|
|
|
|
|
const FileNode *fn = n->asFileNode();
|
|
|
|
|
return fn && fn->fileType() == FileType::QML
|
2021-05-18 14:35:07 +02:00
|
|
|
&& qmlTypeNames.contains(Utils::mimeTypeForFile(fn->filePath(),
|
2017-12-06 10:58:59 +01:00
|
|
|
MimeMatchMode::MatchExtension).name());
|
2022-06-20 12:35:13 +02:00
|
|
|
});
|
2012-12-06 17:20:58 +01:00
|
|
|
activeTarget = project->activeTarget();
|
|
|
|
|
}
|
2015-02-27 09:02:42 +02:00
|
|
|
Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit();
|
2022-01-21 16:06:36 +01:00
|
|
|
QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(activeKit);
|
2012-12-06 17:20:58 +01:00
|
|
|
|
|
|
|
|
projectInfo.tryQmlDump = false;
|
|
|
|
|
|
|
|
|
|
if (activeTarget) {
|
2022-06-20 12:35:13 +02:00
|
|
|
FilePath baseDir;
|
|
|
|
|
auto addAppDir = [&baseDir, &projectInfo](const FilePath &mdir) {
|
|
|
|
|
auto dir = mdir.cleanPath();
|
2022-01-14 10:19:09 +01:00
|
|
|
if (!baseDir.path().isEmpty()) {
|
2022-10-18 14:38:29 +02:00
|
|
|
auto rDir = dir.relativePathFrom(baseDir);
|
2022-01-14 10:19:09 +01:00
|
|
|
// do not add directories outside the build directory
|
|
|
|
|
// this might happen for example when we think an executable path belongs to
|
|
|
|
|
// a bundle, and we need to remove extra directories, but that was not the case
|
2022-06-20 12:35:13 +02:00
|
|
|
if (rDir.path().split(u'/').contains(QStringLiteral(u"..")))
|
2022-01-14 10:19:09 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!projectInfo.applicationDirectories.contains(dir))
|
|
|
|
|
projectInfo.applicationDirectories.append(dir);
|
|
|
|
|
};
|
|
|
|
|
|
2015-02-27 09:02:42 +02:00
|
|
|
if (BuildConfiguration *bc = activeTarget->activeBuildConfiguration()) {
|
2017-06-29 15:00:11 +02:00
|
|
|
// Append QML2_IMPORT_PATH if it is defined in build configuration.
|
|
|
|
|
// It enables qmlplugindump to correctly dump custom plugins or other dependent
|
|
|
|
|
// plugins that are not installed in default Qt qml installation directory.
|
2019-08-19 14:29:14 +02:00
|
|
|
projectInfo.qmlDumpEnvironment.appendOrSet("QML2_IMPORT_PATH", bc->environment().expandedValueForKey("QML2_IMPORT_PATH"), ":");
|
2022-01-14 10:19:09 +01:00
|
|
|
// Treat every target (library or application) in the build directory
|
2019-10-22 16:29:40 +02:00
|
|
|
|
2022-06-20 12:35:13 +02:00
|
|
|
FilePath dir = bc->buildDirectory();
|
|
|
|
|
baseDir = dir.absoluteFilePath();
|
2022-01-14 10:19:09 +01:00
|
|
|
addAppDir(dir);
|
|
|
|
|
}
|
|
|
|
|
// Qml loads modules from the following sources
|
|
|
|
|
// 1. The build directory of the executable
|
|
|
|
|
// 2. Any QML_IMPORT_PATH (environment variable) or IMPORT_PATH (parameter to qt_add_qml_module)
|
|
|
|
|
// 3. The Qt import path
|
|
|
|
|
// For an IDE things are a bit more complicated because source files might be edited,
|
|
|
|
|
// and the directory of the executable might be outdated.
|
|
|
|
|
// Here we try to get the directory of the executable, adding all targets
|
2020-03-23 14:14:03 +01:00
|
|
|
const auto appTargets = activeTarget->buildSystem()->applicationTargets();
|
2019-10-22 16:29:40 +02:00
|
|
|
for (const auto &target : appTargets) {
|
|
|
|
|
if (target.targetFilePath.isEmpty())
|
|
|
|
|
continue;
|
2022-01-14 10:19:09 +01:00
|
|
|
auto dir = target.targetFilePath.parentDir();
|
2022-06-20 12:35:13 +02:00
|
|
|
projectInfo.applicationDirectories.append(dir);
|
2022-01-14 10:19:09 +01:00
|
|
|
// unfortunately the build directory of the executable where cmake puts the qml
|
|
|
|
|
// might be different than the directory of the executable:
|
2022-06-20 12:35:13 +02:00
|
|
|
if (HostOsInfo::isWindowsHost()) {
|
|
|
|
|
// On Windows systems QML type information is located one directory higher as we build
|
|
|
|
|
// in dedicated "debug" and "release" directories
|
|
|
|
|
addAppDir(dir.parentDir());
|
|
|
|
|
} else if (HostOsInfo::isMacHost()) {
|
|
|
|
|
// On macOS and iOS when building a bundle this is not the case and
|
|
|
|
|
// we have to go up up to three additional directories
|
|
|
|
|
// (BundleName.app/Contents/MacOS or BundleName.app/Contents for iOS)
|
|
|
|
|
if (dir.fileName() == u"MacOS")
|
|
|
|
|
dir = dir.parentDir();
|
|
|
|
|
if (dir.fileName() == u"Contents")
|
|
|
|
|
dir = dir.parentDir().parentDir();
|
|
|
|
|
addAppDir(dir);
|
|
|
|
|
}
|
2019-10-22 16:29:40 +02:00
|
|
|
}
|
2012-12-06 17:20:58 +01:00
|
|
|
}
|
|
|
|
|
if (qtVersion && qtVersion->isValid()) {
|
2015-04-24 15:07:08 +02:00
|
|
|
projectInfo.tryQmlDump = project && qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT);
|
2021-10-12 17:32:48 +02:00
|
|
|
projectInfo.qtQmlPath = qtVersion->qmlPath();
|
2022-09-28 11:16:49 +02:00
|
|
|
auto v = qtVersion->qtVersion();
|
|
|
|
|
projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(qtVersion->hostBinPath(), v);
|
2012-12-06 17:20:58 +01:00
|
|
|
projectInfo.qtVersionString = qtVersion->qtVersionString();
|
2021-07-06 14:04:33 +02:00
|
|
|
} else if (!activeKit || !activeKit->value(QtSupport::SuppliesQtQuickImportPath::id(), false).toBool()) {
|
2023-06-06 14:32:35 +02:00
|
|
|
projectInfo.qtQmlPath = FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath));
|
2022-09-28 11:16:49 +02:00
|
|
|
projectInfo.qmllsPath = ModelManagerInterface::qmllsForBinPath(
|
2023-06-06 14:32:35 +02:00
|
|
|
FilePath::fromUserInput(QLibraryInfo::path(QLibraryInfo::BinariesPath)), QLibraryInfo::version());
|
2014-04-11 23:07:52 +02:00
|
|
|
projectInfo.qtVersionString = QLatin1String(qVersion());
|
2012-12-06 17:20:58 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-09 13:16:04 +01:00
|
|
|
projectInfo.qmlDumpPath.clear();
|
2022-01-21 16:06:36 +01:00
|
|
|
const QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(activeKit);
|
2021-03-09 13:16:04 +01:00
|
|
|
if (version && projectInfo.tryQmlDump) {
|
2021-10-12 17:32:48 +02:00
|
|
|
projectInfo.qmlDumpPath = version->qmlplugindumpFilePath();
|
2021-03-09 13:16:04 +01:00
|
|
|
projectInfo.qmlDumpHasRelocatableFlag = version->hasQmlDumpWithRelocatableFlag();
|
2012-12-06 17:20:58 +01:00
|
|
|
}
|
2021-03-09 13:16:04 +01:00
|
|
|
|
2012-12-06 17:20:58 +01:00
|
|
|
setupProjectInfoQmlBundles(projectInfo);
|
2022-10-25 08:57:49 +02:00
|
|
|
projectInfo.generatedQrcFiles = findGeneratedQrcFiles(projectInfo, hiddenRccFolders);
|
2012-12-06 17:20:58 +01:00
|
|
|
return projectInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-20 13:42:26 +02:00
|
|
|
QHash<QString,Dialect> ModelManager::initLanguageForSuffix() const
|
2012-12-06 12:11:12 +01:00
|
|
|
{
|
2015-02-03 23:48:57 +02:00
|
|
|
QHash<QString,Dialect> res = ModelManagerInterface::languageForSuffix();
|
2011-09-09 10:55:11 +02:00
|
|
|
|
2013-08-30 09:22:42 +02:00
|
|
|
if (ICore::instance()) {
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType jsSourceTy = Utils::mimeTypeForName(Constants::JS_MIMETYPE);
|
2022-05-31 16:42:57 +02:00
|
|
|
const QStringList jsSuffixes = jsSourceTy.suffixes();
|
|
|
|
|
for (const QString &suffix : jsSuffixes)
|
2014-07-22 19:06:44 +02:00
|
|
|
res[suffix] = Dialect::JavaScript;
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType qmlSourceTy = Utils::mimeTypeForName(Constants::QML_MIMETYPE);
|
2022-05-31 16:42:57 +02:00
|
|
|
const QStringList qmlSuffixes = qmlSourceTy.suffixes();
|
|
|
|
|
for (const QString &suffix : qmlSuffixes)
|
2014-07-22 19:06:44 +02:00
|
|
|
res[suffix] = Dialect::Qml;
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType qbsSourceTy = Utils::mimeTypeForName(Constants::QBS_MIMETYPE);
|
2022-05-31 16:42:57 +02:00
|
|
|
const QStringList qbsSuffixes = qbsSourceTy.suffixes();
|
|
|
|
|
for (const QString &suffix : qbsSuffixes)
|
2014-07-22 19:06:44 +02:00
|
|
|
res[suffix] = Dialect::QmlQbs;
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType qmlProjectSourceTy = Utils::mimeTypeForName(Constants::QMLPROJECT_MIMETYPE);
|
2022-05-31 16:42:57 +02:00
|
|
|
const QStringList qmlProjSuffixes = qmlProjectSourceTy.suffixes();
|
|
|
|
|
for (const QString &suffix : qmlProjSuffixes)
|
2014-07-22 19:06:44 +02:00
|
|
|
res[suffix] = Dialect::QmlProject;
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType qmlUiSourceTy = Utils::mimeTypeForName(Constants::QMLUI_MIMETYPE);
|
2022-05-31 16:42:57 +02:00
|
|
|
const QStringList qmlUiSuffixes = qmlUiSourceTy.suffixes();
|
|
|
|
|
for (const QString &suffix : qmlUiSuffixes)
|
2014-10-13 16:46:30 +02:00
|
|
|
res[suffix] = Dialect::QmlQtQuick2Ui;
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType jsonSourceTy = Utils::mimeTypeForName(Constants::JSON_MIMETYPE);
|
2022-05-31 16:42:57 +02:00
|
|
|
const QStringList jsonSuffixes = jsonSourceTy.suffixes();
|
|
|
|
|
for (const QString &suffix : jsonSuffixes)
|
2014-07-22 19:06:44 +02:00
|
|
|
res[suffix] = Dialect::Json;
|
2011-09-09 10:55:11 +02:00
|
|
|
}
|
2014-01-22 18:38:45 +01:00
|
|
|
return res;
|
2011-09-09 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-20 13:42:26 +02:00
|
|
|
QHash<QString,Dialect> ModelManager::languageForSuffix() const
|
|
|
|
|
{
|
|
|
|
|
static QHash<QString,Dialect> res = initLanguageForSuffix();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-08 10:40:29 +01:00
|
|
|
ModelManager::ModelManager()
|
2009-09-04 16:51:11 +02:00
|
|
|
{
|
2012-04-13 11:57:34 +02:00
|
|
|
qRegisterMetaType<QmlJSTools::SemanticInfo>("QmlJSTools::SemanticInfo");
|
2014-01-23 14:28:31 +01:00
|
|
|
loadDefaultQmlTypeDescriptions();
|
2010-03-01 13:01:05 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-24 10:22:37 +01:00
|
|
|
ModelManager::~ModelManager() = default;
|
2011-10-20 11:25:38 +02:00
|
|
|
|
2010-12-03 10:13:15 +01:00
|
|
|
void ModelManager::delayedInitialization()
|
|
|
|
|
{
|
2021-08-30 10:58:08 +02:00
|
|
|
CppEditor::CppModelManager *cppModelManager = CppEditor::CppModelManager::instance();
|
2015-02-15 23:13:28 +02:00
|
|
|
// It's important to have a direct connection here so we can prevent
|
|
|
|
|
// the source and AST of the cpp document being cleaned away.
|
2021-08-30 10:58:08 +02:00
|
|
|
connect(cppModelManager, &CppEditor::CppModelManager::documentUpdated,
|
2016-06-27 22:25:11 +03:00
|
|
|
this, &ModelManagerInterface::maybeQueueCppQmlTypeUpdate, Qt::DirectConnection);
|
2011-08-26 13:31:18 +02:00
|
|
|
|
2023-02-14 15:47:22 +01:00
|
|
|
connect(ProjectManager::instance(), &ProjectManager::projectRemoved,
|
2015-01-12 14:04:27 +01:00
|
|
|
this, &ModelManager::removeProjectInfo);
|
2023-02-14 15:47:22 +01:00
|
|
|
connect(ProjectManager::instance(), &ProjectManager::startupProjectChanged,
|
2014-11-19 17:58:33 +01:00
|
|
|
this, &ModelManager::updateDefaultProjectInfo);
|
2014-05-06 09:46:05 +02:00
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
ViewerContext qbsVContext;
|
2014-07-22 19:06:44 +02:00
|
|
|
qbsVContext.language = Dialect::QmlQbs;
|
2022-11-23 09:32:45 +01:00
|
|
|
qbsVContext.paths.insert(ICore::resourcePath("qbs"));
|
2014-05-06 09:46:05 +02:00
|
|
|
setDefaultVContext(qbsVContext);
|
2010-12-03 10:13:15 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 14:28:31 +01:00
|
|
|
void ModelManager::loadDefaultQmlTypeDescriptions()
|
2010-03-01 13:01:05 +01:00
|
|
|
{
|
2013-08-30 09:22:42 +02:00
|
|
|
if (ICore::instance()) {
|
2021-04-22 16:15:26 +02:00
|
|
|
loadQmlTypeDescriptionsInternal(ICore::resourcePath().toString());
|
|
|
|
|
loadQmlTypeDescriptionsInternal(ICore::userResourcePath().toString());
|
2010-11-10 16:21:05 +01:00
|
|
|
}
|
2010-09-08 10:11:44 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 14:28:31 +01:00
|
|
|
void ModelManager::writeMessageInternal(const QString &msg) const
|
2010-09-08 10:11:44 +02:00
|
|
|
{
|
2020-12-15 10:13:13 +01:00
|
|
|
MessageManager::writeFlashing(msg);
|
2009-09-04 16:51:11 +02:00
|
|
|
}
|
|
|
|
|
|
2014-01-23 14:28:31 +01:00
|
|
|
ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
|
2010-09-24 14:05:34 +02:00
|
|
|
{
|
|
|
|
|
WorkingCopy workingCopy;
|
2016-06-13 20:49:41 +02:00
|
|
|
|
|
|
|
|
if (!Core::ICore::instance())
|
|
|
|
|
return workingCopy;
|
|
|
|
|
|
2022-05-31 16:42:57 +02:00
|
|
|
const QList<IDocument *> documents = DocumentModel::openedDocuments();
|
|
|
|
|
for (IDocument *document : documents) {
|
2022-06-20 12:35:13 +02:00
|
|
|
const Utils::FilePath key = document->filePath();
|
2018-11-24 10:22:37 +01:00
|
|
|
if (auto textDocument = qobject_cast<const TextEditor::TextDocument *>(document)) {
|
2013-07-17 11:27:46 +02:00
|
|
|
// TODO the language should be a property on the document, not the editor
|
2019-01-17 01:54:13 +01:00
|
|
|
if (DocumentModel::editorsForDocument(document).constFirst()
|
2017-01-30 14:59:10 +01:00
|
|
|
->context().contains(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID)) {
|
|
|
|
|
workingCopy.insert(key, textDocument->plainText(),
|
|
|
|
|
textDocument->document()->revision());
|
|
|
|
|
}
|
2010-09-24 14:05:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return workingCopy;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-30 11:56:28 +02:00
|
|
|
void ModelManager::updateDefaultProjectInfo()
|
2013-05-21 11:35:15 +02:00
|
|
|
{
|
2015-01-12 14:02:25 +01:00
|
|
|
// needs to be performed in the ui thread
|
2023-02-14 15:47:22 +01:00
|
|
|
Project *currentProject = ProjectManager::startupProject();
|
2019-10-23 14:03:13 +02:00
|
|
|
setDefaultProject(containsProject(currentProject)
|
|
|
|
|
? projectInfo(currentProject)
|
2022-10-25 08:57:49 +02:00
|
|
|
: defaultProjectInfoForProject(currentProject, {}),
|
2019-10-23 14:03:13 +02:00
|
|
|
currentProject);
|
2010-03-16 16:34:33 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-30 11:56:28 +02:00
|
|
|
|
2019-10-23 14:03:13 +02:00
|
|
|
void ModelManager::addTaskInternal(const QFuture<void> &result, const QString &msg,
|
|
|
|
|
const char *taskId) const
|
2012-12-06 17:20:58 +01:00
|
|
|
{
|
2014-01-23 14:28:31 +01:00
|
|
|
ProgressManager::addTask(result, msg, taskId);
|
2012-12-06 17:20:58 +01:00
|
|
|
}
|
2015-02-27 09:02:42 +02:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlJSTools
|