ModelManagerInterface.h 5.07 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** 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.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33 34 35 36
#ifndef CPPMODELMANAGERINTERFACE_H
#define CPPMODELMANAGERINTERFACE_H

#include <cplusplus/CppDocument.h>
37
#include <languageutils/fakemetaobject.h>
con's avatar
con committed
38
#include <QtCore/QObject>
39
#include <QtCore/QHash>
40
#include <QtCore/QPointer>
41
#include <QtCore/QStringList>
dt's avatar
dt committed
42
#include <QtCore/QFuture>
con's avatar
con committed
43

44 45 46 47
namespace Core {
    class IEditor;
}

48 49 50 51
namespace CPlusPlus {
    class LookupContext;
}

con's avatar
con committed
52 53 54 55 56
namespace ProjectExplorer {
    class Project;
}

namespace CppTools {
57
    class AbstractEditorSupport;
58 59
}

60 61 62
namespace CPlusPlus {

class CPLUSPLUS_EXPORT CppModelManagerInterface : public QObject
con's avatar
con committed
63 64 65 66
{
    Q_OBJECT

public:
67
    class ProjectInfo
con's avatar
con committed
68
    {
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
    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;
con's avatar
con committed
88 89 90 91 92
        QString projectPath;
        QByteArray defines;
        QStringList sourceFiles;
        QStringList includePaths;
        QStringList frameworkPaths;
93
        QStringList precompiledHeaders;
con's avatar
con committed
94 95
    };

96 97 98
    class WorkingCopy
    {
    public:
99 100
        void insert(const QString &fileName, const QString &source, unsigned revision = 0)
        { _elements.insert(fileName, qMakePair(source, revision)); }
101 102 103 104 105

        bool contains(const QString &fileName) const
        { return _elements.contains(fileName); }

        QString source(const QString &fileName) const
106 107 108
        { return _elements.value(fileName).first; }

        QPair<QString, unsigned> get(const QString &fileName) const
109 110 111
        { return _elements.value(fileName); }

    private:
112
        typedef QHash<QString, QPair<QString, unsigned> > Table;
113 114
        Table _elements;
    };
115

116 117 118 119 120 121
    enum ExtraDiagnosticKind
    {
        AllExtraDiagnostics = -1,
        ExportedQmlTypesDiagnostic
    };

con's avatar
con committed
122
public:
123 124
    CppModelManagerInterface(QObject *parent = 0);
    virtual ~CppModelManagerInterface();
con's avatar
con committed
125

126 127
    static CppModelManagerInterface *instance();

128 129
    virtual bool isCppEditor(Core::IEditor *editor) const = 0;

130
    virtual WorkingCopy workingCopy() const = 0;
131
    virtual CPlusPlus::Snapshot snapshot() const = 0;
con's avatar
con committed
132

133 134 135
    virtual QList<ProjectInfo> projectInfos() const = 0;
    virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
    virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
136

137 138
    virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
    virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
Roberto Raggi's avatar
Roberto Raggi committed
139

140
    virtual QList<int> references(CPlusPlus::Symbol *symbol,
141
                                  const CPlusPlus::LookupContext &context) = 0;
142

143 144
    virtual void renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context,
                              const QString &replacement = QString()) = 0;
145
    virtual void findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) = 0;
146

Christian Kamm's avatar
Christian Kamm committed
147 148
    virtual void findMacroUsages(const CPlusPlus::Macro &macro) = 0;

149 150 151 152 153
    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;

154 155
Q_SIGNALS:
    void documentUpdated(CPlusPlus::Document::Ptr doc);
156
    void sourceFilesRefreshed(const QStringList &files);
157

158
public Q_SLOTS:
159
    virtual void updateModifiedSourceFiles() = 0;
dt's avatar
dt committed
160
    virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles) = 0;
161
    virtual void GC() = 0;
162 163
};

164
} // namespace CPlusPlus
con's avatar
con committed
165 166

#endif // CPPMODELMANAGERINTERFACE_H