Do not pass Utils::LinkHandler by rvalue ref

There is nothing special about this type that justifies it sticking out
everywhere it appears.

Change-Id: Iccdc95163d477db8a031d0d520f28fea26432a44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2022-06-03 15:17:33 +02:00
parent 0135c47849
commit a167bd9ad2
22 changed files with 54 additions and 56 deletions

View File

@@ -359,10 +359,10 @@ class ClangdClient::FollowSymbolData {
public:
FollowSymbolData(ClangdClient *q, quint64 id, const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget,
const DocumentUri &uri, Utils::LinkHandler &&callback,
const DocumentUri &uri, const Utils::LinkHandler &callback,
bool openInSplit)
: q(q), id(id), cursor(cursor), editorWidget(editorWidget), uri(uri),
callback(std::move(callback)), virtualFuncAssistProvider(q->d),
callback(callback), virtualFuncAssistProvider(q->d),
docRevision(editorWidget ? editorWidget->textDocument()->document()->revision() : -1),
openInSplit(openInSplit) {}
@@ -418,9 +418,9 @@ class SwitchDeclDefData {
public:
SwitchDeclDefData(quint64 id, TextDocument *doc, const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget,
Utils::LinkHandler &&callback)
const Utils::LinkHandler &callback)
: id(id), document(doc), uri(DocumentUri::fromFilePath(doc->filePath())),
cursor(cursor), editorWidget(editorWidget), callback(std::move(callback)) {}
cursor(cursor), editorWidget(editorWidget), callback(callback) {}
Utils::optional<ClangdAstNode> getFunctionNode() const
{
@@ -1726,7 +1726,7 @@ void ClangdClient::Private::finishSearch(const ReferencesData &refData, bool can
void ClangdClient::followSymbol(TextDocument *document,
const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget,
Utils::LinkHandler &&callback,
const Utils::LinkHandler &callback,
bool resolveTarget,
bool openInSplit
)
@@ -1735,7 +1735,7 @@ void ClangdClient::followSymbol(TextDocument *document,
const QTextCursor adjustedCursor = d->adjustedCursor(cursor, document);
if (!resolveTarget) {
d->followSymbolData.reset();
symbolSupport().findLinkAt(document, adjustedCursor, std::move(callback), false);
symbolSupport().findLinkAt(document, adjustedCursor, callback, false);
return;
}
@@ -1743,7 +1743,7 @@ void ClangdClient::followSymbol(TextDocument *document,
<< adjustedCursor.blockNumber() << adjustedCursor.positionInBlock();
d->followSymbolData.emplace(this, ++d->nextJobId, adjustedCursor, editorWidget,
DocumentUri::fromFilePath(document->filePath()),
std::move(callback), openInSplit);
callback, openInSplit);
// Step 1: Follow the symbol via "Go to Definition". At the same time, request the
// AST node corresponding to the cursor position, so we can find out whether
@@ -1777,14 +1777,13 @@ void ClangdClient::followSymbol(TextDocument *document,
void ClangdClient::switchDeclDef(TextDocument *document, const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget,
Utils::LinkHandler &&callback)
const Utils::LinkHandler &callback)
{
QTC_ASSERT(documentOpen(document), openDocument(document));
qCDebug(clangdLog) << "switch decl/dev requested" << document->filePath()
<< cursor.blockNumber() << cursor.positionInBlock();
d->switchDeclDefData.emplace(++d->nextJobId, document, cursor, editorWidget,
std::move(callback));
d->switchDeclDefData.emplace(++d->nextJobId, document, cursor, editorWidget, callback);
// Retrieve AST and document symbols.
const auto astHandler = [this, id = d->switchDeclDefData->id](const ClangdAstNode &ast,

View File

@@ -70,14 +70,14 @@ public:
void followSymbol(TextEditor::TextDocument *document,
const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget,
Utils::LinkHandler &&callback,
const Utils::LinkHandler &callback,
bool resolveTarget,
bool openInSplit);
void switchDeclDef(TextEditor::TextDocument *document,
const QTextCursor &cursor,
CppEditor::CppEditorWidget *editorWidget,
Utils::LinkHandler &&callback);
const Utils::LinkHandler &callback);
void switchHeaderSource(const Utils::FilePath &filePath, bool inNextSplit);
void findLocalUsages(TextEditor::TextDocument *document, const QTextCursor &cursor,

View File

@@ -191,32 +191,31 @@ CppEditor::CppCompletionAssistProvider *ClangModelManagerSupport::functionHintAs
}
void ClangModelManagerSupport::followSymbol(const CppEditor::CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback, bool resolveTarget,
const Utils::LinkHandler &processLinkCallback, bool resolveTarget,
bool inNextSplit)
{
if (ClangdClient * const client = clientForFile(data.filePath());
client && client->isFullyIndexed()) {
client->followSymbol(data.textDocument(), data.cursor(), data.editorWidget(),
std::move(processLinkCallback), resolveTarget, inNextSplit);
processLinkCallback, resolveTarget, inNextSplit);
return;
}
CppModelManager::followSymbol(data, std::move(processLinkCallback), resolveTarget, inNextSplit,
CppModelManager::followSymbol(data, processLinkCallback, resolveTarget, inNextSplit,
CppModelManager::Backend::Builtin);
}
void ClangModelManagerSupport::switchDeclDef(const CppEditor::CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback)
const Utils::LinkHandler &processLinkCallback)
{
if (ClangdClient * const client = clientForFile(data.filePath());
client && client->isFullyIndexed()) {
client->switchDeclDef(data.textDocument(), data.cursor(), data.editorWidget(),
std::move(processLinkCallback));
processLinkCallback);
return;
}
CppModelManager::switchDeclDef(data, std::move(processLinkCallback),
CppModelManager::Backend::Builtin);
CppModelManager::switchDeclDef(data, processLinkCallback, CppModelManager::Backend::Builtin);
}
void ClangModelManagerSupport::startLocalRenaming(const CppEditor::CursorInEditor &data,

View File

@@ -80,10 +80,10 @@ signals:
private:
void followSymbol(const CppEditor::CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback, bool resolveTarget,
const Utils::LinkHandler &processLinkCallback, bool resolveTarget,
bool inNextSplit) override;
void switchDeclDef(const CppEditor::CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback) override;
const Utils::LinkHandler &processLinkCallback) override;
void startLocalRenaming(const CppEditor::CursorInEditor &data,
const CppEditor::ProjectPart *projectPart,
CppEditor::RenameCallback &&renameSymbolsCallback) override;

View File

@@ -108,7 +108,7 @@ public:
private:
bool save(const QString &fileName = QString());
void findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget = true,
bool inNextSplit = false) override;
void contextMenuEvent(QContextMenuEvent *e) override;
@@ -152,7 +152,7 @@ static QString unescape(const QString &s)
}
void CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool/* resolveTarget*/,
bool /*inNextSplit*/)
{

View File

@@ -140,20 +140,20 @@ std::unique_ptr<AbstractOverviewModel> BuiltinModelManagerSupport::createOvervie
}
void BuiltinModelManagerSupport::followSymbol(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget, bool inNextSplit)
{
SymbolFinder finder;
m_followSymbol->findLink(data, std::move(processLinkCallback),
m_followSymbol->findLink(data, processLinkCallback,
resolveTarget, CppModelManager::instance()->snapshot(),
data.editorWidget()->semanticInfo().doc, &finder, inNextSplit);
}
void BuiltinModelManagerSupport::switchDeclDef(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback)
const Utils::LinkHandler &processLinkCallback)
{
SymbolFinder finder;
m_followSymbol->switchDeclDef(data, std::move(processLinkCallback),
m_followSymbol->switchDeclDef(data, processLinkCallback,
CppModelManager::instance()->snapshot(), data.editorWidget()->semanticInfo().doc,
&finder);
}

View File

@@ -51,10 +51,10 @@ public:
FollowSymbolUnderCursor &followSymbolInterface() { return *m_followSymbol; }
private:
void followSymbol(const CursorInEditor &data, Utils::LinkHandler &&processLinkCallback,
void followSymbol(const CursorInEditor &data, const Utils::LinkHandler &processLinkCallback,
bool resolveTarget, bool inNextSplit) override;
void switchDeclDef(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback) override;
const Utils::LinkHandler &processLinkCallback) override;
void startLocalRenaming(const CursorInEditor &data,
const ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) override;

View File

@@ -889,7 +889,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
}
void CppEditorWidget::findLinkAt(const QTextCursor &cursor,
LinkHandler &&processLinkCallback,
const LinkHandler &processLinkCallback,
bool resolveTarget,
bool inNextSplit)
{
@@ -903,7 +903,7 @@ void CppEditorWidget::findLinkAt(const QTextCursor &cursor,
QTextCursor c(cursor);
c.select(QTextCursor::WordUnderCursor);
LinkHandler callbackWrapper = [start = c.selectionStart(), end = c.selectionEnd(),
doc = QPointer(cursor.document()), callback = std::move(processLinkCallback),
doc = QPointer(cursor.document()), callback = processLinkCallback,
filePath](const Link &link) {
const int linkPos = doc ? Text::positionInText(doc, link.targetLine, link.targetColumn + 1)
: -1;
@@ -927,7 +927,7 @@ void CppEditorWidget::findLinkAt(const QTextCursor &cursor,
};
CppModelManager::followSymbol(
CursorInEditor{cursor, filePath, this, textDocument()},
std::move(callbackWrapper),
callbackWrapper,
resolveTarget,
inNextSplit);
}

View File

@@ -116,7 +116,7 @@ protected:
bool handleStringSplitting(QKeyEvent *e) const;
void findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget = true,
bool inNextSplit = false) override;

View File

@@ -492,7 +492,7 @@ static int skipMatchingParentheses(const Tokens &tokens, int idx, int initialDep
void FollowSymbolUnderCursor::findLink(
const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget,
const Snapshot &theSnapshot,
const Document::Ptr &documentFromSemanticInfo,
@@ -803,7 +803,7 @@ void FollowSymbolUnderCursor::findLink(
void FollowSymbolUnderCursor::switchDeclDef(
const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
SymbolFinder *symbolFinder)

View File

@@ -42,7 +42,7 @@ public:
FollowSymbolUnderCursor();
void findLink(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget,
const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
@@ -50,7 +50,7 @@ public:
bool inNextSplit);
void switchDeclDef(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
const CPlusPlus::Snapshot &snapshot,
const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
SymbolFinder *symbolFinder);

View File

@@ -1631,18 +1631,18 @@ TextEditor::BaseHoverHandler *CppModelManager::createHoverHandler() const
}
void CppModelManager::followSymbol(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget, bool inNextSplit, Backend backend)
{
instance()->modelManagerSupport(backend)->followSymbol(data, std::move(processLinkCallback),
instance()->modelManagerSupport(backend)->followSymbol(data, processLinkCallback,
resolveTarget, inNextSplit);
}
void CppModelManager::switchDeclDef(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
Backend backend)
{
instance()->modelManagerSupport(backend)->switchDeclDef(data, std::move(processLinkCallback));
instance()->modelManagerSupport(backend)->switchDeclDef(data, processLinkCallback);
}
Core::ILocatorFilter *CppModelManager::createAuxiliaryCurrentDocumentFilter()

View File

@@ -170,10 +170,10 @@ public:
enum class Backend { Builtin, Best };
static void followSymbol(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget, bool inNextSplit, Backend backend = Backend::Best);
static void switchDeclDef(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
Backend backend = Backend::Best);
static void startLocalRenaming(const CursorInEditor &data, const ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback,

View File

@@ -65,10 +65,10 @@ public:
virtual bool usesClangd(const TextEditor::TextDocument *) const { return false; }
virtual void followSymbol(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget, bool inNextSplit) = 0;
virtual void switchDeclDef(const CursorInEditor &data,
Utils::LinkHandler &&processLinkCallback) = 0;
const Utils::LinkHandler &processLinkCallback) = 0;
virtual void startLocalRenaming(const CursorInEditor &data,
const ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) = 0;

View File

@@ -456,7 +456,7 @@ void LanguageClientManager::editorOpened(Core::IEditor *editor)
if (TextEditorWidget *widget = textEditor->editorWidget()) {
connect(widget, &TextEditorWidget::requestLinkAt, this,
[document = textEditor->textDocument()]
(const QTextCursor &cursor, Utils::LinkHandler &callback, bool resolveTarget) {
(const QTextCursor &cursor, const Utils::LinkHandler &callback, bool resolveTarget) {
if (auto client = clientForDocument(document))
client->symbolSupport().findLinkAt(document, cursor, callback, resolveTarget);
});

View File

@@ -60,7 +60,7 @@ NimTextEditorWidget::NimTextEditorWidget(QWidget *parent)
setLanguageSettingsId(Nim::Constants::C_NIMLANGUAGE_ID);
}
void NimTextEditorWidget::findLinkAt(const QTextCursor &c, Utils::LinkHandler &&processLinkCallback, bool /*resolveTarget*/, bool /*inNextSplit*/)
void NimTextEditorWidget::findLinkAt(const QTextCursor &c, const Utils::LinkHandler &processLinkCallback, bool /*resolveTarget*/, bool /*inNextSplit*/)
{
const Utils::FilePath &path = textDocument()->filePath();
@@ -90,7 +90,7 @@ void NimTextEditorWidget::findLinkAt(const QTextCursor &c, Utils::LinkHandler &&
m_callback(Utils::Link());
m_dirtyFile = std::move(dirtyFile);
m_callback = std::move(processLinkCallback);
m_callback = processLinkCallback;
m_request = std::move(request);
QObject::connect(m_request.get(), &NimSuggestClientRequest::finished, this, &NimTextEditorWidget::onFindLinkFinished);

View File

@@ -36,7 +36,7 @@ public:
NimTextEditorWidget(QWidget* parent = nullptr);
protected:
void findLinkAt(const QTextCursor &, Utils::LinkHandler &&processLinkCallback, bool resolveTarget, bool inNextSplit);
void findLinkAt(const QTextCursor &, const Utils::LinkHandler &processLinkCallback, bool resolveTarget, bool inNextSplit);
private:
void onFindLinkFinished();

View File

@@ -62,7 +62,7 @@ class ProFileEditorWidget : public TextEditorWidget
{
private:
void findLinkAt(const QTextCursor &,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget = true,
bool inNextSplit = false) override;
void contextMenuEvent(QContextMenuEvent *) override;
@@ -125,7 +125,7 @@ QString ProFileEditorWidget::checkForPrfFile(const QString &baseName) const
}
void ProFileEditorWidget::findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&processLinkCallback,
const LinkHandler &processLinkCallback,
bool /*resolveTarget*/,
bool /*inNextSplit*/)
{

View File

@@ -753,7 +753,7 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const
}
void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool /*resolveTarget*/,
bool /*inNextSplit*/)
{

View File

@@ -102,7 +102,7 @@ protected:
void applyFontSettings() override;
void createToolBar();
void findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget = true,
bool inNextSplit = false) override;
QString foldReplacementText(const QTextBlock &block) const override;

View File

@@ -6081,7 +6081,7 @@ void TextEditorWidget::zoomReset()
}
void TextEditorWidget::findLinkAt(const QTextCursor &cursor,
Utils::LinkHandler &&callback,
const Utils::LinkHandler &callback,
bool resolveTarget,
bool inNextSplit)
{

View File

@@ -496,7 +496,7 @@ signals:
void requestBlockUpdate(const QTextBlock &);
void requestLinkAt(const QTextCursor &cursor, Utils::LinkHandler &callback,
void requestLinkAt(const QTextCursor &cursor, const Utils::LinkHandler &callback,
bool resolveTarget, bool inNextSplit);
void requestUsages(const QTextCursor &cursor);
void requestRename(const QTextCursor &cursor);
@@ -582,7 +582,7 @@ protected:
(it isn't until the link is used).
*/
virtual void findLinkAt(const QTextCursor &,
Utils::LinkHandler &&processLinkCallback,
const Utils::LinkHandler &processLinkCallback,
bool resolveTarget = true,
bool inNextSplit = false);