CppEditor: Skip over access specifier when inserting a doxygen comment

That is, also do function-specific magic on typing "/**<return>" in front
of a function if there is an access specifier such as "public:" in
between.
This use case is rather weird, but it's also pretty easy to support and
it should not hurt anyone.
Note that depending on the indentation of the access specifier, the
indentation of the inserted comment will probably not be what the user
expects, but this is not easily fixable.

Fixes: QTCREATORBUG-20311
Change-Id: Ie32a71eede91ef64a19381c8e379a183a91fd27d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-08-20 17:43:48 +02:00
parent 2a05186194
commit f852cfe284
2 changed files with 15 additions and 1 deletions

View File

@@ -295,6 +295,20 @@ void DoxygenTest::testBasic_data()
" */\n"
"API void f();\n"
);
QTest::newRow("withAccessSpecifierBeforeFunction") << _(
"class C {\n"
" /**|\n"
" public: void f();\n"
"};\n"
) << _(
"class C {\n"
" /**\n"
" * @brief f\n"
" */\n"
" public: void f();\n"
"};\n"
);
}
void DoxygenTest::testBasic()

View File

@@ -116,7 +116,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
declCandidate.replace(attribute, "");
declCandidate.replace("Q_INVOKABLE", "");
declCandidate.remove(QRegularExpression(R"(\s*(public|protected|private)\s*:\s*)"));
declCandidate.replace(QChar::ParagraphSeparator, QLatin1Char('\n'));
// Let's append a closing brace in the case we got content like 'class MyType {'