2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef CPPMODELMANAGERINTERFACE_H
|
|
|
|
|
#define CPPMODELMANAGERINTERFACE_H
|
|
|
|
|
|
|
|
|
|
#include <cplusplus/CppDocument.h>
|
2010-12-03 10:13:15 +01:00
|
|
|
#include <languageutils/fakemetaobject.h>
|
2012-02-16 15:09:56 +01:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/toolchain.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QHash>
|
|
|
|
|
#include <QPointer>
|
|
|
|
|
#include <QStringList>
|
|
|
|
|
#include <QFuture>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-06-07 12:12:07 +02:00
|
|
|
namespace Core {
|
|
|
|
|
class IEditor;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-31 12:09:28 +02:00
|
|
|
namespace CPlusPlus {
|
|
|
|
|
class LookupContext;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class Project;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace CppTools {
|
2010-12-03 13:49:35 +01:00
|
|
|
class AbstractEditorSupport;
|
2012-02-07 15:09:08 +01:00
|
|
|
class CppCompletionSupport;
|
|
|
|
|
class CppHighlightingSupport;
|
2010-06-07 13:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
namespace CPlusPlus {
|
|
|
|
|
|
|
|
|
|
class CPLUSPLUS_EXPORT CppModelManagerInterface : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2012-02-16 15:09:56 +01:00
|
|
|
enum Language { CXX, OBJC };
|
|
|
|
|
|
|
|
|
|
class CPLUSPLUS_EXPORT ProjectPart
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ProjectPart()
|
|
|
|
|
: qtVersion(UnknownQt)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
public: //attributes
|
|
|
|
|
QStringList sourceFiles;
|
|
|
|
|
QByteArray defines;
|
|
|
|
|
QStringList includePaths;
|
|
|
|
|
QStringList frameworkPaths;
|
|
|
|
|
QStringList precompiledHeaders;
|
|
|
|
|
Language language;
|
|
|
|
|
ProjectExplorer::ToolChain::CompilerFlags flags;
|
|
|
|
|
enum QtVersion {
|
|
|
|
|
UnknownQt = -1,
|
|
|
|
|
NoQt = 0,
|
|
|
|
|
Qt4 = 1,
|
|
|
|
|
Qt5 = 2
|
|
|
|
|
};
|
|
|
|
|
QtVersion qtVersion;
|
|
|
|
|
|
|
|
|
|
bool cpp0xEnabled() const
|
|
|
|
|
{ return flags == ProjectExplorer::ToolChain::STD_CXX11; }
|
|
|
|
|
|
|
|
|
|
bool objcEnabled() const
|
|
|
|
|
{ return language == CppModelManagerInterface::OBJC; }
|
|
|
|
|
|
|
|
|
|
typedef QSharedPointer<ProjectPart> Ptr;
|
|
|
|
|
};
|
|
|
|
|
|
2008-12-08 10:44:56 +01:00
|
|
|
class ProjectInfo
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2008-12-08 10:44:56 +01:00
|
|
|
public:
|
|
|
|
|
ProjectInfo()
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-02-16 15:09:56 +01:00
|
|
|
ProjectInfo(QWeakPointer<ProjectExplorer::Project> project)
|
|
|
|
|
: m_project(project)
|
2008-12-08 10:44:56 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
operator bool() const
|
2012-02-16 15:09:56 +01:00
|
|
|
{ return ! m_project.isNull(); }
|
2008-12-08 10:44:56 +01:00
|
|
|
|
|
|
|
|
bool isValid() const
|
2012-02-16 15:09:56 +01: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-02-16 15:09:56 +01:00
|
|
|
QWeakPointer<ProjectExplorer::Project> project() const
|
|
|
|
|
{ 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; }
|
|
|
|
|
|
|
|
|
|
private: // attributes
|
|
|
|
|
QWeakPointer<ProjectExplorer::Project> m_project;
|
|
|
|
|
QList<ProjectPart::Ptr> m_projectParts;
|
|
|
|
|
// the attributes below are calculated from the project parts.
|
|
|
|
|
QStringList m_includePaths;
|
|
|
|
|
QStringList m_frameworkPaths;
|
|
|
|
|
QStringList m_sourceFiles;
|
|
|
|
|
QByteArray m_defines;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2009-12-15 15:26:40 +01:00
|
|
|
class WorkingCopy
|
|
|
|
|
{
|
|
|
|
|
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); }
|
|
|
|
|
|
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
|
|
|
|
2011-08-24 10:55:48 +02:00
|
|
|
enum ExtraDiagnosticKind
|
|
|
|
|
{
|
|
|
|
|
AllExtraDiagnostics = -1,
|
|
|
|
|
ExportedQmlTypesDiagnostic
|
|
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
|
2012-02-16 15:09:56 +01:00
|
|
|
virtual QList<ProjectPart::Ptr> projectPart(const QString &fileName) const = 0;
|
2009-05-12 13:45:24 +02:00
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
|
|
|
|
|
virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 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
|
|
|
|
2009-12-21 14:54:10 +01:00
|
|
|
virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 0;
|
|
|
|
|
|
2011-08-24 10:55:48 +02:00
|
|
|
virtual void setExtraDiagnostics(const QString &fileName, int key,
|
|
|
|
|
const QList<CPlusPlus::Document::DiagnosticMessage> &diagnostics) = 0;
|
|
|
|
|
virtual QList<CPlusPlus::Document::DiagnosticMessage> extraDiagnostics(
|
|
|
|
|
const QString &fileName, int key = AllExtraDiagnostics) const = 0;
|
|
|
|
|
|
2012-02-07 15:09:08 +01:00
|
|
|
virtual CppTools::CppCompletionSupport *completionSupport(Core::IEditor *editor) const = 0;
|
|
|
|
|
virtual CppTools::CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const = 0;
|
|
|
|
|
|
2010-03-17 14:18:32 +01:00
|
|
|
Q_SIGNALS:
|
|
|
|
|
void documentUpdated(CPlusPlus::Document::Ptr doc);
|
2011-07-05 10:46:46 +02:00
|
|
|
void sourceFilesRefreshed(const QStringList &files);
|
2011-08-31 09:58:40 +02:00
|
|
|
void extraDiagnosticsUpdated(QString fileName);
|
2010-03-17 14:18:32 +01:00
|
|
|
|
2009-11-05 12:34:02 +01:00
|
|
|
public Q_SLOTS:
|
2010-12-03 13:49:35 +01:00
|
|
|
virtual void updateModifiedSourceFiles() = 0;
|
2010-03-02 12:51:47 +01:00
|
|
|
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles) = 0;
|
2009-11-05 12:34:02 +01:00
|
|
|
virtual void GC() = 0;
|
2009-05-12 13:45:24 +02:00
|
|
|
};
|
|
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
} // namespace CPlusPlus
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#endif // CPPMODELMANAGERINTERFACE_H
|