ClangCodeModel: Do not use clangd for completing #ifdef & friends

Annoyingly, LLVM does not complete preprocessor directives in disabled
code, so that we would not offer e.g. "#endif" after "#if 0" (but we
would offer it after "#if 1").
Fixing it would require messing with the clang libs (rather than just
clangd), so let's just keep using our existing code, which seems to work
fine.

Change-Id: I9dabf9a2a8f3a2f68e88a11b62c3df3b5e64a55c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-09-28 15:10:47 +02:00
parent 94a59f15c6
commit 29c0512416
6 changed files with 71 additions and 29 deletions

View File

@@ -1462,20 +1462,19 @@ void ClangdTestCompletion::testCompletePreprocessorKeywords()
ProposalModelPtr proposal;
getProposal("preprocessorKeywordsCompletion.cpp", proposal);
QVERIFY(proposal);
QVERIFY(hasItem(proposal, " ifdef macro"));
QVERIFY(hasItem(proposal, "ifdef"));
QVERIFY(!hasSnippet(proposal, "class "));
proposal.clear();
getProposal("preprocessorKeywordsCompletion2.cpp", proposal);
QVERIFY(proposal);
QVERIFY(hasItem(proposal, " endif"));
QVERIFY(hasItem(proposal, "endif"));
QVERIFY(!hasSnippet(proposal, "class "));
proposal.clear();
getProposal("preprocessorKeywordsCompletion3.cpp", proposal);
QVERIFY(proposal);
QEXPECT_FAIL("", "TODO: Fix in clangd", Continue);
QVERIFY(hasItem(proposal, " endif"));
QVERIFY(hasItem(proposal, "endif"));
QVERIFY(!hasSnippet(proposal, "class "));
}