Control.h 8.93 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11 12 13 14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18 19 20 21 22 23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
con's avatar
con committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
// 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"
Roberto Raggi's avatar
Roberto Raggi committed
53 54

namespace CPlusPlus {
con's avatar
con committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68

class CPLUSPLUS_EXPORT Control
{
public:
    Control();
    ~Control();

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

    DiagnosticClient *diagnosticClient() const;
    void setDiagnosticClient(DiagnosticClient *diagnosticClient);

    /// Returns the canonical template name id.
Roberto Raggi's avatar
Roberto Raggi committed
69 70 71
    const TemplateNameId *templateNameId(const Identifier *id,
                                         const FullySpecifiedType *const args = 0,
                                         unsigned argc = 0);
con's avatar
con committed
72 73

    /// Returns the canonical destructor name id.
Roberto Raggi's avatar
Roberto Raggi committed
74
    const DestructorNameId *destructorNameId(const Identifier *id);
con's avatar
con committed
75 76

    /// Returns the canonical operator name id.
Roberto Raggi's avatar
Roberto Raggi committed
77
    const OperatorNameId *operatorNameId(int operatorId);
con's avatar
con committed
78 79

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

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

Roberto Raggi's avatar
Roberto Raggi committed
85 86 87
    const SelectorNameId *selectorNameId(const Name *const *names,
                                         unsigned nameCount,
                                         bool hasArguments);
88

con's avatar
con committed
89 90 91 92 93 94 95 96 97 98
    /// 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
99
    PointerToMemberType *pointerToMemberType(const Name *memberName,
100
                                             const FullySpecifiedType &elementType);
con's avatar
con committed
101 102

    /// Returns a Type object of type PointerType.
103
    PointerType *pointerType(const FullySpecifiedType &elementType);
con's avatar
con committed
104 105

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

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

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

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

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

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

con's avatar
con committed
123
    /// Creates a new Function symbol.
Roberto Raggi's avatar
Roberto Raggi committed
124
    Function *newFunction(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
125 126

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

129 130 131
    /// Creates a new Template symbol.
    Template *newTemplate(unsigned sourceLocation, const Name *name = 0);

132 133 134
    /// Creates a new Namespace symbol.
    NamespaceAlias *newNamespaceAlias(unsigned sourceLocation, const Name *name = 0);

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

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

    /// Creates a new Enum symbol.
Roberto Raggi's avatar
Roberto Raggi committed
142
    Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
con's avatar
con committed
143 144 145 146 147

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

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

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

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

Roberto Raggi's avatar
Roberto Raggi committed
156 157
    ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
    ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
158

159
    /// Creates a new Objective-C class symbol.
Roberto Raggi's avatar
Roberto Raggi committed
160
    ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0);
161 162

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

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

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

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

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

Erik Verbruggen's avatar
Erik Verbruggen committed
177
    const Identifier *deprecatedId() const;
178
    const Identifier *unavailableId() const;
179
    // Objective-C specific context keywords.
Roberto Raggi's avatar
Roberto Raggi committed
180 181 182 183 184 185 186 187 188 189
    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;

    const Identifier *findIdentifier(const char *chars, unsigned size) const;
190 191
    const Identifier *identifier(const char *chars, unsigned size);
    const Identifier *identifier(const char *chars);
con's avatar
con committed
192

193
    typedef const Identifier *const *IdentifierIterator;
194 195
    typedef const StringLiteral *const *StringLiteralIterator;
    typedef const NumericLiteral *const *NumericLiteralIterator;
196 197 198 199

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

200 201 202 203 204 205
    StringLiteralIterator firstStringLiteral() const;
    StringLiteralIterator lastStringLiteral() const;

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

206 207
    const StringLiteral *stringLiteral(const char *chars, unsigned size);
    const StringLiteral *stringLiteral(const char *chars);
con's avatar
con committed
208

209 210
    const NumericLiteral *numericLiteral(const char *chars, unsigned size);
    const NumericLiteral *numericLiteral(const char *chars);
con's avatar
con committed
211

212 213
    bool hasSymbol(Symbol *symbol) const;

214 215
    void squeeze();

con's avatar
con committed
216 217 218 219 220 221
private:
    class Data;
    friend class Data;
    Data *d;
};

Roberto Raggi's avatar
Roberto Raggi committed
222 223
} // end of namespace CPlusPlus

con's avatar
con committed
224 225

#endif // CPLUSPLUS_CONTROL_H