From a437539096e8d5e4a49101f5d05774667089dc0d Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 27 Oct 2021 17:11:28 +0200 Subject: [PATCH] CppEditor: Fix doxygen comment magic before templates Fixes: QTCREATORBUG-9620 Change-Id: I65a434d72adbe72d449783a917444c2ee216fc5e Reviewed-by: Christian Stenger --- src/plugins/cppeditor/cppdoxygen_test.cpp | 14 ++++++++++++++ src/plugins/cppeditor/doxygengenerator.cpp | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp index c9c40a8dd80..7e2781a6ce4 100644 --- a/src/plugins/cppeditor/cppdoxygen_test.cpp +++ b/src/plugins/cppeditor/cppdoxygen_test.cpp @@ -326,6 +326,20 @@ void DoxygenTest::testBasic_data() "};\n" ); + QTest::newRow("classTemplate") << _( + "bool preventFolding;\n" + "/**|\n" + "template class C {\n" + "};\n" + ) << _( + "bool preventFolding;\n" + "/**\n" + " * @brief The C class\n" + " */\n" + "template class C {\n" + "};\n" + ); + QTest::newRow("continuation_after_text_in_first_line") << _( "bool preventFolding;\n" "/*! leading comment|\n" diff --git a/src/plugins/cppeditor/doxygengenerator.cpp b/src/plugins/cppeditor/doxygengenerator.cpp index aba3655b811..9ab9e109eb6 100644 --- a/src/plugins/cppeditor/doxygengenerator.cpp +++ b/src/plugins/cppeditor/doxygengenerator.cpp @@ -141,6 +141,9 @@ QString DoxygenGenerator::generate(QTextCursor cursor, QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl) { + if (const TemplateDeclarationAST * const templDecl = decl->asTemplateDeclaration()) + decl = templDecl->declaration; + SpecifierAST *spec = nullptr; DeclaratorAST *decltr = nullptr; if (SimpleDeclarationAST *simpleDecl = decl->asSimpleDeclaration()) {