CppEditor: Fix doxygen comment magic before templates

Fixes: QTCREATORBUG-9620
Change-Id: I65a434d72adbe72d449783a917444c2ee216fc5e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-10-27 17:11:28 +02:00
parent d8d4739bc4
commit a437539096
2 changed files with 17 additions and 0 deletions

View File

@@ -326,6 +326,20 @@ void DoxygenTest::testBasic_data()
"};\n" "};\n"
); );
QTest::newRow("classTemplate") << _(
"bool preventFolding;\n"
"/**|\n"
"template<typename T> class C {\n"
"};\n"
) << _(
"bool preventFolding;\n"
"/**\n"
" * @brief The C class\n"
" */\n"
"template<typename T> class C {\n"
"};\n"
);
QTest::newRow("continuation_after_text_in_first_line") << _( QTest::newRow("continuation_after_text_in_first_line") << _(
"bool preventFolding;\n" "bool preventFolding;\n"
"/*! leading comment|\n" "/*! leading comment|\n"

View File

@@ -141,6 +141,9 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl) QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
{ {
if (const TemplateDeclarationAST * const templDecl = decl->asTemplateDeclaration())
decl = templDecl->declaration;
SpecifierAST *spec = nullptr; SpecifierAST *spec = nullptr;
DeclaratorAST *decltr = nullptr; DeclaratorAST *decltr = nullptr;
if (SimpleDeclarationAST *simpleDecl = decl->asSimpleDeclaration()) { if (SimpleDeclarationAST *simpleDecl = decl->asSimpleDeclaration()) {