author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:10:48 +0300 | |
changeset 30 | 5dc02b23752f |
parent 18 | 2f34d5167611 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the tools applications of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
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 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
/* |
|
43 |
codeparser.cpp |
|
44 |
*/ |
|
45 |
||
46 |
#include "codeparser.h" |
|
47 |
#include "node.h" |
|
48 |
#include "tree.h" |
|
49 |
#include "config.h" |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
50 |
#include <QDebug> |
0 | 51 |
|
52 |
QT_BEGIN_NAMESPACE |
|
53 |
||
54 |
#define COMMAND_COMPAT Doc::alias(QLatin1String("compat")) |
|
55 |
#define COMMAND_DEPRECATED Doc::alias(QLatin1String("deprecated")) // ### don't document |
|
56 |
#define COMMAND_INGROUP Doc::alias(QLatin1String("ingroup")) |
|
57 |
#define COMMAND_INMODULE Doc::alias(QLatin1String("inmodule")) // ### don't document |
|
58 |
#define COMMAND_INTERNAL Doc::alias(QLatin1String("internal")) |
|
59 |
#define COMMAND_MAINCLASS Doc::alias(QLatin1String("mainclass")) |
|
60 |
#define COMMAND_NONREENTRANT Doc::alias(QLatin1String("nonreentrant")) |
|
61 |
#define COMMAND_OBSOLETE Doc::alias(QLatin1String("obsolete")) |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
62 |
#define COMMAND_PAGEKEYWORDS Doc::alias(QLatin1String("pagekeywords")) |
0 | 63 |
#define COMMAND_PRELIMINARY Doc::alias(QLatin1String("preliminary")) |
64 |
#define COMMAND_INPUBLICGROUP Doc::alias(QLatin1String("inpublicgroup")) |
|
65 |
#define COMMAND_REENTRANT Doc::alias(QLatin1String("reentrant")) |
|
66 |
#define COMMAND_SINCE Doc::alias(QLatin1String("since")) |
|
67 |
#define COMMAND_SUBTITLE Doc::alias(QLatin1String("subtitle")) |
|
68 |
#define COMMAND_THREADSAFE Doc::alias(QLatin1String("threadsafe")) |
|
69 |
#define COMMAND_TITLE Doc::alias(QLatin1String("title")) |
|
70 |
||
71 |
QList<CodeParser *> CodeParser::parsers; |
|
72 |
bool CodeParser::showInternal = false; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
73 |
QMap<QString,QString> CodeParser::nameToTitle; |
0 | 74 |
|
75 |
/*! |
|
76 |
The constructor adds this code parser to the static |
|
77 |
list of code parsers. |
|
78 |
*/ |
|
79 |
CodeParser::CodeParser() |
|
80 |
{ |
|
81 |
parsers.prepend(this); |
|
82 |
} |
|
83 |
||
84 |
/*! |
|
85 |
The destructor removes this code parser from the static |
|
86 |
list of code parsers. |
|
87 |
*/ |
|
88 |
CodeParser::~CodeParser() |
|
89 |
{ |
|
90 |
parsers.removeAll(this); |
|
91 |
} |
|
92 |
||
93 |
/*! |
|
94 |
Initialize the code parser base class. |
|
95 |
*/ |
|
96 |
void CodeParser::initializeParser(const Config& config) |
|
97 |
{ |
|
98 |
showInternal = config.getBool(QLatin1String(CONFIG_SHOWINTERNAL)); |
|
99 |
} |
|
100 |
||
101 |
/*! |
|
102 |
Teerminating a code parser is trivial. |
|
103 |
*/ |
|
104 |
void CodeParser::terminateParser() |
|
105 |
{ |
|
106 |
// nothing. |
|
107 |
} |
|
108 |
||
109 |
QString CodeParser::headerFileNameFilter() |
|
110 |
{ |
|
111 |
return sourceFileNameFilter(); |
|
112 |
} |
|
113 |
||
114 |
void CodeParser::parseHeaderFile(const Location& location, |
|
115 |
const QString& filePath, |
|
116 |
Tree *tree) |
|
117 |
{ |
|
118 |
parseSourceFile(location, filePath, tree); |
|
119 |
} |
|
120 |
||
121 |
void CodeParser::doneParsingHeaderFiles(Tree *tree) |
|
122 |
{ |
|
123 |
doneParsingSourceFiles(tree); |
|
124 |
} |
|
125 |
||
126 |
/*! |
|
127 |
All the code parsers in the static list are initialized here, |
|
128 |
after the qdoc configuration variables have been set. |
|
129 |
*/ |
|
130 |
void CodeParser::initialize(const Config& config) |
|
131 |
{ |
|
132 |
QList<CodeParser *>::ConstIterator p = parsers.begin(); |
|
133 |
while (p != parsers.end()) { |
|
134 |
(*p)->initializeParser(config); |
|
135 |
++p; |
|
136 |
} |
|
137 |
} |
|
138 |
||
139 |
/*! |
|
140 |
All the code parsers in the static list are terminated here. |
|
141 |
*/ |
|
142 |
void CodeParser::terminate() |
|
143 |
{ |
|
144 |
QList<CodeParser *>::ConstIterator p = parsers.begin(); |
|
145 |
while (p != parsers.end()) { |
|
146 |
(*p)->terminateParser(); |
|
147 |
++p; |
|
148 |
} |
|
149 |
} |
|
150 |
||
151 |
CodeParser *CodeParser::parserForLanguage(const QString& language) |
|
152 |
{ |
|
153 |
QList<CodeParser *>::ConstIterator p = parsers.begin(); |
|
154 |
while (p != parsers.end()) { |
|
155 |
if ((*p)->language() == language) |
|
156 |
return *p; |
|
157 |
++p; |
|
158 |
} |
|
159 |
return 0; |
|
160 |
} |
|
161 |
||
162 |
/*! |
|
163 |
Returns the set of strings representing the common metacommands. |
|
164 |
*/ |
|
165 |
QSet<QString> CodeParser::commonMetaCommands() |
|
166 |
{ |
|
167 |
return QSet<QString>() << COMMAND_COMPAT |
|
168 |
<< COMMAND_DEPRECATED |
|
169 |
<< COMMAND_INGROUP |
|
170 |
<< COMMAND_INMODULE |
|
171 |
<< COMMAND_INTERNAL |
|
172 |
<< COMMAND_MAINCLASS |
|
173 |
<< COMMAND_NONREENTRANT |
|
174 |
<< COMMAND_OBSOLETE |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
175 |
<< COMMAND_PAGEKEYWORDS |
0 | 176 |
<< COMMAND_PRELIMINARY |
177 |
<< COMMAND_INPUBLICGROUP |
|
178 |
<< COMMAND_REENTRANT |
|
179 |
<< COMMAND_SINCE |
|
180 |
<< COMMAND_SUBTITLE |
|
181 |
<< COMMAND_THREADSAFE |
|
182 |
<< COMMAND_TITLE; |
|
183 |
} |
|
184 |
||
185 |
/*! |
|
186 |
The topic command has been processed. Now process the other |
|
187 |
metacommands that were found. These are not the text markup |
|
188 |
commands. |
|
189 |
*/ |
|
190 |
void CodeParser::processCommonMetaCommand(const Location &location, |
|
191 |
const QString &command, |
|
192 |
const QString &arg, |
|
193 |
Node *node, |
|
194 |
Tree *tree) |
|
195 |
{ |
|
196 |
if (command == COMMAND_COMPAT) { |
|
197 |
node->setStatus(Node::Compat); |
|
198 |
} |
|
199 |
else if (command == COMMAND_DEPRECATED) { |
|
200 |
node->setStatus(Node::Deprecated); |
|
201 |
} |
|
202 |
else if (command == COMMAND_INGROUP) { |
|
203 |
tree->addToGroup(node, arg); |
|
204 |
} |
|
205 |
else if (command == COMMAND_INPUBLICGROUP) { |
|
206 |
tree->addToPublicGroup(node, arg); |
|
207 |
} |
|
208 |
else if (command == COMMAND_INMODULE) { |
|
209 |
node->setModuleName(arg); |
|
210 |
} |
|
211 |
else if (command == COMMAND_MAINCLASS) { |
|
212 |
node->setStatus(Node::Main); |
|
213 |
} |
|
214 |
else if (command == COMMAND_OBSOLETE) { |
|
215 |
if (node->status() != Node::Compat) |
|
216 |
node->setStatus(Node::Obsolete); |
|
217 |
} |
|
218 |
else if (command == COMMAND_NONREENTRANT) { |
|
219 |
node->setThreadSafeness(Node::NonReentrant); |
|
220 |
} |
|
221 |
else if (command == COMMAND_PRELIMINARY) { |
|
222 |
node->setStatus(Node::Preliminary); |
|
223 |
} |
|
224 |
else if (command == COMMAND_INTERNAL) { |
|
225 |
if (!showInternal) { |
|
226 |
node->setAccess(Node::Private); |
|
227 |
node->setStatus(Node::Internal); |
|
228 |
} |
|
229 |
} |
|
230 |
else if (command == COMMAND_REENTRANT) { |
|
231 |
node->setThreadSafeness(Node::Reentrant); |
|
232 |
} |
|
233 |
else if (command == COMMAND_SINCE) { |
|
234 |
node->setSince(arg); |
|
235 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
236 |
else if (command == COMMAND_PAGEKEYWORDS) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
237 |
node->addPageKeywords(arg); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
238 |
} |
0 | 239 |
else if (command == COMMAND_SUBTITLE) { |
240 |
if (node->type() == Node::Fake) { |
|
241 |
FakeNode *fake = static_cast<FakeNode *>(node); |
|
242 |
fake->setSubTitle(arg); |
|
243 |
} |
|
244 |
else |
|
245 |
location.warning(tr("Ignored '\\%1'").arg(COMMAND_SUBTITLE)); |
|
246 |
} |
|
247 |
else if (command == COMMAND_THREADSAFE) { |
|
248 |
node->setThreadSafeness(Node::ThreadSafe); |
|
249 |
} |
|
250 |
else if (command == COMMAND_TITLE) { |
|
251 |
if (node->type() == Node::Fake) { |
|
252 |
FakeNode *fake = static_cast<FakeNode *>(node); |
|
253 |
fake->setTitle(arg); |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
254 |
nameToTitle.insert(fake->name(),arg); |
0 | 255 |
} |
256 |
else |
|
257 |
location.warning(tr("Ignored '\\%1'").arg(COMMAND_TITLE)); |
|
258 |
} |
|
259 |
} |
|
260 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
261 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
262 |
Find the page title given the page \a name and return it. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
263 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
264 |
const QString CodeParser::titleFromName(const QString& name) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
265 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
266 |
const QString t = nameToTitle.value(name); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
267 |
return t; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
268 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
269 |
|
0 | 270 |
QT_END_NAMESPACE |