OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / cppeditor / cppelementevaluator.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef CPPHIGHLEVELMODEL_H
34 #define CPPHIGHLEVELMODEL_H
35
36 #include "cppeditor.h"
37
38 #include <texteditor/helpitem.h>
39
40 #include <cplusplus/CppDocument.h>
41 #include <cplusplus/Overview.h>
42
43 #include <QtCore/QString>
44 #include <QtCore/QStringList>
45 #include <QtCore/QSharedPointer>
46 #include <QtGui/QTextCursor>
47 #include <QtGui/QIcon>
48
49 namespace CPlusPlus {
50 class LookupItem;
51 class LookupContext;
52 }
53
54 namespace CppTools {
55 class CppModelManagerInterface;
56 }
57
58 namespace CppEditor {
59 namespace Internal {
60
61 class CPPEditorWidget;
62 class CppElement;
63
64 class CppElementEvaluator
65 {
66 public:
67     CppElementEvaluator(CPPEditorWidget *editor);
68
69     void setTextCursor(const QTextCursor &tc);
70     void setLookupBaseClasses(const bool lookup);
71
72     void execute();
73     bool identifiedCppElement() const;
74     const QSharedPointer<CppElement> &cppElement() const;
75     bool hasDiagnosis() const;
76     const QString &diagnosis() const;
77
78 private:
79     void clear();
80     void checkDiagnosticMessage(const CPlusPlus::Document::Ptr &document, unsigned line);
81     bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line);
82     bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos);
83     void handleLookupItemMatch(const CPlusPlus::Snapshot &snapshot,
84                                const CPlusPlus::LookupItem &lookupItem,
85                                const CPlusPlus::LookupContext &lookupContext);
86
87     CPPEditorWidget *m_editor;
88     CPlusPlus::CppModelManagerInterface *m_modelManager;
89     QTextCursor m_tc;
90     bool m_lookupBaseClasses;
91     QSharedPointer<CppElement> m_element;
92     QString m_diagnosis;
93 };
94
95 class CppElement
96 {
97 public:
98     virtual ~CppElement();
99
100     const TextEditor::HelpItem::Category &helpCategory() const;
101     const QStringList &helpIdCandidates() const;
102     const QString &helpMark() const;
103     const CPPEditorWidget::Link &link() const;
104     const QString &tooltip() const;
105
106 protected:
107     CppElement();
108
109     void setHelpCategory(const TextEditor::HelpItem::Category &category);
110     void setLink(const CPPEditorWidget::Link &link);
111     void setTooltip(const QString &tooltip);
112     void setHelpIdCandidates(const QStringList &candidates);
113     void addHelpIdCandidate(const QString &candidate);
114     void setHelpMark(const QString &mark);
115
116 private:
117     TextEditor::HelpItem::Category m_helpCategory;
118     QStringList m_helpIdCandidates;
119     QString m_helpMark;
120     CPPEditorWidget::Link m_link;
121     QString m_tooltip;
122 };
123
124 class Unknown : public CppElement
125 {
126 public:
127     Unknown(const QString &type);
128     virtual ~Unknown();
129
130     const QString &type() const;
131
132 private:
133     QString m_type;
134 };
135
136 class CppInclude : public CppElement
137 {
138 public:
139     CppInclude(const CPlusPlus::Document::Include &includeFile);
140     virtual ~CppInclude();
141
142     const QString &path() const;
143     const QString &fileName() const;
144
145 private:
146     QString m_path;
147     QString m_fileName;
148 };
149
150 class CppMacro : public CppElement
151 {
152 public:
153     CppMacro(const CPlusPlus::Macro &macro);
154     virtual ~CppMacro();
155 };
156
157 class CppDeclarableElement : public CppElement
158 {
159 public:
160     CppDeclarableElement(CPlusPlus::Symbol *declaration);
161     virtual ~CppDeclarableElement();
162
163     const QString &name() const;
164     const QString &qualifiedName() const;
165     const QString &type() const;
166     const QIcon &icon() const;
167
168 protected:
169     void setName(const QString &name);
170     void setQualifiedName(const QString &name);
171     void setType(const QString &type);
172     void setIcon(const QIcon &icon);
173
174 private:
175     QString m_name;
176     QString m_qualifiedName;
177     QString m_type;
178     QIcon m_icon;
179 };
180
181 class CppNamespace : public CppDeclarableElement
182 {
183 public:
184     CppNamespace(CPlusPlus::Symbol *declaration);
185     virtual ~CppNamespace();
186 };
187
188 class CppClass : public CppDeclarableElement
189 {
190 public:
191     CppClass(CPlusPlus::Symbol *declaration);
192     virtual ~CppClass();
193
194     void lookupBases(CPlusPlus::Symbol *declaration, const CPlusPlus::LookupContext &context);
195
196     const QList<CppClass> &bases() const;
197
198 private:
199     QList<CppClass> m_bases;
200 };
201
202 class CppFunction : public CppDeclarableElement
203 {
204 public:
205     CppFunction(CPlusPlus::Symbol *declaration);
206     virtual ~CppFunction();
207 };
208
209 class CppEnum : public CppDeclarableElement
210 {
211 public:
212     CppEnum(CPlusPlus::Symbol *declaration);
213     virtual ~CppEnum();
214 };
215
216 class CppTypedef : public CppDeclarableElement
217 {
218 public:
219     CppTypedef(CPlusPlus::Symbol *declaration);
220     virtual ~CppTypedef();
221 };
222
223 class CppVariable : public CppDeclarableElement
224 {
225 public:
226     CppVariable(CPlusPlus::Symbol *declaration,
227                 const CPlusPlus::LookupContext &context,
228                 CPlusPlus::Scope *scope);
229     virtual ~CppVariable();
230 };
231
232 class CppTemplate : public CppDeclarableElement
233 {
234 public:
235     CppTemplate(CPlusPlus::Symbol *declaration);
236     virtual ~CppTemplate();
237
238     bool isClassTemplate() const;
239     bool isFunctionTemplate() const;
240
241 private:
242     bool m_isClassTemplate;
243 };
244
245 } // namespace Internal
246 } // namespace CppEditor
247
248 #endif // CPPHIGHLEVELMODEL_H