Control.h 9.91 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
**************************************************************************/
con's avatar
con committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef CPLUSPLUS_CONTROL_H
#define CPLUSPLUS_CONTROL_H

#include "CPlusPlusForwardDeclarations.h"
56
#include "ASTfwd.h"
57
#include "Names.h"
Roberto Raggi's avatar
Roberto Raggi committed
58
59

namespace CPlusPlus {
con's avatar
con committed
60

61
62
63
64
65
66
67
class CPLUSPLUS_EXPORT TopLevelDeclarationProcessor
{
public:
    virtual ~TopLevelDeclarationProcessor() {}
    virtual bool processDeclaration(DeclarationAST *ast) = 0;
};

con's avatar
con committed
68
69
70
71
72
73
74
75
76
class CPLUSPLUS_EXPORT Control
{
public:
    Control();
    ~Control();

    TranslationUnit *translationUnit() const;
    TranslationUnit *switchTranslationUnit(TranslationUnit *unit);

77
78
79
    TopLevelDeclarationProcessor *topLevelDeclarationProcessor() const;
    void setTopLevelDeclarationProcessor(TopLevelDeclarationProcessor *processor);

con's avatar
con committed
80
81
82
83
    DiagnosticClient *diagnosticClient() const;
    void setDiagnosticClient(DiagnosticClient *diagnosticClient);

    /// Returns the canonical template name id.
Roberto Raggi's avatar
Roberto Raggi committed
84
85
86
    const TemplateNameId *templateNameId(const Identifier *id,
                                         const FullySpecifiedType *const args = 0,
                                         unsigned argc = 0);
con's avatar
con committed
87
88

    /// Returns the canonical destructor name id.
Roberto Raggi's avatar
Roberto Raggi committed
89
    const DestructorNameId *destructorNameId(const Identifier *id);
con's avatar
con committed
90
91

    /// Returns the canonical operator name id.
92
    const OperatorNameId *operatorNameId(OperatorNameId::Kind operatorId);
con's avatar
con committed
93
94

    /// Returns the canonical conversion name id.
Roberto Raggi's avatar
Roberto Raggi committed
95
    const ConversionNameId *conversionNameId(const FullySpecifiedType &type);
con's avatar
con committed
96
97

    /// Returns the canonical qualified name id.
98
    const QualifiedNameId *qualifiedNameId(const Name *base, const Name *name);
con's avatar
con committed
99

Roberto Raggi's avatar
Roberto Raggi committed
100
101
102
    const SelectorNameId *selectorNameId(const Name *const *names,
                                         unsigned nameCount,
                                         bool hasArguments);
103

con's avatar
con committed
104
105
106
107
108
109
110
111
112
113
    /// Returns a Type object of type VoidType.
    VoidType *voidType();

    /// Returns a Type object of type IntegerType.
    IntegerType *integerType(int integerId);

    /// Returns a Type object of type FloatType.
    FloatType *floatType(int floatId);

    /// Returns a Type object of type PointertoMemberType.
Roberto Raggi's avatar
Roberto Raggi committed
114
    PointerToMemberType *pointerToMemberType(const Name *memberName,
115
                                             const FullySpecifiedType &elementType);
con's avatar
con committed
116
117

    /// Returns a Type object of type PointerType.
118
    PointerType *pointerType(const FullySpecifiedType &elementType);
con's avatar
con committed
119
120

    /// Returns a Type object of type ReferenceType.
121
    ReferenceType *referenceType(const FullySpecifiedType &elementType, bool rvalueRef = false);
con's avatar
con committed
122
123

    /// Retruns a Type object of type ArrayType.
124
    ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
con's avatar
con committed
125
126

    /// Returns a Type object of type NamedType.
Roberto Raggi's avatar
Roberto Raggi committed
127
    NamedType *namedType(const Name *name);
con's avatar
con committed
128
129

