forked from qt-creator/qt-creator
CppEditor: Fix Doxygen continuation handling for "//!"
Change-Id: Ib1e3183a85b55a894964f56458512aca1fafc2ea Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -170,15 +170,12 @@ bool handleDoxygenCppStyleContinuation(QTextCursor &cursor)
|
||||
// If the line does not start with the comment we don't
|
||||
// consider it as a continuation. Handles situations like:
|
||||
// void d(); ///<enter>
|
||||
if (!(text.trimmed().startsWith(QLatin1String("///"))
|
||||
|| text.startsWith(QLatin1String("//!")))) {
|
||||
const QStringRef commentMarker = text.midRef(offset, 3);
|
||||
if (commentMarker != QLatin1String("///") && commentMarker != QLatin1String("//!"))
|
||||
return false;
|
||||
}
|
||||
|
||||
QString newLine(QLatin1Char('\n'));
|
||||
newLine.append(QString(offset, QLatin1Char(' '))); // indent correctly
|
||||
|
||||
const QString commentMarker = text.mid(offset, 3);
|
||||
newLine.append(commentMarker);
|
||||
newLine.append(QLatin1Char(' '));
|
||||
|
||||
|
@@ -162,6 +162,21 @@ void DoxygenTest::testBasic_data()
|
||||
"int a;\n"
|
||||
);
|
||||
|
||||
QTest::newRow("cpp_styleB_continuation") << _(
|
||||
"bool preventFolding;\n"
|
||||
"//!\n"
|
||||
"//! \\brief a|\n"
|
||||
"//!\n"
|
||||
"int a;\n"
|
||||
) << _(
|
||||
"bool preventFolding;\n"
|
||||
"//!\n"
|
||||
"//! \\brief a\n"
|
||||
"//! \n"
|
||||
"//!\n"
|
||||
"int a;\n"
|
||||
);
|
||||
|
||||
/// test cpp style doxygen comment when inside a indented scope
|
||||
QTest::newRow("cpp_styleA_indented") << _(
|
||||
" bool preventFolding;\n"
|
||||
@@ -175,6 +190,18 @@ void DoxygenTest::testBasic_data()
|
||||
" int a;\n"
|
||||
);
|
||||
|
||||
QTest::newRow("cpp_styleB_indented") << _(
|
||||
" bool preventFolding;\n"
|
||||
" //!|\n"
|
||||
" int a;\n"
|
||||
) << _(
|
||||
" bool preventFolding;\n"
|
||||
" //!\n"
|
||||
" //! \\brief a\n"
|
||||
" //!\n"
|
||||
" int a;\n"
|
||||
);
|
||||
|
||||
/// test cpp style doxygen comment continuation when inside a indented scope
|
||||
QTest::newRow("cpp_styleA_indented_continuation") << _(
|
||||
" bool preventFolding;\n"
|
||||
@@ -191,6 +218,21 @@ void DoxygenTest::testBasic_data()
|
||||
" int a;\n"
|
||||
);
|
||||
|
||||
QTest::newRow("cpp_styleB_indented_continuation") << _(
|
||||
" bool preventFolding;\n"
|
||||
" //!\n"
|
||||
" //! \\brief a|\n"
|
||||
" //!\n"
|
||||
" int a;\n"
|
||||
) << _(
|
||||
" bool preventFolding;\n"
|
||||
" //!\n"
|
||||
" //! \\brief a\n"
|
||||
" //! \n"
|
||||
" //!\n"
|
||||
" int a;\n"
|
||||
);
|
||||
|
||||
QTest::newRow("cpp_styleA_corner_case") << _(
|
||||
"bool preventFolding;\n"
|
||||
"///\n"
|
||||
@@ -202,6 +244,17 @@ void DoxygenTest::testBasic_data()
|
||||
"\n"
|
||||
);
|
||||
|
||||
QTest::newRow("cpp_styleB_corner_case") << _(
|
||||
"bool preventFolding;\n"
|
||||
"//!\n"
|
||||
"void d(); //!|\n"
|
||||
) << _(
|
||||
"bool preventFolding;\n"
|
||||
"//!\n"
|
||||
"void d(); //!\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
QTest::newRow("noContinuationForExpressionAndComment1") << _(
|
||||
"bool preventFolding;\n"
|
||||
"*foo //|\n"
|
||||
|
Reference in New Issue
Block a user