2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01: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
|
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
|
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
#include "cpptools_global.h"
|
2013-04-02 11:52:31 +02:00
|
|
|
#include "cppmodelmanagerinterface.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>
|
|
|
|
|
2012-09-07 10:51:50 +02:00
|
|
|
#include <QHash>
|
|
|
|
#include <QMutex>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
namespace Core { class IEditor; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
namespace TextEditor {
|
2011-02-21 16:02:26 +01:00
|
|
|
class BaseTextEditorWidget;
|
2013-04-02 11:28:11 +02:00
|
|
|
} // namespace TextEditor
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
namespace CppTools {
|
2010-01-19 15:26:08 +10:00
|
|
|
|
2013-04-17 10:58:20 +02:00
|
|
|
class CppEditorSupport;
|
2012-02-20 12:39:08 +01:00
|
|
|
class CppHighlightingSupportFactory;
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
class CppFindReferences;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
class CPPTOOLS_EXPORT CppModelManager : public CppTools::CppModelManagerInterface
|
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);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual ~CppModelManager();
|
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
static CppModelManager *instance();
|
|
|
|
|
2010-03-02 12:51:47 +01:00
|
|
|
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles);
|
2009-12-15 15:16:46 +01:00
|
|
|
virtual WorkingCopy workingCopy() const;
|
2008-12-08 10:44:56 +01:00
|
|
|
|
|
|
|
virtual QList<ProjectInfo> projectInfos() const;
|
|
|
|
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
|
|
|
|
virtual void updateProjectInfo(const ProjectInfo &pinfo);
|
2013-04-02 11:28:11 +02:00
|
|
|
virtual QList<CppTools::ProjectPart::Ptr> projectPart(const QString &fileName) const;
|
2008-12-08 10:44:56 +01:00
|
|
|
|
2008-12-12 10:07:58 +01:00
|
|
|
virtual CPlusPlus::Snapshot snapshot() const;
|
2013-02-19 12:48:42 +01:00
|
|
|
virtual Document::Ptr document(const QString &fileName) const;
|
|
|
|
bool replaceDocument(Document::Ptr newDoc);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual void GC();
|
|
|
|
|
2010-06-07 12:12:07 +02:00
|
|
|
virtual bool isCppEditor(Core::IEditor *editor) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
void emitDocumentUpdated(CPlusPlus::Document::Ptr doc);
|
|
|
|
|
2009-05-12 13:45:24 +02:00
|
|
|
virtual void addEditorSupport(AbstractEditorSupport *editorSupport);
|
|
|
|
virtual void removeEditorSupport(AbstractEditorSupport *editorSupport);
|
2013-04-17 10:58:20 +02:00
|
|
|
virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *editor);
|
2009-05-12 13:45:24 +02:00
|
|
|
|
2010-05-31 12:09:28 +02:00
|
|
|
virtual QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
2009-09-30 13:25:40 +02:00
|
|
|
|
2010-07-20 11:02:37 +02:00
|
|
|
virtual void renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
|
|
|
|
const QString &replacement = QString());
|
2010-05-31 12:09:28 +02:00
|
|
|
virtual void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2009-12-21 14:54:10 +01:00
|
|
|
virtual void findMacroUsages(const CPlusPlus::Macro ¯o);
|
2012-03-17 13:26:27 +01:00
|
|
|
virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement);
|
2009-12-21 14:54:10 +01:00
|
|
|
|
2013-04-17 10:58:20 +02:00
|
|
|
virtual void setExtraDiagnostics(const QString &fileName, const QString &key,
|
2013-02-19 12:48:42 +01:00
|
|
|
const QList<Document::DiagnosticMessage> &diagnostics);
|
2011-08-24 10:55:48 +02:00
|
|
|
|
2011-07-05 10:46:46 +02:00
|
|
|
void finishedRefreshingSourceFiles(const QStringList &files);
|
|
|
|
|
2012-02-07 15:09:08 +01:00
|
|
|
virtual CppCompletionSupport *completionSupport(Core::IEditor *editor) const;
|
2012-02-21 10:00:32 +01:00
|
|
|
virtual void setCppCompletionAssistProvider(CppCompletionAssistProvider *completionAssistProvider);
|
2012-02-20 12:39:08 +01:00
|
|
|
|
2012-02-07 15:09:08 +01:00
|
|
|
virtual CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const;
|
2012-02-21 10:00:32 +01:00
|
|
|
virtual void setHighlightingSupportFactory(CppHighlightingSupportFactory *highlightingFactory);
|
2012-02-07 15:09:08 +01:00
|
|
|
|
2012-11-23 11:47:39 +01:00
|
|
|
virtual void setIndexingSupport(CppIndexingSupport *indexingSupport);
|
|
|
|
virtual CppIndexingSupport *indexingSupport();
|
2009-10-12 10:38:00 +02:00
|
|
|
|
2008-12-04 17:07:43 +01:00
|
|
|
QStringList projectFiles()
|
|
|
|
{
|
|
|
|
ensureUpdated();
|
|
|
|
return m_projectFiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList includePaths()
|
|
|
|
{
|
|
|
|
ensureUpdated();
|
|
|
|
return m_includePaths;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList frameworkPaths()
|
|
|
|
{
|
|
|
|
ensureUpdated();
|
|
|
|
return m_frameworkPaths;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray definedMacros()
|
|
|
|
{
|
|
|
|
ensureUpdated();
|
|
|
|
return m_definedMacros;
|
|
|
|
}
|
|
|
|
|
2012-10-16 16:02:40 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void aboutToRemoveFiles(const QStringList &files);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
void editorAboutToClose(Core::IEditor *editor);
|
|
|
|
virtual void updateModifiedSourceFiles();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
// this should be executed in the GUI thread.
|
|
|
|
void onAboutToRemoveProject(ProjectExplorer::Project *project);
|
|
|
|
void onAboutToUnloadSession();
|
2013-04-19 16:56:12 +02:00
|
|
|
void onCoreAboutToClose();
|
2012-10-16 16:02:40 +02:00
|
|
|
void onProjectAdded(ProjectExplorer::Project *project);
|
|
|
|
|
|
|
|
private:
|
2013-02-19 12:48:42 +01:00
|
|
|
void replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot);
|
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;
|
|
|
|
QStringList internalIncludePaths() const;
|
|
|
|
QStringList internalFrameworkPaths() const;
|
|
|
|
QByteArray internalDefinedMacros() const;
|
2008-12-04 17:07:43 +01:00
|
|
|
|
2012-11-06 10:48:16 +01:00
|
|
|
void dumpModelManagerConfiguration();
|
|
|
|
|
2012-10-15 16:38:56 +02:00
|
|
|
private:
|
|
|
|
static QMutex m_modelManagerMutex;
|
|
|
|
static CppModelManager *m_modelManagerInstance;
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2013-04-23 14:46:44 +02:00
|
|
|
// snapshot
|
|
|
|
mutable QMutex m_snapshotMutex;
|
2008-12-12 10:07:58 +01:00
|
|
|
CPlusPlus::Snapshot m_snapshot;
|
2013-04-23 14:46:44 +02:00
|
|
|
|
2013-04-19 16:56:12 +02:00
|
|
|
bool m_enableGC;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-23 14:46:44 +02:00
|
|
|
// project integration
|
|
|
|
mutable QMutex m_projectMutex;
|
|
|
|
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
|
|
|
|
QMap<QString, QList<CppTools::ProjectPart::Ptr> > m_srcToProjectPart;
|
|
|
|
// cached/calculated from the projects and/or their project-parts
|
2008-12-04 17:07:43 +01:00
|
|
|
bool m_dirty;
|
2008-12-02 12:01:29 +01:00
|
|
|
QStringList m_projectFiles;
|
2008-12-04 17:07:43 +01:00
|
|
|
QStringList m_includePaths;
|
|
|
|
QStringList m_frameworkPaths;
|
|
|
|
QByteArray m_definedMacros;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
// editor integration
|
2013-04-17 10:58:20 +02:00
|
|
|
mutable QMutex m_editorSupportMutex;
|
|
|
|
QMap<TextEditor::BaseTextEditor *, CppEditorSupport *> m_editorSupport;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-12 13:45:24 +02:00
|
|
|
QSet<AbstractEditorSupport *> m_addtionalEditorSupport;
|
|
|
|
|
2009-08-07 13:02:36 +02:00
|
|
|
CppFindReferences *m_findReferences;
|
2009-12-07 12:03:31 +01:00
|
|
|
bool m_indexerEnabled;
|
2011-08-24 10:55:48 +02:00
|
|
|
|
2012-02-21 10:00:32 +01:00
|
|
|
CppCompletionAssistProvider *m_completionAssistProvider;
|
|
|
|
CppCompletionAssistProvider *m_completionFallback;
|
2012-02-20 12:39:08 +01:00
|
|
|
CppHighlightingSupportFactory *m_highlightingFactory;
|
|
|
|
CppHighlightingSupportFactory *m_highlightingFallback;
|
2012-11-23 11:47:39 +01:00
|
|
|
CppIndexingSupport *m_indexingSupporter;
|
2012-10-16 16:02:40 +02:00
|
|
|
CppIndexingSupport *m_internalIndexingSupport;
|
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 Internal
|
|
|
|
} // namespace CppTools
|
|
|
|
|
|
|
|
#endif // CPPMODELMANAGER_H
|