forked from qt-creator/qt-creator
C++: Consider '^//[/!][^\n]*' as doxygen comment
Now everything following '///' or '//!' is a doxygen comment.
This simplification fixes also the bug ('\n' was considered as part of
the doxygen comment and led to strange highlighting).
Task-number: QTCREATORBUG-8921
Change-Id: I6dae3b80ec11400f2f623897257782a80860a7f3
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
6
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
6
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
@@ -368,11 +368,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
|
||||
if (_yychar == '/' || _yychar == '!') {
|
||||
yyinp();
|
||||
|
||||
if (_yychar == '<' || _yychar != '/') {
|
||||
yyinp();
|
||||
doxy = true;
|
||||
}
|
||||
doxy = true;
|
||||
}
|
||||
|
||||
while (_yychar && _yychar != '\n')
|
||||
|
||||
@@ -65,7 +65,7 @@ void tst_SimpleLexer::doxygen_comments()
|
||||
Token expectedToken; // Create a Token in order to spell the token kind
|
||||
expectedToken.f.kind = expectedTokenKind;
|
||||
// qDebug("Comparing (i=%d): \"%s\" \"%s\"", i, token.spell(), expectedToken.spell());
|
||||
QCOMPARE(token.spell(), expectedToken.spell());
|
||||
QCOMPARE(token.kind(), expectedTokenKind);
|
||||
}
|
||||
QVERIFY2(i == expectedTokenKindList.size(), "Less tokens than expected.");
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void tst_SimpleLexer::doxygen_comments_data()
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "//// comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_COMMENT;
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "/// comment";
|
||||
@@ -105,6 +105,13 @@ void tst_SimpleLexer::doxygen_comments_data()
|
||||
source = "///\n";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "///\n"
|
||||
"int i;";
|
||||
expectedTokenKindList = QList<unsigned>()
|
||||
<< T_CPP_DOXY_COMMENT
|
||||
<< T_INT << T_IDENTIFIER << T_SEMICOLON;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_SimpleLexer)
|
||||
|
||||
Reference in New Issue
Block a user