forked from qt-creator/qt-creator
C++: Fix highlighting of doxygen's "///"
The color scheme changed for "///\n" lines: "///\n" - "Doxygen Comment" (was "Comment") "/// hello\n" - "Doxygen Comment" (as before) "////...\n" - "Comment" (as before) Change-Id: I6bdaf471760bb05547385fd4821eded6cefed4d7 Reviewed-by: Knut Petter Svendsen <knutpett@pvv.org> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -12,4 +12,5 @@ SUBDIRS = \
|
||||
simplifytypes \
|
||||
misc \
|
||||
cxx11 \
|
||||
checksymbols
|
||||
checksymbols \
|
||||
lexer
|
||||
|
||||
4
tests/auto/cplusplus/lexer/lexer.pro
Normal file
4
tests/auto/cplusplus/lexer/lexer.pro
Normal file
@@ -0,0 +1,4 @@
|
||||
include(../../qttest.pri)
|
||||
include(../shared/shared.pri)
|
||||
SOURCES += tst_lexer.cpp
|
||||
|
||||
109
tests/auto/cplusplus/lexer/tst_lexer.cpp
Normal file
109
tests/auto/cplusplus/lexer/tst_lexer.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtTest>
|
||||
#include <QDebug>
|
||||
|
||||
#include <Token.h>
|
||||
#include <SimpleLexer.h>
|
||||
|
||||
//TESTED_COMPONENT=src/libs/cplusplus
|
||||
using namespace CPlusPlus;
|
||||
|
||||
class tst_SimpleLexer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void doxygen_comments();
|
||||
void doxygen_comments_data();
|
||||
};
|
||||
|
||||
void tst_SimpleLexer::doxygen_comments()
|
||||
{
|
||||
QFETCH(QByteArray, source);
|
||||
QFETCH(QList<unsigned>, expectedTokenKindList);
|
||||
|
||||
SimpleLexer lexer;
|
||||
const QList<Token> tokenList = lexer(source);
|
||||
|
||||
int i = 0;
|
||||
for (; i < tokenList.size(); ++i) {
|
||||
QVERIFY2(i < expectedTokenKindList.size(), "More tokens than expected.");
|
||||
|
||||
// Compare spelled tokens to have it more readable
|
||||
const Token token = tokenList.at(i);
|
||||
const unsigned expectedTokenKind = expectedTokenKindList.at(i);
|
||||
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());
|
||||
}
|
||||
QVERIFY2(i == expectedTokenKindList.size(), "Less tokens than expected.");
|
||||
}
|
||||
|
||||
void tst_SimpleLexer::doxygen_comments_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
QTest::addColumn<QList<unsigned> >("expectedTokenKindList");
|
||||
|
||||
QByteArray source;
|
||||
QList<unsigned> expectedTokenKindList;
|
||||
|
||||
source = "// comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "//// comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "/// comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "///< comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "//! comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "//!< comment";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
|
||||
source = "///\n";
|
||||
expectedTokenKindList = QList<unsigned>() << T_CPP_DOXY_COMMENT;
|
||||
QTest::newRow(source) << source << expectedTokenKindList;
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_SimpleLexer)
|
||||
#include "tst_lexer.moc"
|
||||
Reference in New Issue
Block a user