ClangCodeModel: Fix detection of #ifdef'ed out blocks with clangd

We were erroneously merging adjacent disabled blocks.

Change-Id: I9f8f588c0362d488a24c044910474815b94efd59
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2022-02-10 10:15:54 +01:00
parent 3bdab2f05e
commit 14ee4654c1
6 changed files with 37 additions and 1 deletions

View File

@@ -675,6 +675,8 @@ void ClangdTestHighlighting::initTestCase()
{
ClangdTest::initTestCase();
connect(document("highlighting.cpp"), &TextDocument::ifdefedOutBlocksChanged, this,
[this](const QList<BlockRange> &ranges) { m_ifdefedOutBlocks = ranges; });
QTimer timer;
timer.setSingleShot(true);
QEventLoop loop;
@@ -1380,6 +1382,17 @@ void ClangdTestHighlighting::test()
QCOMPARE(result.kind, expectedKind);
}
void ClangdTestHighlighting::testIfdefedOutBlocks()
{
QCOMPARE(m_ifdefedOutBlocks.size(), 3);
QCOMPARE(m_ifdefedOutBlocks.at(0).first(), 12033);
QCOMPARE(m_ifdefedOutBlocks.at(0).last(), 12050);
QCOMPARE(m_ifdefedOutBlocks.at(1).first(), 13351);
QCOMPARE(m_ifdefedOutBlocks.at(1).last(), 13364);
QCOMPARE(m_ifdefedOutBlocks.at(2).first(), 13390);
QCOMPARE(m_ifdefedOutBlocks.at(2).last(), 13402);
}
class Manipulator : public TextDocumentManipulatorInterface
{