1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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.
**
** GNU Lesser General Public License Usage
** 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
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPMODELMANAGERINTERFACE_H
#define CPPMODELMANAGERINTERFACE_H
#include <cplusplus/CppDocument.h>
#include <languageutils/fakemetaobject.h>
#include "cpptools_global.h"
#include <QObject>
#include <QHash>
#include <QPointer>
#include <QStringList>
#include <QFuture>
namespace Core {
class IEditor;
}
namespace CPlusPlus {
class LookupContext;
}
namespace ProjectExplorer {
class Project;
}
namespace CppTools {
class AbstractEditorSupport;
class CppCompletionSupport;
class CppCompletionAssistProvider;
class CppHighlightingSupport;
class CppHighlightingSupportFactory;
}
namespace CPlusPlus {
class CPPTOOLS_EXPORT CppModelManagerInterface : public QObject
{
Q_OBJECT
public:
enum Language { CXX, OBJC };
class CPPTOOLS_EXPORT ProjectPart
{
public:
ProjectPart()
: language(CXX)
, cxx11Enabled(false)
, qtVersion(UnknownQt)
{}
public: //attributes
QStringList sourceFiles;
QByteArray defines;
QStringList includePaths;
QStringList frameworkPaths;
QStringList precompiledHeaders;
Language language;
bool cxx11Enabled;
enum QtVersion {
UnknownQt = -1,
NoQt = 0,
Qt4 = 1,
Qt5 = 2
};
QtVersion qtVersion;
bool objcEnabled() const
{ return language == CppModelManagerInterface::OBJC; }
typedef QSharedPointer<ProjectPart> Ptr;
};
class CPPTOOLS_EXPORT ProjectInfo
{
public:
ProjectInfo()
{ }
ProjectInfo(QWeakPointer<ProjectExplorer::Project> project)
: m_project(project)
{ }
operator bool() const
{ return ! m_project.isNull(); }
bool isValid() const
{ return ! m_project.isNull(); }
bool isNull() const
{ return m_project.isNull(); }
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;
};
class CPPTOOLS_EXPORT 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); }
QHashIterator<QString, QPair<QString, unsigned> > iterator() const
{ return QHashIterator<QString, QPair<QString, unsigned> >(_elements); }
private:
typedef QHash<QString, QPair<QString, unsigned> > Table;
Table _elements;
};
enum ExtraDiagnosticKind
{
AllExtraDiagnostics = -1,
ExportedQmlTypesDiagnostic,
CppSemanticsDiagnostic
};
public:
CppModelManagerInterface(QObject *parent = 0);
virtual ~CppModelManagerInterface();
static CppModelManagerInterface *instance();
virtual bool isCppEditor(Core::IEditor *editor) const = 0;
virtual WorkingCopy workingCopy() const = 0;
virtual CPlusPlus::Snapshot snapshot() const = 0;
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
virtual QList<ProjectPart::Ptr> projectPart(const QString &fileName) const = 0;
virtual void addEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
virtual void removeEditorSupport(CppTools::AbstractEditorSupport *editorSupport) = 0;
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 renameMacroUsages(const CPlusPlus::Macro ¯o, const QString &replacement = QString()) = 0;
virtual void findMacroUsages(const CPlusPlus::Macro ¯o) = 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;
virtual CppTools::CppCompletionSupport *completionSupport(Core::IEditor *editor) const = 0;
virtual void setCppCompletionAssistProvider(CppTools::CppCompletionAssistProvider *completionAssistProvider) = 0;
virtual CppTools::CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const = 0;
virtual void setHighlightingSupportFactory(CppTools::CppHighlightingSupportFactory *highlightingFactory) = 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;
virtual QFuture<void> updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual void GC() = 0;
};
} // namespace CPlusPlus
#endif // CPPMODELMANAGERINTERFACE_H
|