    /// Creates a new Declaration symbol.
Roberto Raggi's avatar
Roberto Raggi committed
130
    Declaration *newDeclaration(unsigned sourceLocation, const Name *name);
con's avatar
con committed
131

132
133
134
    /// Creates a new EnumeratorDeclaration symbol.
    EnumeratorDeclaration *newEnumeratorDeclaration(unsigned sourceLocation, const Name *name);

con's avatar
con committed
135
    /// Creates a new Argument symbol.
Roberto Raggi's avatar
Roberto Raggi committed
136
    Argument *newArgument(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
137

Roberto Raggi's avatar
Roberto Raggi committed
138
139
140
    /// Creates a new Argument symbol.
    TypenameArgument *newTypenameArgument(unsigned sourceLocation, const Name *name = 0);

con's avatar
con committed
141
    /// Creates a new Function symbol.
Roberto Raggi's avatar
Roberto Raggi committed
142
    Function *newFunction(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
143
144

    /// Creates a new Namespace symbol.
Roberto Raggi's avatar
Roberto Raggi committed
145
    Namespace *newNamespace(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
146

147
148
149
    /// Creates a new Template symbol.
    Template *newTemplate(unsigned sourceLocation, const Name *name = 0);

150
151
152
    /// Creates a new Namespace symbol.
    NamespaceAlias *newNamespaceAlias(unsigned sourceLocation, const Name *name = 0);

con's avatar
con committed
153
    /// Creates a new BaseClass symbol.
Roberto Raggi's avatar
Roberto Raggi committed
154
    BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
155
156

    /// Creates a new Class symbol.
Roberto Raggi's avatar
Roberto Raggi committed
157
    Class *newClass(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
158
159

    /// Creates a new Enum symbol.
Roberto Raggi's avatar
Roberto Raggi committed
160
    Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
161
162
163
164
165

    /// Creates a new Block symbol.
    Block *newBlock(unsigned sourceLocation);

    /// Creates a new UsingNamespaceDirective symbol.
Roberto Raggi's avatar
Roberto Raggi committed
166
    UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
167
168

    /// Creates a new UsingDeclaration symbol.
Roberto Raggi's avatar
Roberto Raggi committed
169
    UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
170

171
    /// Creates a new ForwardClassDeclaration symbol.
Roberto Raggi's avatar
Roberto Raggi committed
172
    ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
173

174
175
176
    /// Creates a new QtPropertyDeclaration symbol.
    QtPropertyDeclaration *newQtPropertyDeclaration(unsigned sourceLocation, const Name *name = 0);

177
178
179
    /// Creates a new QtEnum symbol.
    QtEnum *newQtEnum(unsigned sourceLocation, const Name *name = 0);

Roberto Raggi's avatar
Roberto Raggi committed
180
181
    ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
    ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
182

183
    /// Creates a new Objective-C class symbol.
Roberto Raggi's avatar
Roberto Raggi committed
184
    ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0);
185
186

    /// Creates a new Objective-C class forward declaration symbol.
Roberto Raggi's avatar
Roberto Raggi committed
187
    ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
188
189

    /// Creates a new Objective-C protocol symbol.
Roberto Raggi's avatar
Roberto Raggi committed
190
    ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name = 0);
191
192

    /// Creates a new Objective-C protocol forward declaration symbol.
Roberto Raggi's avatar
Roberto Raggi committed
193
    ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0);
194

195
    /// Creates a new Objective-C method symbol.
Roberto Raggi's avatar
Roberto Raggi committed
196
    ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name = 0);
197

198
    /// Creates a new Objective-C @property declaration symbol.
Roberto Raggi's avatar
Roberto Raggi committed
199
    ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name);
200

Erik Verbruggen's avatar
Erik Verbruggen committed
201
    const Identifier *deprecatedId() const;
202
    const Identifier *unavailableId() const;
203
    // Objective-C specific context keywords.
Roberto Raggi's avatar
Roberto Raggi committed
204
205
206
207
208
209
210
211
212
    const Identifier *objcGetterId() const;
    const Identifier *objcSetterId() const;
    const Identifier *objcReadwriteId() const;
    const Identifier *objcReadonlyId() const;
    const Identifier *objcAssignId() const;
    const Identifier *objcRetainId() const;
    const Identifier *objcCopyId() const;
    const Identifier *objcNonatomicId() const;

213
214
    const OperatorNameId *findOperatorNameId(OperatorNameId::Kind operatorId) const;

Roberto Raggi's avatar
Roberto Raggi committed
215
    const Identifier *findIdentifier(const char *chars, unsigned size) const;
216
217
    const Identifier *identifier(const char *chars, unsigned size);
    const Identifier *identifier(const char *chars);
con's avatar
con committed
218

219
    typedef const Identifier *const *IdentifierIterator;
220
221
    typedef const StringLiteral *const *StringLiteralIterator;
    typedef const NumericLiteral *const *NumericLiteralIterator;
222
223
224
225

    IdentifierIterator firstIdentifier() const;
    IdentifierIterator lastIdentifier() const;

226
227
228
229
230
231
    StringLiteralIterator firstStringLiteral() const;
    StringLiteralIterator lastStringLiteral() const;

    NumericLiteralIterator firstNumericLiteral() const;
    NumericLiteralIterator lastNumericLiteral() const;

232
233
    const StringLiteral *stringLiteral(const char *chars, unsigned size);
    const StringLiteral *stringLiteral(const char *chars);
con's avatar
con committed
234

235
236
    const NumericLiteral *numericLiteral(const char *chars, unsigned size);
    const NumericLiteral *numericLiteral(const char *chars);
con's avatar
con committed
237

238
239
240
    Symbol **firstSymbol() const;
    Symbol **lastSymbol() const;

241
242
    bool hasSymbol(Symbol *symbol) const;

243
244
    void squeeze();

con's avatar
con committed
245
246
247
248
249
250
private:
    class Data;
    friend class Data;
    Data *d;
};

251
} // namespace CPlusPlus
Roberto Raggi's avatar
Roberto Raggi committed
252

con's avatar
con committed
253
254

#endif // CPLUSPLUS_CONTROL_H