ClangCodeModel: Fix local renamings with clangd

This functionality somehow stayed in the proof-of-concept
stage, working only for free functions.

Fixes: QTCREATORBUG-27249
Change-Id: I840beae66314330ce643e159c596e702a0ec3273
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2022-03-30 17:31:26 +02:00
parent bd8537fc77
commit a1b910724d
2 changed files with 6 additions and 3 deletions

View File

@@ -1989,7 +1989,10 @@ void ClangdClient::findLocalUsages(TextDocument *document, const QTextCursor &cu
const QList<AstNode> astPath = getAstPath(ast, linkPos);
bool isVar = false;
for (auto it = astPath.rbegin(); it != astPath.rend(); ++it) {
if (it->role() == "declaration" && it->kind() == "Function") {
if (it->role() == "declaration"
&& (it->kind() == "Function" || it->kind() == "CXXMethod"
|| it->kind() == "CXXConstructor" || it->kind() == "CXXDestructor"
|| it->kind() == "Lambda")) {
if (!isVar)
break;

View File

@@ -434,8 +434,8 @@ void ClangdTestLocalReferences::test_data()
/* QList<Range>{{40, 7, 3}, {43, 9, 3}} */;
QTest::newRow("instantiated template object") << 52 << 19
<< QList<Range>{{52, 19, 3}, {53, 5, 3}};
QTest::newRow("variable in template") << 62 << 13 << QList<Range>()
/* QList<Range>{{62, 13, 3}, {63, 11, 3}} */;
QTest::newRow("variable in template") << 62 << 13
<< QList<Range>{{62, 13, 3}, {63, 11, 3}};
QTest::newRow("member in template") << 67 << 7 << QList<Range>()
/* QList<Range>{{64, 16, 3}, {67, 7, 3}} */;
QTest::newRow("template type") << 58 << 19 << QList<Range>()