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 CPPMODELMANAGERINTERFACE_H
|
|
|
|
|
#define CPPMODELMANAGERINTERFACE_H
|
|
|
|
|
|
2012-03-14 10:25:55 +01:00
|
|
|
#include "cpptools_global.h"
|
2013-07-11 11:13:07 +02:00
|
|
|
|
2013-03-04 01:30:46 +04:00
|
|
|
#include "cppprojectfile.h"
|
2012-02-16 15:09:56 +01:00
|
|
|
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <cplusplus/CppDocument.h>
|
2013-05-08 18:27:03 +04:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
#include <QFuture>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QHash>
|
2013-07-11 11:13:07 +02:00
|
|
|
#include <QObject>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QStringList>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
namespace Core { class IEditor; }
|
|
|
|
|
namespace CPlusPlus { class LookupContext; }
|
2013-05-08 18:27:03 +04:00
|
|
|
namespace ProjectExplorer { class Project; }
|
2013-08-09 11:43:20 +02:00
|
|
|
namespace TextEditor { class BaseTextEditor; class BlockRange; }
|
2013-04-28 15:40:54 +04:00
|
|
|
namespace Utils { class FileName; }
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace CppTools {
|
2013-07-11 11:13:07 +02:00
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
class AbstractEditorSupport;
|
|
|
|
|
class CppCompletionAssistProvider;
|
2013-04-17 10:58:20 +02:00
|
|
|
class CppEditorSupport;
|
2013-04-02 11:28:11 +02:00
|
|
|
class CppHighlightingSupport;
|
|
|
|
|
class CppHighlightingSupportFactory;
|
|
|
|
|
class CppIndexingSupport;
|
2010-12-03 13:49:35 +01:00
|
|
|
|
2013-03-04 01:30:46 +04:00
|
|
|
class CPPTOOLS_EXPORT ProjectPart
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-03-04 01:30:46 +04:00
|
|
|
public:
|
2013-05-08 18:27:03 +04:00
|
|
|
ProjectPart();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-04-28 15:40:54 +04:00
|
|
|
void evaluateToolchain(const ProjectExplorer::ToolChain *tc,
|
|
|
|
|
const QStringList &cxxflags,
|
|
|
|
|
const QStringList &cflags,
|
|
|
|
|
const Utils::FileName &sysRoot);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2013-03-04 01:30:46 +04:00
|
|
|
enum CVersion {
|
|
|
|
|
C89,
|
|
|
|
|
C99,
|
|
|
|
|
C11
|
|
|
|
|
};
|
2012-02-16 15:09:56 +01:00
|
|
|
|
2013-03-04 01:30:46 +04:00
|
|
|
enum CXXVersion {
|
|
|
|
|
CXX98,
|
|
|
|
|
CXX11
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum CXXExtension {
|
|
|
|
|
NoExtensions = 0x0,
|
|
|
|
|
GnuExtensions = 0x1,
|
|
|
|
|
MicrosoftExtensions = 0x2,
|
|
|
|
|
BorlandExtensions = 0x4,
|
2013-08-19 18:20:49 +02:00
|
|
|
OpenMPExtensions = 0x8,
|
|
|
|
|
|
|
|
|
|
AllExtensions = GnuExtensions | MicrosoftExtensions | BorlandExtensions | OpenMPExtensions
|
2013-03-04 01:30:46 +04:00
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(CXXExtensions, CXXExtension)
|
|
|
|
|
|
|
|
|
|
enum QtVersion {
|
|
|
|
|
UnknownQt = -1,
|
|
|
|
|
NoQt = 0,
|
|
|
|
|
Qt4 = 1,
|
|
|
|
|
Qt5 = 2
|
2012-02-16 15:09:56 +01:00
|
|
|
};
|
|
|
|
|
|
2013-03-04 01:30:46 +04:00
|
|
|
typedef QSharedPointer<ProjectPart> Ptr;
|
|
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
public:
|
2013-03-04 01:30:46 +04:00
|
|
|
QList<ProjectFile> files;
|
|
|
|
|
QByteArray defines;
|
|
|
|
|
QStringList includePaths;
|
|
|
|
|
QStringList frameworkPaths;
|
|
|
|
|
QStringList precompiledHeaders;
|
|
|
|
|
CVersion cVersion;
|
|
|
|
|
CXXVersion cxxVersion;
|
|
|
|
|
CXXExtensions cxxExtensions;
|
|
|
|
|
QtVersion qtVersion;
|
2013-05-08 18:27:03 +04:00
|
|
|
ProjectExplorer::ToolChain::WarningFlags cWarningFlags;
|
|
|
|
|
ProjectExplorer::ToolChain::WarningFlags cxxWarningFlags;
|
2013-03-04 01:30:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2013-07-11 11:13:07 +02:00
|
|
|
// Documented in source file.
|
2013-06-21 08:42:27 +02:00
|
|
|
enum ProgressNotificationMode {
|
|
|
|
|
ForcedProgressNotification,
|
|
|
|
|
ReservedProgressNotification
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-14 10:25:55 +01:00
|
|
|
class CPPTOOLS_EXPORT ProjectInfo
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-08 10:44:56 +01:00
|
|
|
public:
|
|
|
|
|
ProjectInfo()
|
2013-07-11 11:13:07 +02:00
|
|
|
{}
|
2008-12-08 10:44:56 +01:00
|
|
|
|
2012-09-24 13:48:18 +02:00
|
|
|
ProjectInfo(QPointer<ProjectExplorer::Project> project)
|
2012-02-16 15:09:56 +01:00
|
|
|
: m_project(project)
|
2013-07-11 11:13:07 +02:00
|
|
|
{}
|
2008-12-08 10:44:56 +01:00
|
|
|
|
|
|
|
|
operator bool() const
|
2013-07-24 11:59:39 +02:00
|
|
|
{ return !m_project.isNull(); }
|
2008-12-08 10:44:56 +01:00
|
|
|
|
|
|
|
|
bool isValid() const
|
2013-07-24 11:59:39 +02:00
|
|
|
{ return !m_project.isNull(); }
|
2008-12-08 10:44:56 +01:00
|
|
|
|
|
|
|
|
bool isNull() const
|
2012-02-16 15:09:56 +01:00
|
|
|
{ return m_project.isNull(); }
|
2008-12-08 10:44:56 +01:00
|
|
|
|
2012-09-24 13:48:18 +02:00
|
|
|
QPointer<ProjectExplorer::Project> project() const
|
2012-02-16 15:09:56 +01:00
|
|
|
{ return m_project; }
|
|
|
|
|
|
|
|
|
|
const QList<ProjectPart::Ptr> projectParts() const
|
|
|
|
|
{ return m_projectParts; }
|
|
|
|
|
|
|
|
|
|
void clearProjectParts();
|
|
|
|
|
void appendProjectPart(const ProjectPart::Ptr &part);
|
|
|
|
|
|
|
|
|
|
const QStringList includePaths() const
|
|
|
|
|
{ return m_includePaths; }
|
|
|
|
|
|
|
|
|
|
const QStringList frameworkPaths() const
|
|
|
|
|
{ return m_frameworkPaths; }
|
|
|
|
|
|
|
|
|
|
const QStringList sourceFiles() const
|
|
|
|
|
{ return m_sourceFiles; }
|
|
|
|
|
|
|
|
|
|
const QByteArray defines() const
|
|
|
|
|
{ return m_defines; }
|
|
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
private:
|
2012-09-24 13:48:18 +02:00
|
|
|
QPointer<ProjectExplorer::Project> m_project;
|
2012-02-16 15:09:56 +01:00
|
|
|
QList<ProjectPart::Ptr> m_projectParts;
|
2013-07-11 11:13:07 +02:00
|
|
|
// The members below are (re)calculated from the project parts once a part is appended.
|
2012-02-16 15:09:56 +01:00
|
|
|
QStringList m_includePaths;
|
|
|
|
|
QStringList m_frameworkPaths;
|
|
|
|
|
QStringList m_sourceFiles;
|
|
|
|
|
QByteArray m_defines;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2012-03-14 10:25:55 +01:00
|
|
|
class CPPTOOLS_EXPORT WorkingCopy
|
2009-12-15 15:26:40 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2009-12-15 15:52:55 +01:00
|
|
|
void insert(const QString &fileName, const QString &source, unsigned revision = 0)
|
|
|
|
|
{ _elements.insert(fileName, qMakePair(source, revision)); }
|
2009-12-15 15:26:40 +01:00
|
|
|
|
|
|
|
|
bool contains(const QString &fileName) const
|
|
|
|
|
{ return _elements.contains(fileName); }
|
|
|
|
|
|
|
|
|
|
QString source(const QString &fileName) const
|
2009-12-15 15:52:55 +01:00
|
|
|
{ return _elements.value(fileName).first; }
|
|
|
|
|
|
|
|
|
|
QPair<QString, unsigned> get(const QString &fileName) const
|
2009-12-15 15:26:40 +01:00
|
|
|
{ return _elements.value(fileName); }
|
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
QHashIterator<QString, QPair<QString, unsigned> > iterator() const
|
|
|
|
|
{ return QHashIterator<QString, QPair<QString, unsigned> >(_elements); }
|
|
|
|
|
|
2012-12-20 14:07:27 +01:00
|
|
|
int size() const
|
|
|
|
|
{ return _elements.size(); }
|
|
|
|
|
|
2009-12-15 15:26:40 +01:00
|
|
|
private:
|
2009-12-15 15:52:55 +01:00
|
|
|
typedef QHash<QString, QPair<QString, unsigned> > Table;
|
2009-12-15 15:26:40 +01:00
|
|
|
Table _elements;
|
|
|
|
|
};
|
2009-12-15 15:16:46 +01:00
|
|
|
|
2012-11-28 09:52:19 +01:00
|
|
|
public:
|
|
|
|
|
static const QString configurationFileName();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-12-03 13:49:35 +01:00
|
|
|
CppModelManagerInterface(QObject *parent = 0);
|
|
|
|
|
virtual ~CppModelManagerInterface();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-10-05 13:43:05 +02:00
|
|
|
static CppModelManagerInterface *instance();
|
|
|
|
|
|
2010-06-07 12:12:07 +02:00
|
|
|
virtual bool isCppEditor(Core::IEditor *editor) const = 0;
|
|
|
|
|
|
2009-12-15 15:16:46 +01:00
|
|
|
virtual WorkingCopy workingCopy() const = 0;
|
2008-12-12 10:07:58 +01:00
|
|
|
virtual CPlusPlus::Snapshot snapshot() const = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-08 10:44:56 +01:00
|
|
|
virtual QList<ProjectInfo> projectInfos() const = 0;
|
|
|
|
|
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
|
2013-07-16 12:08:39 +02:00
|
|
|
virtual QFuture<void> updateProjectInfo(const ProjectInfo &pinfo) = 0;
|
2012-02-16 15:09:56 +01:00
|
|
|
virtual QList<ProjectPart::Ptr> projectPart(const QString &fileName) const = 0;
|
2013-08-19 18:20:49 +02:00
|
|
|
virtual ProjectPart::Ptr fallbackProjectPart() const = 0;
|
2009-05-12 13:45:24 +02:00
|
|
|
|
2013-06-14 14:02:17 +02:00
|
|
|
virtual QStringList includePaths() = 0;
|
|
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
virtual void addExtraEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
|
|
|
|
|
virtual void removeExtraEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
|
|
|
|
|
virtual CppEditorSupport *cppEditorSupport(TextEditor::BaseTextEditor *textEditor) = 0;
|
|
|
|
|
virtual void deleteCppEditorSupport(TextEditor::BaseTextEditor *textEditor) = 0;
|
2009-08-07 13:02:36 +02:00
|
|
|
|
2009-09-30 13:25:40 +02:00
|
|
|
virtual QList<int> references(CPlusPlus::Symbol *symbol,
|
2010-05-31 12:09:28 +02:00
|
|
|
const CPlusPlus::LookupContext &context) = 0;
|
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()) = 0;
|
2010-05-31 12:09:28 +02:00
|
|
|
virtual void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) = 0;
|
2009-11-05 12:34:02 +01:00
|
|
|
|
2012-03-17 13:26:27 +01:00
|
|
|
virtual void renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement = QString()) = 0;
|
2009-12-21 14:54:10 +01:00
|
|
|
virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0;
|
|
|
|
|
|
2013-04-17 10:58:20 +02:00
|
|
|
virtual void setExtraDiagnostics(const QString &fileName, const QString &kind,
|
2011-08-24 10:55:48 +02:00
|
|
|
const QList<CPlusPlus::Document::DiagnosticMessage> &diagnostics) = 0;
|
2013-08-09 11:43:20 +02:00
|
|
|
virtual void setIfdefedOutBlocks(const QString &fileName,
|
|
|
|
|
const QList<TextEditor::BlockRange> &ifdeffedOutBlocks) = 0;
|
2011-08-24 10:55:48 +02:00
|
|
|
|
2013-08-30 12:55:06 +02:00
|
|
|
virtual CppCompletionAssistProvider *completionAssistProvider(Core::IEditor *editor) const = 0;
|
2012-02-21 10:00:32 +01:00
|
|
|
virtual void setCppCompletionAssistProvider(CppTools::CppCompletionAssistProvider *completionAssistProvider) = 0;
|
|
|
|
|
|
2012-02-07 15:09:08 +01:00
|
|
|
virtual CppTools::CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const = 0;
|
2012-02-21 10:00:32 +01:00
|
|
|
virtual void setHighlightingSupportFactory(CppTools::CppHighlightingSupportFactory *highlightingFactory) = 0;
|
2012-02-07 15:09:08 +01:00
|
|
|
|
2012-11-23 11:47:39 +01:00
|
|
|
virtual void setIndexingSupport(CppTools::CppIndexingSupport *indexingSupport) = 0;
|
|
|
|
|
virtual CppTools::CppIndexingSupport *indexingSupport() = 0;
|
2012-10-16 16:02:40 +02:00
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
signals:
|
2013-07-10 14:46:08 +02:00
|
|
|
/// Project data might be locked while this is emitted.
|
|
|
|
|
void aboutToRemoveFiles(const QStringList &files);
|
|
|
|
|
|
2010-03-17 14:18:32 +01:00
|
|
|
void documentUpdated(CPlusPlus::Document::Ptr doc);
|
2011-07-05 10:46:46 +02:00
|
|
|
void sourceFilesRefreshed(const QStringList &files);
|
2010-03-17 14:18:32 +01:00
|
|
|
|
2013-01-01 10:34:42 +01:00
|
|
|
/// \brief Emitted after updateProjectInfo method 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);
|
|
|
|
|
|
2013-07-11 11:13:07 +02:00
|
|
|
public slots:
|
2013-07-10 14:46:08 +02:00
|
|
|
// Documented in source file.
|
2013-06-21 08:42:27 +02:00
|
|
|
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles,
|
|
|
|
|
ProgressNotificationMode mode = ReservedProgressNotification) = 0;
|
2013-07-10 14:46:08 +02:00
|
|
|
|
|
|
|
|
virtual void updateModifiedSourceFiles() = 0;
|
2009-11-05 12:34:02 +01:00
|
|
|
virtual void GC() = 0;
|
2009-05-12 13:45:24 +02:00
|
|
|
};
|
|
|
|
|
|
2013-04-02 11:28:11 +02:00
|
|
|
} // namespace CppTools
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#endif // CPPMODELMANAGERINTERFACE_H
|