21
22
23
24
27
28
29
30
31TagFileWriter::TagFileWriter() : m_qdb(QDocDatabase::qdocDB()) { }
34
35
36
40 for (
const auto *node : nonFunctionList) {
41 if (!node->url().isNull() || node->isPrivate())
45 switch (node->nodeType()) {
58 const auto *aggregate =
static_cast<
const Aggregate *>(node);
60 QString access =
"public";
61 if (node->isProtected())
64 QString objName = node->name();
67 if (objName.isEmpty() && node != m_qdb->primaryTreeRoot())
71 writer.writeStartElement(
"compound");
72 writer.writeAttribute(
"kind", kind);
74 if (node->isClassNode()) {
75 writer.writeTextElement(
"name", node->fullDocumentName());
76 writer.writeTextElement(
"filename", m_generator->fullDocumentLocation(node));
79 const auto *classNode =
static_cast<
const ClassNode *>(node);
80 const QList<RelatedClass> &bases = classNode->baseClasses();
81 for (
const auto &related : bases) {
82 ClassNode *n = related.m_node;
84 writer.writeTextElement(
"base", n->name());
88 generateTagFileMembers(writer, aggregate);
89 writer.writeEndElement();
92 generateTagFileCompounds(writer, aggregate);
94 writer.writeTextElement(
"name", node->fullDocumentName());
95 writer.writeTextElement(
"filename", m_generator->fullDocumentLocation(node));
98 generateTagFileMembers(writer, aggregate);
99 writer.writeEndElement();
102 generateTagFileCompounds(writer, aggregate);
108
109
110
115 for (
const auto *node : childNodes) {
116 if (!node->url().isNull())
121 switch (node->nodeType()) {
124 kind =
"enumeration";
126 case Node::TypeAlias:
139 case Node::Namespace:
140 nodeName =
"namespace";
153 switch (node->access()) {
157 case Access::Protected:
158 access =
"protected";
160 case Access::Private:
165 QString objName = node->name();
168 if (objName.isEmpty() && node != m_qdb->primaryTreeRoot())
172 writer.writeStartElement(nodeName);
174 writer.writeAttribute(
"kind", kind);
176 switch (node->nodeType()) {
180 writer.writeCharacters(node->fullDocumentName());
181 writer.writeEndElement();
183 case Node::Namespace:
184 writer.writeCharacters(node->fullDocumentName());
185 writer.writeEndElement();
187 case Node::Function: {
189
190
191
193 const auto *functionNode =
static_cast<
const FunctionNode *>(node);
194 writer.writeAttribute(
"protection", access);
195 writer.writeAttribute(
"virtualness", functionNode->virtualness());
196 writer.writeAttribute(
"static", functionNode->isStatic() ?
"yes" :
"no");
198 if (functionNode->isNonvirtual())
199 writer.writeTextElement(
"type", functionNode->returnType());
201 writer.writeTextElement(
"type",
"virtual " + functionNode->returnType());
203 writer.writeTextElement(
"name", objName);
204 const QStringList pieces =
205 m_generator->fullDocumentLocation(node).split(QLatin1Char(
'#'));
206 writer.writeTextElement(
"anchorfile", pieces[0]);
207 writer.writeTextElement(
"anchor", pieces[1]);
208 QString signature = functionNode->signature(Node::SignatureReturnType);
209 signature = signature.mid(signature.indexOf(QChar(
'('))).trimmed();
210 if (functionNode->isConst())
211 signature +=
" const";
212 if (functionNode->isFinal())
213 signature +=
" final";
214 if (functionNode->isOverride())
215 signature +=
" override";
216 if (functionNode->isPureVirtual())
218 writer.writeTextElement(
"arglist", signature);
220 writer.writeEndElement();
222 case Node::Property: {
223 const auto *propertyNode =
static_cast<
const PropertyNode *>(node);
224 writer.writeAttribute(
"type", propertyNode->dataType());
225 writer.writeTextElement(
"name", objName);
226 const QStringList pieces =
227 m_generator->fullDocumentLocation(node).split(QLatin1Char(
'#'));
228 writer.writeTextElement(
"anchorfile", pieces[0]);
229 writer.writeTextElement(
"anchor", pieces[1]);
230 writer.writeTextElement(
"arglist", QString());
232 writer.writeEndElement();
235 const auto *enumNode =
static_cast<
const EnumNode *>(node);
236 writer.writeTextElement(
"name", objName);
237 const QStringList pieces =
238 m_generator->fullDocumentLocation(node).split(QLatin1Char(
'#'));
239 writer.writeTextElement(
"anchorfile", pieces[0]);
240 writer.writeTextElement(
"anchor", pieces[1]);
241 writer.writeEndElement();
243 for (
const auto &item : enumNode->items()) {
244 writer.writeStartElement(
"member");
245 writer.writeAttribute(
"kind",
"enumvalue");
246 writer.writeTextElement(
"name", item.name());
247 writer.writeTextElement(
"anchorfile", pieces[0]);
248 writer.writeTextElement(
"anchor", pieces[1]);
249 writer.writeTextElement(
"arglist", QString());
250 writer.writeEndElement();
253 case Node::TypeAlias:
254 case Node::Typedef: {
255 const auto *typedefNode =
static_cast<
const TypedefNode *>(node);
256 if (typedefNode->associatedEnum())
257 writer.writeAttribute(
"type", typedefNode->associatedEnum()->fullDocumentName());
259 writer.writeAttribute(
"type", QString());
260 writer.writeTextElement(
"name", objName);
261 const QStringList pieces =
262 m_generator->fullDocumentLocation(node).split(QLatin1Char(
'#'));
263 writer.writeTextElement(
"anchorfile", pieces[0]);
264 writer.writeTextElement(
"anchor", pieces[1]);
265 writer.writeTextElement(
"arglist", QString());
267 writer.writeEndElement();
278
279
282 QFile file(fileName);
283 QFileInfo fileInfo(fileName);
287 if (fileInfo.fileName() == fileName || !fileInfo.dir().exists())
288 file.setFileName(m_generator->outputDir() + QLatin1Char(
'/') + fileInfo.fileName());
290 if (!file.open(QFile::WriteOnly | QFile::Text)) {
291 Location().warning(QString(
"Failed to open %1 for writing.").arg(file.fileName()));
296 QXmlStreamWriter writer(&file);
297 writer.setAutoFormatting(
true);
298 writer.writeStartDocument();
299 writer.writeStartElement(
"tagfile");
300 generateTagFileCompounds(writer, m_qdb->primaryTreeRoot());
301 writer.writeEndElement();
302 writer.writeEndDocument();
const NodeList & nonfunctionList()
Returns a const reference to the list of child nodes of this aggregate that are not function nodes.
const NodeList & childNodes() const
Returns a const reference to the child list.
The Location class provides a way to mark a location in a file.
Location()
Constructs an empty location.
static bool nodeNameLessThan(const Node *first, const Node *second)
Returns true if the node n1 is less than node n2.
LinkType
An unsigned char value that probably should be moved out of the Node base class.
This class handles the generation of the QDoc tag files.
Combined button and popup list for selecting options.