CppEditor: Generate doxygen comments for functions with macros

...at least for object-like macros. This handles the common case where a
macro before the function signature annotates the DLL import/export.

Task-number: QTCREATORBUG-15819
Change-Id: I79f22508188019402fb7345222408aaf90106f20
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2016-03-04 12:43:06 +01:00
parent f99f5dcdc6
commit 2b2ba298f3
12 changed files with 131 additions and 19 deletions

View File

@@ -757,8 +757,23 @@ void Snapshot::insert(Document::Ptr doc)
}
}
static QList<Macro> macrosDefinedUntilLine(const QList<Macro> &macros, int line)
{
QList<Macro> filtered;
foreach (const Macro &macro, macros) {
if (macro.line() <= unsigned(line))
filtered.append(macro);
else
break;
}
return filtered;
}
Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source,
const Utils::FileName &fileName) const
const Utils::FileName &fileName,
int withDefinedMacrosFromDocumentUntilLine) const
{
Document::Ptr newDoc = Document::create(fileName.toString());
if (Document::Ptr thisDocument = document(fileName)) {
@@ -768,10 +783,15 @@ Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source,
newDoc->_resolvedIncludes = thisDocument->_resolvedIncludes;
newDoc->_unresolvedIncludes = thisDocument->_unresolvedIncludes;
newDoc->setLanguageFeatures(thisDocument->languageFeatures());
if (withDefinedMacrosFromDocumentUntilLine != -1) {
newDoc->_definedMacros = macrosDefinedUntilLine(thisDocument->_definedMacros,
withDefinedMacrosFromDocumentUntilLine);
}
}
FastPreprocessor pp(*this);
const QByteArray preprocessedCode = pp.run(newDoc, source);
const bool mergeDefinedMacrosOfDocument = !newDoc->_definedMacros.isEmpty();
const QByteArray preprocessedCode = pp.run(newDoc, source, mergeDefinedMacrosOfDocument);
newDoc->setUtf8Source(preprocessedCode);
return newDoc;
}