forked from qt-creator/qt-creator
CppEditor: Do not assume an opening brace starts a block
... when generating doxygen comments. Otherwise, we will not properly parse declarations such as void f(int i = {}); or int m_member{}; Fixes: QTCREATORBUG-29198 Change-Id: I744041d2cd5438e4b64161bba04a088a8910024b Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -61,7 +61,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
|
|||||||
const QString &text = block.text();
|
const QString &text = block.text();
|
||||||
const Tokens &tks = lexer(text);
|
const Tokens &tks = lexer(text);
|
||||||
for (const Token &tk : tks) {
|
for (const Token &tk : tks) {
|
||||||
if (tk.is(T_SEMICOLON) || tk.is(T_LBRACE)) {
|
if (tk.is(T_SEMICOLON)) {
|
||||||
// No need to continue beyond this, we might already have something meaningful.
|
// No need to continue beyond this, we might already have something meaningful.
|
||||||
cursor.setPosition(block.position() + tk.utf16charsEnd(), QTextCursor::KeepAnchor);
|
cursor.setPosition(block.position() + tk.utf16charsEnd(), QTextCursor::KeepAnchor);
|
||||||
break;
|
break;
|
||||||
@@ -74,6 +74,11 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
|
|||||||
block = block.next();
|
block = block.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For the edge case of no semicolons at all, which can e.g. happen if the file
|
||||||
|
// consists only of empty function definitions.
|
||||||
|
if (!cursor.hasSelection())
|
||||||
|
cursor.setPosition(cursor.document()->characterCount() - 1, QTextCursor::KeepAnchor);
|
||||||
|
|
||||||
if (!cursor.hasSelection())
|
if (!cursor.hasSelection())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user