summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz Haas <lykurg@gmail.com>2015-02-07 20:53:34 +0100
committerLorenz Haas <lykurg@gmail.com>2015-02-17 13:16:14 +0000
commitb4902e5f1beef4ccde7b2f4711be28295af5d23a (patch)
tree2af910030434d129ae867946e280a85882a83739 /src
parent5a3a940ad3b3984b308b539e7f0456ce11d4d90e (diff)
downloadqt-creator-b4902e5f1beef4ccde7b2f4711be28295af5d23a.tar.gz
CppEditor: Fix Doxygen continuation handling for "//!"
Change-Id: Ib1e3183a85b55a894964f56458512aca1fafc2ea Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/cppeditor/cppdocumentationcommenthelper.cpp7
-rw-r--r--src/plugins/cppeditor/cppdoxygen_test.cpp53
2 files changed, 55 insertions, 5 deletions
diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
index 1bb5959b20..844c33afbc 100644
--- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
+++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp
@@ -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(' '));
diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp
index d5d2afb008..830c67ba97 100644
--- a/src/plugins/cppeditor/cppdoxygen_test.cpp
+++ b/src/plugins/cppeditor/cppdoxygen_test.cpp
@@ -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"