Files
qt-creator/src/libs/cplusplus/ModelManagerInterface.h

168 lines
5.1 KiB
C
Raw Normal View History

/**************************************************************************
2008-12-02 12:01:29 +01:00
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
2008-12-02 12:01:29 +01:00
**
** Contact: Nokia Corporation (qt-info@nokia.com)
2008-12-02 12:01:29 +01:00
**
**
** GNU Lesser General Public License Usage
**
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.
**
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
** Nokia at qt-info@nokia.com.
2008-12-02 12:01:29 +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>
#include <languageutils/fakemetaobject.h>
2008-12-02 12:01:29 +01:00
#include <QtCore/QObject>
2009-12-07 12:36:16 +01:00
#include <QtCore/QHash>
#include <QtCore/QPointer>
2009-12-07 11:12:55 +01:00
#include <QtCore/QStringList>
2010-03-02 12:51:47 +01:00
#include <QtCore/QFuture>
2008-12-02 12:01:29 +01:00
2010-06-07 12:12:07 +02:00
namespace Core {
class IEditor;
}
namespace CPlusPlus {
class LookupContext;
}
2008-12-02 12:01:29 +01:00
namespace ProjectExplorer {
class Project;
}
namespace CppTools {
class AbstractEditorSupport;
}
namespace CPlusPlus {
class CPLUSPLUS_EXPORT CppModelManagerInterface : public QObject
2008-12-02 12:01:29 +01:00
{
Q_OBJECT
public:
class ProjectInfo
2008-12-02 12:01:29 +01:00
{
public:
ProjectInfo()
{ }
ProjectInfo(QPointer<ProjectExplorer::Project> project)
: project(project)
{ }
operator bool() const
{ return ! project.isNull(); }
bool isValid() const
{ return ! project.isNull(); }
bool isNull() const
{ return project.isNull(); }
public: // attributes
QPointer<ProjectExplorer::Project> project;
2008-12-02 12:01:29 +01:00
QString projectPath;
QByteArray defines;
QStringList sourceFiles;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
2008-12-02 12:01:29 +01:00
};
class WorkingCopy
{
public:
void insert(const QString &fileName, const QString &source, unsigned revision = 0)
{ _elements.insert(fileName, qMakePair(source, revision)); }
bool contains(const QString &fileName) const
{ return _elements.contains(fileName); }
QString source(const QString &fileName) const
{ return _elements.value(fileName).first; }
QPair<QString, unsigned> get(const QString &fileName) const
{ return _elements.value(fileName); }
private:
typedef QHash<QString, QPair<QString, unsigned> > Table;
Table _elements;
};
enum ExtraDiagnosticKind
{
AllExtraDiagnostics = -1,
ExportedQmlTypesDiagnostic
};
2008-12-02 12:01:29 +01:00
public:
CppModelManagerInterface(QObject *parent = 0);
virtual ~CppModelManagerInterface();
2008-12-02 12:01:29 +01:00
static CppModelManagerInterface *instance();
2010-06-07 12:12:07 +02:00
virtual bool isCppEditor(Core::IEditor *editor) const = 0;
virtual WorkingCopy workingCopy() const = 0;
virtual CPlusPlus::Snapshot snapshot() const = 0;
2008-12-02 12:01:29 +01:00
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
2009-08-07 13:02:36 +02:00
virtual QList<int> references(CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context) = 0;
virtual void renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
const QString &replacement = QString()) = 0;
virtual void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) = 0;
virtual void findMacroUsages(const CPlusPlus::Macro &macro) = 0;
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;
Q_SIGNALS:
void documentUpdated(CPlusPlus::Document::Ptr doc);
void sourceFilesRefreshed(const QStringList &files);
void extraDiagnosticsUpdated(QString fileName);
public Q_SLOTS:
virtual void updateModifiedSourceFiles() = 0;
2010-03-02 12:51:47 +01:00
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual void GC() = 0;
};
} // namespace CPlusPlus
2008-12-02 12:01:29 +01:00
#endif // CPPMODELMANAGERINTERFACE_H