2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** 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
|
|
|
|
|
|
|
|
|
|
#include <cplusplus/CppDocument.h>
|
2010-12-03 10:13:15 +01:00
|
|
|
#include <languageutils/fakemetaobject.h>
|
2012-03-14 10:25:55 +01:00
|
|
|
#include "cpptools_global.h"
|
2012-02-16 15:09:56 +01:00
|
|
|
|
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;
|
2012-02-21 10:00:32 +01:00
|
|
|
class CppCompletionAssistProvider;
|
2012-02-07 15:09:08 +01:00
|
|
|
class CppHighlightingSupport;
|
2012-02-21 10:00:32 +01:00
|
|
|
class CppHighlightingSupportFactory;
|
2012-10-16 16:02:40 +02:00
|
|
|
class CppIndexingSupport;
|
2010-06-07 13:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
namespace CPlusPlus {
|
|
|
|
|
|
2012-03-14 10:25:55 +01:00
|
|
|
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2012-02-16 15:09:56 +01:00
|
|
|
|
2012-03-14 10:25:55 +01:00
|
|
|
class CPPTOOLS_EXPORT ProjectPart
|
2012-02-16 15:09:56 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ProjectPart()
|
2013-01-01 14:45:37 +01:00
|
|
|
: language(CXX11)
|
2012-03-14 10:25:55 +01:00
|
|
|
, qtVersion(UnknownQt)
|
2012-02-16 15:09:56 +01:00
|
|
|
{}
|
|
|
|
|
|
2012-11-23 16:29:00 +01:00
|
|
|
public: // enums and types
|
|
|
|
|
enum Language { CXX, CXX11, C99, C89 };
|
2012-02-16 15:09:56 +01:00
|
|
|
enum QtVersion {
|
|
|
|
|
UnknownQt = -1,
|
|
|
|
|
NoQt = 0,
|
|
|
|
|
Qt4 = 1,
|
|
|
|
|
Qt5 = 2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef QSharedPointer<ProjectPart> Ptr;
|
2012-11-23 16:29:00 +01:00
|
|
|
|
|
|
|
|
public: //attributes
|
|
|
|
|
QStringList headerFiles;
|
|
|
|
|
QStringList sourceFiles;
|
|
|
|
|
QStringList objcSourceFiles;
|
|
|
|
|
QByteArray defines;
|
|
|
|
|
QStringList includePaths;
|
|
|
|
|
QStringList frameworkPaths;
|
|
|
|
|
QStringList precompiledHeaders;
|
|
|
|
|
Language language;
|
|
|
|
|
QtVersion qtVersion;
|
2012-02-16 15:09:56 +01:00
|
|
|
};
|
|
|
|
|
|
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()
|
|
|
|
|
{ }
|
|
|
|
|
|
2012-09-24 13:48:18 +02:00
|
|
|
ProjectInfo(QPointer<ProjectExplorer::Project> project)
|
2012-02-16 15:09:56 +01:00
|
|
|
: 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-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; }
|
|
|
|
|
|
|
|
|
|
private: // attributes
|
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;
|
|
|
|
|
// 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
|
|
|
};
|
|
|
|
|
|
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
|
|
|
|
2011-08-24 10:55:48 +02:00
|
|
|
enum ExtraDiagnosticKind
|
|
|
|
|
{
|
|
|
|
|
AllExtraDiagnostics = -1,
|
2010-10-18 17:45:49 +02:00
|
|
|
ExportedQmlTypesDiagnostic,
|
|
|
|
|
CppSemanticsDiagnostic
|
2011-08-24 10:55:48 +02: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;
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
|
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;
|
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
|
|
|
|
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
|