2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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>
|
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>
|
2011-06-28 12:01:56 +02:00
|
|
|
#include <projectexplorer/session.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>
|
2012-02-09 09:35:03 +01:00
|
|
|
#include <utils/runextensions.h>
|
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 <QLibraryInfo>
|
|
|
|
|
#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;
|
|
|
|
|
foreach (const Target *t, projectInfo.project->targets())
|
|
|
|
|
currentKits.insert(t->kit());
|
|
|
|
|
currentKits.remove(activeKit);
|
|
|
|
|
foreach (Kit *kit, currentKits) {
|
|
|
|
|
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
|
|
|
|
bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:48:57 +02:00
|
|
|
ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
|
2015-02-27 09:02:42 +02:00
|
|
|
Project *project) 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 };
|
2017-12-06 10:58:59 +01:00
|
|
|
projectInfo.sourceFiles = Utils::transform(project->files([&qmlTypeNames](const Node *n) {
|
|
|
|
|
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());
|
2019-05-28 13:49:26 +02:00
|
|
|
}), &FilePath::toString);
|
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-01-14 10:19:09 +01:00
|
|
|
QDir baseDir;
|
|
|
|
|
auto addAppDir = [&baseDir, & projectInfo](const QString &mdir) {
|
|
|
|
|
auto dir = QDir::cleanPath(mdir);
|
|
|
|
|
if (!baseDir.path().isEmpty()) {
|
|
|
|
|
auto rDir = baseDir.relativeFilePath(dir);
|
|
|
|
|
// 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
|
|
|
|
|
if (rDir.split(u'/').contains(QStringLiteral(u"..")))
|
|
|
|
|
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-01-14 10:19:09 +01:00
|
|
|
QString dir = bc->buildDirectory().toString();
|
|
|
|
|
baseDir.setPath(QDir{dir}.absolutePath());
|
|
|
|
|
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();
|
|
|
|
|
projectInfo.applicationDirectories.append(dir.toString());
|
|
|
|
|
// unfortunately the build directory of the executable where cmake puts the qml
|
|
|
|
|
// might be different than the directory of the executable:
|
2021-12-06 17:13:19 +01:00
|
|
|
#if defined(Q_OS_WIN)
|
|
|
|
|
// On Windows systems QML type information is located one directory higher as we build
|
|
|
|
|
// in dedicated "debug" and "release" directories
|
2022-01-14 10:19:09 +01:00
|
|
|
addAppDir(
|
|
|
|
|
dir.parentDir().toString());
|
2021-12-06 17:13:19 +01:00
|
|
|
#elif defined(Q_OS_MACOS)
|
2022-01-14 10:19:09 +01:00
|
|
|
// 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.toString());
|
2021-12-06 17:13:19 +01:00
|
|
|
#endif
|
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();
|
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()) {
|
2021-10-12 17:32:48 +02:00
|
|
|
projectInfo.qtQmlPath = FilePath::fromUserInput(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath));
|
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);
|
|
|
|
|
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);
|
2014-01-22 18:38:45 +01:00
|
|
|
foreach (const QString &suffix, jsSourceTy.suffixes())
|
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);
|
2014-01-22 18:38:45 +01:00
|
|
|
foreach (const QString &suffix, qmlSourceTy.suffixes())
|
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);
|
2014-01-22 18:38:45 +01:00
|
|
|
foreach (const QString &suffix, qbsSourceTy.suffixes())
|
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);
|
2014-01-22 18:38:45 +01:00
|
|
|
foreach (const QString &suffix, qmlProjectSourceTy.suffixes())
|
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);
|
2014-10-13 16:46:30 +02:00
|
|
|
foreach (const QString &suffix, qmlUiSourceTy.suffixes())
|
|
|
|
|
res[suffix] = Dialect::QmlQtQuick2Ui;
|
2017-03-02 12:07:11 +01:00
|
|
|
MimeType jsonSourceTy = Utils::mimeTypeForName(Constants::JSON_MIMETYPE);
|
2014-01-22 18:38:45 +01:00
|
|
|
foreach (const QString &suffix, jsonSourceTy.suffixes())
|
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
|
|
|
|
2015-02-27 09:02:42 +02:00
|
|
|
connect(SessionManager::instance(), &SessionManager::projectRemoved,
|
2015-01-12 14:04:27 +01:00
|
|
|
this, &ModelManager::removeProjectInfo);
|
2015-02-27 09:02:42 +02:00
|
|
|
connect(SessionManager::instance(), &SessionManager::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;
|
2021-04-26 15:46:09 +02:00
|
|
|
qbsVContext.paths.append(ICore::resourcePath("qbs").toString());
|
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;
|
|
|
|
|
|
2014-05-07 16:25:04 +02:00
|
|
|
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
2014-12-21 21:54:30 +02:00
|
|
|
const QString key = document->filePath().toString();
|
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
|
2015-02-27 09:02:42 +02:00
|
|
|
Project *currentProject = SessionManager::startupProject();
|
2019-10-23 14:03:13 +02:00
|
|
|
setDefaultProject(containsProject(currentProject)
|
|
|
|
|
? projectInfo(currentProject)
|
|
|
|
|
: defaultProjectInfoForProject(currentProject),
|
|
|
|
|
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
|