2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-09-04 16:51:11 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-02-15 13:49:00 +01:00
|
|
|
#ifndef QMLJSMODELMANAGER_H
|
|
|
|
|
#define QMLJSMODELMANAGER_H
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
#include "qmljstools_global.h"
|
|
|
|
|
|
2010-06-09 15:56:03 +02:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2013-05-21 11:35:15 +02:00
|
|
|
#include <qmljs/qmljsqrcparser.h>
|
2011-01-20 14:03:07 +01:00
|
|
|
|
2011-08-18 16:46:26 +02:00
|
|
|
#include <cplusplus/CppDocument.h>
|
2009-12-02 17:59:27 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFuture>
|
|
|
|
|
#include <QFutureSynchronizer>
|
|
|
|
|
#include <QMutex>
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-12-03 10:13:15 +01:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QTimer)
|
2013-05-21 11:35:15 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QLocale)
|
2010-12-03 10:13:15 +01:00
|
|
|
|
2009-09-04 16:51:11 +02:00
|
|
|
namespace Core {
|
2010-01-20 16:43:50 +01:00
|
|
|
class MimeType;
|
2009-09-04 16:51:11 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-18 16:46:26 +02:00
|
|
|
namespace CPlusPlus {
|
|
|
|
|
class CppModelManagerInterface;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 11:35:15 +02:00
|
|
|
namespace QmlJS {
|
|
|
|
|
class QrcParser;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
namespace QmlJSTools {
|
2011-09-09 10:55:11 +02:00
|
|
|
|
2013-10-16 14:59:28 +02:00
|
|
|
QMLJSTOOLS_EXPORT QmlJS::Language::Enum languageOfFile(const QString &fileName);
|
2011-09-09 10:55:11 +02:00
|
|
|
QMLJSTOOLS_EXPORT QStringList qmlAndJsGlobPatterns();
|
|
|
|
|
|
2009-09-04 16:51:11 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-11-10 15:07:53 +01:00
|
|
|
class PluginDumper;
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
class QMLJSTOOLS_EXPORT ModelManager: public QmlJS::ModelManagerInterface
|
2009-09-04 16:51:11 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-02-15 13:49:00 +01:00
|
|
|
ModelManager(QObject *parent = 0);
|
2011-10-20 11:25:38 +02:00
|
|
|
~ModelManager();
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-12-03 10:13:15 +01:00
|
|
|
void delayedInitialization();
|
|
|
|
|
|
2010-09-24 14:05:34 +02:00
|
|
|
virtual WorkingCopy workingCopy() const;
|
2011-08-30 09:19:56 +02:00
|
|
|
virtual QmlJS::Snapshot snapshot() const;
|
|
|
|
|
virtual QmlJS::Snapshot newestSnapshot() const;
|
2010-09-24 14:05:34 +02:00
|
|
|
|
2010-04-16 13:08:59 +02:00
|
|
|
virtual void updateSourceFiles(const QStringList &files,
|
|
|
|
|
bool emitDocumentOnDiskChanged);
|
2010-04-16 12:42:12 +02:00
|
|
|
virtual void fileChangedOnDisk(const QString &path);
|
2010-05-18 13:40:35 +02:00
|
|
|
virtual void removeFiles(const QStringList &files);
|
2013-05-21 11:35:15 +02:00
|
|
|
virtual QStringList filesAtQrcPath(const QString &path, const QLocale *locale = 0,
|
|
|
|
|
ProjectExplorer::Project *project = 0,
|
|
|
|
|
QrcResourceSelector resources = AllQrcResources);
|
|
|
|
|
virtual QMap<QString,QStringList> filesInQrcPath(const QString &path,
|
|
|
|
|
const QLocale *locale = 0,
|
|
|
|
|
ProjectExplorer::Project *project = 0,
|
|
|
|
|
bool addDirs = false,
|
|
|
|
|
QrcResourceSelector resources = AllQrcResources);
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-06-22 12:54:19 +02:00
|
|
|
virtual QList<ProjectInfo> projectInfos() const;
|
2010-09-27 11:16:43 +01:00
|
|
|
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
2010-06-22 12:54:19 +02:00
|
|
|
virtual void updateProjectInfo(const ProjectInfo &pinfo);
|
2011-08-26 13:31:18 +02:00
|
|
|
Q_SLOT virtual void removeProjectInfo(ProjectExplorer::Project *project);
|
2012-12-06 17:20:58 +01:00
|
|
|
virtual ProjectInfo projectInfoForPath(QString path);
|
2010-06-22 12:54:19 +02:00
|
|
|
|
2010-10-15 10:06:59 +02:00
|
|
|
void updateDocument(QmlJS::Document::Ptr doc);
|
|
|
|
|
void updateLibraryInfo(const QString &path, const QmlJS::LibraryInfo &info);
|
2010-04-16 12:42:12 +02:00
|
|
|
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
|
2013-05-21 11:35:15 +02:00
|
|
|
void updateQrcFile(const QString &path);
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-03-16 16:34:33 +01:00
|
|
|
virtual QStringList importPaths() const;
|
2012-12-06 17:20:58 +01:00
|
|
|
virtual QmlJS::QmlLanguageBundles activeBundles() const;
|
|
|
|
|
virtual QmlJS::QmlLanguageBundles extendedBundles() const;
|
2010-03-16 16:34:33 +01:00
|
|
|
|
2011-02-08 13:29:21 +01:00
|
|
|
virtual void loadPluginTypes(const QString &libraryPath, const QString &importPath,
|
|
|
|
|
const QString &importUri, const QString &importVersion);
|
2010-08-25 14:15:57 +02:00
|
|
|
|
2011-08-25 12:35:55 +02:00
|
|
|
virtual CppDataHash cppData() const;
|
2011-06-28 12:01:56 +02:00
|
|
|
|
|
|
|
|
virtual QmlJS::LibraryInfo builtins(const QmlJS::Document::Ptr &doc) const;
|
2011-01-06 10:01:45 +01:00
|
|
|
|
2011-07-12 11:11:26 +02:00
|
|
|
virtual void joinAllThreads();
|
|
|
|
|
|
2011-06-23 15:12:03 +02:00
|
|
|
public slots:
|
|
|
|
|
virtual void resetCodeModel();
|
|
|
|
|
|
2009-09-04 16:51:11 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
|
void projectPathChanged(const QString &projectPath);
|
|
|
|
|
|
|
|
|
|
protected:
|
2010-04-16 13:08:59 +02:00
|
|
|
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles,
|
|
|
|
|
bool emitDocumentOnDiskChanged);
|
2009-09-04 16:51:11 +02:00
|
|
|
|
|
|
|
|
static void parse(QFutureInterface<void> &future,
|
2010-09-24 14:05:34 +02:00
|
|
|
WorkingCopy workingCopy,
|
2009-09-04 16:51:11 +02:00
|
|
|
QStringList files,
|
2010-04-16 12:42:12 +02:00
|
|
|
ModelManager *modelManager,
|
|
|
|
|
bool emitDocChangedOnDisk);
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-03-01 13:01:05 +01:00
|
|
|
void loadQmlTypeDescriptions();
|
2010-09-08 10:11:44 +02:00
|
|
|
void loadQmlTypeDescriptions(const QString &path);
|
2010-03-01 13:01:05 +01:00
|
|
|
|
2010-06-22 12:54:19 +02:00
|
|
|
void updateImportPaths();
|
|
|
|
|
|
2010-12-03 10:13:15 +01:00
|
|
|
private slots:
|
2011-08-23 12:02:29 +02:00
|
|
|
void maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc);
|
|
|
|
|
void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan);
|
2011-01-06 10:01:45 +01:00
|
|
|
void startCppQmlTypeUpdate();
|
2013-06-28 18:05:00 +02:00
|
|
|
void asyncReset();
|
2010-12-03 10:13:15 +01:00
|
|
|
|
2009-09-04 16:51:11 +02:00
|
|
|
private:
|
2010-01-20 16:43:50 +01:00
|
|
|
static bool matchesMimeType(const Core::MimeType &fileMimeType, const Core::MimeType &knownMimeType);
|
2011-10-20 11:25:38 +02:00
|
|
|
static void updateCppQmlTypes(QFutureInterface<void> &interface,
|
|
|
|
|
ModelManager *qmlModelManager,
|
|
|
|
|
CPlusPlus::Snapshot snapshot,
|
2011-09-16 10:35:48 +02:00
|
|
|
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > documents);
|
2010-01-20 16:43:50 +01:00
|
|
|
|
2009-09-04 17:54:38 +02:00
|
|
|
mutable QMutex m_mutex;
|
2011-08-16 14:11:30 +02:00
|
|
|
QmlJS::Snapshot _validSnapshot;
|
|
|
|
|
QmlJS::Snapshot _newestSnapshot;
|
2010-06-22 12:54:19 +02:00
|
|
|
QStringList m_allImportPaths;
|
2010-03-16 16:34:33 +01:00
|
|
|
QStringList m_defaultImportPaths;
|
2012-12-06 17:20:58 +01:00
|
|
|
QmlJS::QmlLanguageBundles m_activeBundles;
|
|
|
|
|
QmlJS::QmlLanguageBundles m_extendedBundles;
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-12-03 10:13:15 +01:00
|
|
|
QTimer *m_updateCppQmlTypesTimer;
|
2013-06-28 18:05:00 +02:00
|
|
|
QTimer *m_asyncResetTimer;
|
2011-09-16 10:35:48 +02:00
|
|
|
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
|
2011-10-20 11:25:38 +02:00
|
|
|
QFuture<void> m_cppQmlTypesUpdater;
|
2013-05-21 11:35:15 +02:00
|
|
|
QmlJS::QrcCache m_qrcCache;
|
2011-08-25 12:35:55 +02:00
|
|
|
|
|
|
|
|
CppDataHash m_cppDataHash;
|
|
|
|
|
mutable QMutex m_cppDataMutex;
|
2010-06-22 12:54:19 +02:00
|
|
|
|
|
|
|
|
// project integration
|
|
|
|
|
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
|
2010-11-10 15:07:53 +01:00
|
|
|
|
|
|
|
|
PluginDumper *m_pluginDumper;
|
2013-11-12 10:43:32 +01:00
|
|
|
|
|
|
|
|
QFutureSynchronizer<void> m_synchronizer;
|
2009-09-04 16:51:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2012-12-06 17:20:58 +01:00
|
|
|
|
|
|
|
|
QMLJSTOOLS_EXPORT QmlJS::ModelManagerInterface::ProjectInfo defaultProjectInfoForProject(
|
|
|
|
|
ProjectExplorer::Project *project);
|
|
|
|
|
QMLJSTOOLS_EXPORT void setupProjectInfoQmlBundles(QmlJS::ModelManagerInterface::ProjectInfo &projectInfo);
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
} // namespace QmlJSTools
|
2009-09-04 16:51:11 +02:00
|
|
|
|
2010-02-15 13:49:00 +01:00
|
|
|
#endif // QMLJSMODELMANAGER_H
|