2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
** 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.
|
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
|
|
|
|
** 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.
|
|
|
|
**
|
|
|
|
** 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
|
|
|
****************************************************************************/
|
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"
|
|
|
|
|
|
|
|
#include "cppprojects.h"
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2012-09-07 10:51:50 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <texteditor/basetexteditor.h>
|
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
#include <cplusplus/CppDocument.h>
|
|
|
|
#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;
|
|
|
|
class EditorDocumentHandle;
|
|
|
|
class CppIndexingSupport;
|
|
|
|
class ModelManagerSupport;
|
|
|
|
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;
|
|
|
|
}
|
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
|
2014-09-15 00:12:27 +02:00
|
|
|
ProjectPart::Ptr projectPartForProjectFile(const QString &projectFile) 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-09-15 00:12:27 +02:00
|
|
|
QList<ProjectPart::Ptr> projectPart(const QString &fileName) const;
|
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-09-15 00:12:27 +02:00
|
|
|
QList<ProjectPart::Ptr> projectPartFromDependencies(const QString &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);
|
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
bool isCppEditor(Core::IEditor *editor) const;
|
2013-07-11 11:13:07 +02:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
|
|
|
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
2014-08-19 15:59:29 +02:00
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
EditorDocumentHandle *editorDocument(const QString &filePath);
|
|
|
|
void registerEditorDocument(EditorDocumentHandle *editorDocument);
|
|
|
|
void unregisterEditorDocument(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
|
|
|
|
2014-09-15 00:12:27 +02:00
|
|
|
void addModelManagerSupport(ModelManagerSupport *modelManagerSupport);
|
|
|
|
ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const;
|
|
|
|
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);
|
|
|
|
|
|
|
|
/// \brief Emitted after updateProjectInfo function is called on the model-manager.
|
|
|
|
///
|
|
|
|
/// Other classes can use this to get notified when the \c ProjectExplorer has updated the parts.
|
|
|
|
void projectPartsUpdated(ProjectExplorer::Project *project);
|
|
|
|
|
|
|
|
void globalSnapshotChanged();
|
|
|
|
|
2013-07-18 10:57:19 +02:00
|
|
|
void gcFinished(); // Needed for tests.
|
2012-10-16 16:02:40 +02:00
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
public slots:
|
2012-10-16 16:02:40 +02:00
|
|
|
virtual void updateModifiedSourceFiles();
|
2013-07-18 10:57:19 +02:00
|
|
|
virtual 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.
|
2013-07-18 10:57:19 +02:00
|
|
|
void onAboutToLoadSession();
|
2012-10-16 16:02:40 +02:00
|
|
|
void onAboutToUnloadSession();
|
|
|
|
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;
|
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();
|
2013-10-04 12:25:26 +02:00
|
|
|
void recalculateFileToProjectParts();
|
|
|
|
|
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);
|
|
|
|
|
2014-08-19 15:59:29 +02:00
|
|
|
QList<EditorDocumentHandle *> cppEditors() 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
|