1 /***************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Qt Software Information (qt-info@nokia.com)
10 ** Non-Open Source Usage
12 ** Licensees may use this file in accordance with the Qt Beta Version
13 ** License Agreement, Agreement version 2.2 provided with the Software or,
14 ** alternatively, in accordance with the terms contained in a written
15 ** agreement between you and Nokia.
17 ** GNU General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU General
20 ** Public License versions 2.0 or 3.0 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.GPL included in the packaging
22 ** of this file. Please review the following information to ensure GNU
23 ** General Public Licensing requirements will be met:
25 ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
26 ** http://www.gnu.org/copyleft/gpl.html.
28 ** In addition, as a special exception, Nokia gives you certain additional
29 ** rights. These rights are described in the Nokia Qt GPL Exception version
30 ** 1.2, included in the file GPL_EXCEPTION.txt in this package.
32 ***************************************************************************/
37 #include <CPlusPlusForwardDeclarations.h>
42 #include <QSharedPointer>
44 #include <QStringList>
48 class CPLUSPLUS_EXPORT Document
50 Document(const Document &other);
51 void operator =(const Document &other);
53 Document(const QString &fileName);
56 typedef QSharedPointer<Document> Ptr;
61 QString fileName() const;
63 QStringList includedFiles() const;
64 void addIncludeFile(const QString &fileName);
66 QByteArray definedMacros() const;
67 QSet<QByteArray> macroNames() const;
69 void appendMacro(const QByteArray ¯oName, const QByteArray &text);
71 Control *control() const;
72 TranslationUnit *translationUnit() const;
74 bool skipFunctionBody() const;
75 void setSkipFunctionBody(bool skipFunctionBody);
77 unsigned globalSymbolCount() const;
78 Symbol *globalSymbolAt(unsigned index) const;
79 Scope *globalSymbols() const; // ### deprecate?
80 Namespace *globalNamespace() const;
82 Symbol *findSymbolAt(unsigned line, unsigned column) const;
84 void setSource(const QByteArray &source);
85 void startSkippingBlocks(unsigned offset);
86 void stopSkippingBlocks(unsigned offset);
88 void parse(); // ### remove
90 void releaseTranslationUnit();
92 static Ptr create(const QString &fileName);
94 class DiagnosticMessage
104 DiagnosticMessage(int level, const QString &fileName,
105 int line, int column,
117 bool isWarning() const
118 { return _level == Warning; }
121 { return _level == Error; }
124 { return _level == Fatal; }
126 QString fileName() const
127 { return _fileName; }
146 void addDiagnosticMessage(const DiagnosticMessage &d)
147 { _diagnosticMessages.append(d); }
149 QList<DiagnosticMessage> diagnosticMessages() const
150 { return _diagnosticMessages; }
158 inline Block(unsigned begin = 0, unsigned end = 0)
159 : _begin(begin), _end(end)
162 inline unsigned begin() const
165 inline unsigned end() const
169 QList<Block> skippedBlocks() const
170 { return _skippedBlocks; }
173 Symbol *findSymbolAt(unsigned line, unsigned column, Scope *scope) const;
177 QStringList _includedFiles;
179 TranslationUnit *_translationUnit;
180 Namespace *_globalNamespace;
181 QList<DiagnosticMessage> _diagnosticMessages;
182 QByteArray _definedMacros;
183 QSet<QByteArray> _macroNames;
184 QList<Block> _skippedBlocks;
187 } // end of namespace CPlusPlus
189 #endif // CPPDOCUMENT_H