2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01: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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01: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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company 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
|
|
|
****************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef CPPMODELMANAGER_H
|
|
|
|
#define CPPMODELMANAGER_H
|
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
#include "cpptools_global.h"
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
#include "cppmodelmanagersupport.h"
|
2014-09-15 00:12:27 +02:00
|
|
|
#include "cppprojects.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
#include <cplusplus/cppmodelmanagerbase.h>
|
|
|
|
|
|
|
|
#include <QFuture>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
namespace Core { class IEditor; }
|
2014-09-15 00:12:27 +02:00
|
|
|
namespace CPlusPlus { class LookupContext; }
|
|
|
|
namespace ProjectExplorer { class Project; }
|
2014-09-22 18:43:31 +02:00
|
|
|
namespace TextEditor { class TextDocument; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
namespace CppTools {
|
2010-01-19 15:26:08 +10:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
class AbstractEditorSupport;
|
|
|
|
class BaseEditorDocumentProcessor;
|
|
|
|
class CppCompletionAssistProvider;
|
2014-11-24 11:19:41 +01:00
|
|
|
class CppEditorDocumentHandle;
|
2014-09-15 00:12:27 +02:00
|
|
|
class CppIndexingSupport;
|
|
|
|
class WorkingCopy;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
namespace Internal {
|
2014-06-06 14:41:19 +02:00
|
|
|
class CppSourceProcessor;
|
2014-09-15 00:12:27 +02:00
|
|
|
class CppModelManagerPrivate;
|
2015-05-06 11:24:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Tests {
|
2015-01-30 12:59:25 +01:00
|
|
|
class ModelManagerTestHelper;
|
2014-09-15 00:12:27 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
class CPPTOOLS_EXPORT CppModelManager : public CPlusPlus::CppModelManagerBase
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2013-02-19 12:48:42 +01:00
|
|
|
public:
|
|
|
|
typedef CPlusPlus::Document Document;
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2012-10-15 16:38:56 +02:00
|
|
|
CppModelManager(QObject *parent = 0);
|
2014-09-15 00:12:27 +02:00
|
|
|
~CppModelManager();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
static CppModelManager *instance();
|
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
// Documented in source file.
|
|
|
|
enum ProgressNotificationMode {
|
|
|
|
ForcedProgressNotification,
|
|
|
|
ReservedProgressNotification
|
|
|
|
};
|
|
|
|
|
|
|
|
QFuture<void> updateSourceFiles(const QSet<QString> &sourceFiles,
|
2013-06-21 08:42:27 +02:00
|
|
|
ProgressNotificationMode mode = ReservedProgressNotification);
|
2014-09-15 00:12:27 +02:00
|
|
|
WorkingCopy workingCopy() const;
|
|
|
|
QByteArray codeModelConfiguration() const;
|
2008-12-08 10:44:56 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
QList<ProjectInfo> projectInfos() const;
|
|
|
|
ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
|
|
|
QFuture<void> updateProjectInfo(const ProjectInfo &newProjectInfo);
|
2013-08-19 16:05:29 +02:00
|
|
|
|
2013-12-02 15:23:13 +01:00
|
|
|
/// \return The project part with the given project file
|
2015-07-14 17:30:17 +02:00
|
|
|
ProjectPart::Ptr projectPartForId(const QString &projectPartId) const;
|
2013-08-19 16:05:29 +02:00
|
|
|
/// \return All project parts that mention the given file name as one of the sources/headers.
|
2014-11-27 12:40:34 +01:00
|
|
|
QList<ProjectPart::Ptr> projectPart(const Utils::FileName &fileName) const;
|
|
|
|
QList<ProjectPart::Ptr> projectPart(const QString &fileName) const
|
|
|
|
{ return projectPart(Utils::FileName::fromString(fileName)); }
|
2013-08-19 16:05:29 +02:00
|
|
|
/// This is a fall-back function: find all files that includes the file directly or indirectly,
|
|
|
|
/// and return its \c ProjectPart list for use with this file.
|
2014-11-27 12:40:34 +01:00
|
|
|
QList<ProjectPart::Ptr> projectPartFromDependencies(const Utils::FileName &fileName) const;
|
2013-08-19 16:05:29 +02:00
|
|
|
/// \return A synthetic \c ProjectPart which consists of all defines/includes/frameworks from
|
|
|
|
/// all loaded projects.
|
2014-09-15 00:12:27 +02:00
|
|
|
ProjectPart::Ptr fallbackProjectPart() const;
|
2008-12-08 10:44:56 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
CPlusPlus::Snapshot snapshot() const;
|
|
|
|
Document::Ptr document(const QString &fileName) const;
|
2013-02-19 12:48:42 +01:00
|
|
|
bool replaceDocument(Document::Ptr newDoc);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void emitDocumentUpdated(CPlusPlus::Document::Ptr doc);
|
2015-05-18 09:35:29 +02:00
|
|
|
void emitAbstractEditorSupportContentsUpdated(const QString &filePath,
|
|
|
|
const QByteArray &contents);
|
|
|
|
void emitAbstractEditorSupportRemoved(const QString &filePath);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
bool isCppEditor(Core::IEditor *editor) const;
|
2013-07-11 11:13:07 +02:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
QSet<AbstractEditorSupport*> abstractEditorSupports() const;
|
2014-09-15 00:12:27 +02:00
|
|
|
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
|
|
|
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
QList<CppEditorDocumentHandle *> cppEditorDocuments() const;
|
2014-11-24 11:19:41 +01:00
|
|
|
CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const;
|
|
|
|
void registerCppEditorDocument(CppEditorDocumentHandle *cppEditorDocument);
|
|
|
|
void unregisterCppEditorDocument(const QString &filePath);
|
2009-05-12 13:45:24 +02:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
2009-09-30 13:25:40 +02:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
void renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
|
|
|
|
const QString &replacement = QString());
|
|
|
|
void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
void findMacroUsages(const CPlusPlus::Macro ¯o);
|
|
|
|
void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement);
|
2009-12-21 14:54:10 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
void finishedRefreshingSourceFiles(const QSet<QString> &files);
|
2011-07-05 10:46:46 +02:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void addModelManagerSupportProvider(ModelManagerSupportProvider *modelManagerSupportProvider);
|
2014-09-15 00:12:27 +02:00
|
|
|
CppCompletionAssistProvider *completionAssistProvider(const QString &mimeType) const;
|
|
|
|
BaseEditorDocumentProcessor *editorDocumentProcessor(
|
2014-09-22 18:43:31 +02:00
|
|
|
TextEditor::TextDocument *baseTextDocument) const;
|
2012-02-07 15:09:08 +01:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
void setIndexingSupport(CppIndexingSupport *indexingSupport);
|
|
|
|
CppIndexingSupport *indexingSupport();
|
2009-10-12 10:38:00 +02:00
|
|
|
|
2014-09-05 10:57:58 +03:00
|
|
|
QStringList projectFiles();
|
2008-12-04 17:07:43 +01:00
|
|
|
|
2014-09-05 10:57:58 +03:00
|
|
|
ProjectPart::HeaderPaths headerPaths();
|
2008-12-04 17:07:43 +01:00
|
|
|
|
2013-06-06 09:27:28 +02:00
|
|
|
// Use this *only* for auto tests
|
2014-09-15 00:12:27 +02:00
|
|
|
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
|
2008-12-04 17:07:43 +01:00
|
|
|
|
2014-09-05 10:57:58 +03:00
|
|
|
QByteArray definedMacros();
|
2008-12-04 17:07:43 +01:00
|
|
|
|
2013-12-17 13:54:52 +01:00
|
|
|
void enableGarbageCollector(bool enable);
|
|
|
|
|
2014-09-04 14:59:50 +02:00
|
|
|
static QSet<QString> timeStampModifiedFiles(const QList<Document::Ptr> &documentsToCheck);
|
2013-07-10 14:46:08 +02:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
static Internal::CppSourceProcessor *createSourceProcessor();
|
|
|
|
static QString configurationFileName();
|
|
|
|
static QString editorConfigurationFileName();
|
2014-06-06 14:41:19 +02:00
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
signals:
|
2014-09-15 00:12:27 +02:00
|
|
|
/// Project data might be locked while this is emitted.
|
|
|
|
void aboutToRemoveFiles(const QStringList &files);
|
|
|
|
|
|
|
|
void documentUpdated(CPlusPlus::Document::Ptr doc);
|
|
|
|
void sourceFilesRefreshed(const QSet<QString> &files);
|
|
|
|
|
|
|
|
void projectPartsUpdated(ProjectExplorer::Project *project);
|
2015-07-14 17:30:17 +02:00
|
|
|
void projectPartsRemoved(const QStringList &projectPartIds);
|
2014-09-15 00:12:27 +02:00
|
|
|
|
|
|
|
void globalSnapshotChanged();
|
|
|
|
|
2013-07-18 10:57:19 +02:00
|
|
|
void gcFinished(); // Needed for tests.
|
2012-10-16 16:02:40 +02:00
|
|
|
|
2015-05-18 09:35:29 +02:00
|
|
|
void abstractEditorSupportContentsUpdated(const QString &filePath, const QByteArray &contents);
|
|
|
|
void abstractEditorSupportRemoved(const QString &filePath);
|
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
public slots:
|
2015-02-05 16:34:58 +01:00
|
|
|
void updateModifiedSourceFiles();
|
|
|
|
void GC();
|
2012-10-16 16:02:40 +02:00
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
private slots:
|
|
|
|
// This should be executed in the GUI thread.
|
2015-05-06 11:24:41 +02:00
|
|
|
friend class Tests::ModelManagerTestHelper;
|
2013-07-18 10:57:19 +02:00
|
|
|
void onAboutToLoadSession();
|
2012-10-16 16:02:40 +02:00
|
|
|
void onAboutToUnloadSession();
|
2014-09-24 13:42:17 +02:00
|
|
|
void renameIncludes(const QString &oldFileName, const QString &newFileName);
|
2012-10-16 16:02:40 +02:00
|
|
|
void onProjectAdded(ProjectExplorer::Project *project);
|
2013-07-17 13:50:38 +02:00
|
|
|
void onAboutToRemoveProject(ProjectExplorer::Project *project);
|
2014-08-05 11:34:52 +02:00
|
|
|
void onSourceFilesRefreshed() const;
|
2014-12-02 12:11:05 +01:00
|
|
|
void onCurrentEditorChanged(Core::IEditor *editor);
|
2015-05-08 15:48:17 +02:00
|
|
|
void onCodeModelSettingsChanged();
|
2013-07-17 13:50:38 +02:00
|
|
|
void onCoreAboutToClose();
|
2012-10-16 16:02:40 +02:00
|
|
|
|
|
|
|
private:
|
2013-07-18 10:57:19 +02:00
|
|
|
void delayedGC();
|
2015-07-14 17:30:17 +02:00
|
|
|
void recalculateProjectPartMappings();
|
2014-12-02 12:11:05 +01:00
|
|
|
void updateCppEditorDocuments() const;
|
2013-10-04 12:25:26 +02:00
|
|
|
|
2013-02-19 12:48:42 +01:00
|
|
|
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);
|
2013-07-10 14:46:08 +02:00
|
|
|
void removeFilesFromSnapshot(const QSet<QString> &removedFiles);
|
|
|
|
void removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo);
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void handleAddedModelManagerSupports(const QSet<QString> &supportIds);
|
|
|
|
QList<ModelManagerSupport::Ptr> handleRemovedModelManagerSupports(
|
|
|
|
const QSet<QString> &supportIds);
|
|
|
|
void closeCppEditorDocuments();
|
|
|
|
|
|
|
|
ModelManagerSupport::Ptr modelManagerSupportForMimeType(const QString &mimeType) const;
|
2014-03-20 17:03:27 -03:00
|
|
|
|
2012-10-16 16:02:40 +02:00
|
|
|
WorkingCopy buildWorkingCopyList();
|
|
|
|
|
2008-12-08 10:44:56 +01:00
|
|
|
void ensureUpdated();
|
2008-12-08 14:48:51 +01:00
|
|
|
QStringList internalProjectFiles() const;
|
2014-06-25 17:23:19 +02:00
|
|
|
ProjectPart::HeaderPaths internalHeaderPaths() const;
|
2008-12-08 14:48:51 +01:00
|
|
|
QByteArray internalDefinedMacros() const;
|
2008-12-04 17:07:43 +01:00
|
|
|
|
2014-03-17 09:45:07 -03:00
|
|
|
void dumpModelManagerConfiguration(const QString &logFileId);
|
2012-11-06 10:48:16 +01:00
|
|
|
|
2012-10-15 16:38:56 +02:00
|
|
|
private:
|
2014-09-15 00:12:27 +02:00
|
|
|
Internal::CppModelManagerPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
2010-01-19 15:26:08 +10:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
} // namespace CppTools
|
|
|
|
|
|
|
|
#endif // CPPMODELMANAGER_H
|