forked from qt-creator/qt-creator
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:
@@ -757,8 +757,23 @@ void Snapshot::insert(Document::Ptr doc)
|
||||
}
|
||||
}
|
||||
|
||||
static QList<Macro> macrosDefinedUntilLine(const QList<Macro> ¯os, int line)
|
||||
{
|
||||
QList<Macro> filtered;
|
||||
|
||||
foreach (const Macro ¯o, 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user