ClangCodeModel: Adjust cursor for following destructor symbols

... with clangd. More specifically, for the case where we switch between
declaration and definition of a destructor. Since clangd expects the
cursor before the "~" character, we move it there.

Fixes: QTCREATORBUG-26809
Change-Id: I8ea6a060bea3545c963cb8ebbe2d3ae3a18da2d5
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2022-01-26 12:40:12 +01:00
parent dd527a3890
commit abe09bfd76
2 changed files with 11 additions and 4 deletions

View File

@@ -2458,6 +2458,13 @@ QTextCursor ClangdClient::Private::adjustedCursor(const QTextCursor &cursor,
} }
return cursor; return cursor;
} }
// ~My|Class
if (const DestructorNameAST * const destrAst = (*it)->asDestructorName()) {
QTextCursor c = cursor;
c.setPosition(posForToken(destrAst->tilde_token));
return c;
}
} }
return cursor; return cursor;
} }

View File

@@ -263,10 +263,6 @@ F2TestCase::F2TestCase(CppEditorAction action,
QSKIP("fuzzy matching is not supposed to work with clangd"); // TODO: Implement fallback as we do with libclang QSKIP("fuzzy matching is not supposed to work with clangd"); // TODO: Implement fallback as we do with libclang
if (tag == "baseClassFunctionIntroducedByUsingDeclaration") if (tag == "baseClassFunctionIntroducedByUsingDeclaration")
QSKIP("clangd points to the using declaration"); QSKIP("clangd points to the using declaration");
if (tag == "classDestructor" || tag == "fromDestructorDefinitionSymbol"
|| tag == "fromDestructorBody") {
QSKIP("clangd wants the cursor before the ~ character");
}
if (curTestName == "testFollowClassOperatorInOp") if (curTestName == "testFollowClassOperatorInOp")
QSKIP("clangd goes to operator name first"); QSKIP("clangd goes to operator name first");
} }
@@ -438,6 +434,10 @@ F2TestCase::F2TestCase(CppEditorAction action,
} else { } else {
currentTextEditor->convertPosition(targetTestFile->m_targetCursorPosition, currentTextEditor->convertPosition(targetTestFile->m_targetCursorPosition,
&expectedLine, &expectedColumn); &expectedLine, &expectedColumn);
if (useClangd && (tag == "classDestructor" || tag == "fromDestructorDefinitionSymbol"
|| tag == "fromDestructorBody")) {
--expectedColumn; // clangd goes before the ~, built-in code model after
}
} }
// qDebug() << "Expected line:" << expectedLine; // qDebug() << "Expected line:" << expectedLine;
// qDebug() << "Expected column:" << expectedColumn; // qDebug() << "Expected column:" << expectedColumn;