2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-05-06 10:26:31 +02:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-02-23 13:51:41 +01:00
|
|
|
#include "languageclient_global.h"
|
|
|
|
|
|
2021-04-29 15:22:34 +02:00
|
|
|
#include <coreplugin/find/searchresultitem.h>
|
2020-05-06 10:26:31 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
|
|
|
|
|
|
|
|
|
#include <languageserverprotocol/languagefeatures.h>
|
|
|
|
|
|
2020-05-11 08:41:57 +02:00
|
|
|
namespace Core {
|
|
|
|
|
class SearchResult;
|
|
|
|
|
class SearchResultItem;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 15:22:34 +02:00
|
|
|
namespace LanguageServerProtocol { class MessageId; }
|
|
|
|
|
|
2020-05-06 10:26:31 +02:00
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
|
|
2021-02-23 13:51:41 +01:00
|
|
|
class LANGUAGECLIENT_EXPORT SymbolSupport
|
2020-05-06 10:26:31 +02:00
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(SymbolSupport)
|
|
|
|
|
public:
|
|
|
|
|
explicit SymbolSupport(Client *client);
|
|
|
|
|
|
|
|
|
|
void findLinkAt(TextEditor::TextDocument *document,
|
|
|
|
|
const QTextCursor &cursor,
|
2022-06-03 14:58:37 +02:00
|
|
|
Utils::LinkHandler callback,
|
2020-05-06 10:26:31 +02:00
|
|
|
const bool resolveTarget);
|
2021-04-29 15:22:34 +02:00
|
|
|
|
|
|
|
|
using ResultHandler = std::function<void(const QList<LanguageServerProtocol::Location> &)>;
|
2022-08-26 10:30:00 +02:00
|
|
|
std::optional<LanguageServerProtocol::MessageId> findUsages(
|
2021-04-29 15:22:34 +02:00
|
|
|
TextEditor::TextDocument *document,
|
|
|
|
|
const QTextCursor &cursor,
|
|
|
|
|
const ResultHandler &handler = {});
|
2020-05-06 10:26:31 +02:00
|
|
|
|
2020-05-11 08:41:57 +02:00
|
|
|
bool supportsRename(TextEditor::TextDocument *document);
|
|
|
|
|
void renameSymbol(TextEditor::TextDocument *document, const QTextCursor &cursor);
|
|
|
|
|
|
2021-04-29 15:22:34 +02:00
|
|
|
static Core::Search::TextRange convertRange(const LanguageServerProtocol::Range &range);
|
2021-05-18 07:05:39 +02:00
|
|
|
static QStringList getFileContents(const Utils::FilePath &filePath);
|
2021-04-29 15:22:34 +02:00
|
|
|
|
2020-05-06 10:26:31 +02:00
|
|
|
private:
|
|
|
|
|
void handleFindReferencesResponse(
|
|
|
|
|
const LanguageServerProtocol::FindReferencesRequest::Response &response,
|
2021-04-29 15:22:34 +02:00
|
|
|
const QString &wordUnderCursor,
|
|
|
|
|
const ResultHandler &handler);
|
2020-05-06 10:26:31 +02:00
|
|
|
|
2020-05-11 08:41:57 +02:00
|
|
|
void requestPrepareRename(const LanguageServerProtocol::TextDocumentPositionParams ¶ms,
|
|
|
|
|
const QString &placeholder);
|
|
|
|
|
void requestRename(const LanguageServerProtocol::TextDocumentPositionParams &positionParams,
|
|
|
|
|
const QString &newName, Core::SearchResult *search);
|
|
|
|
|
void startRenameSymbol(const LanguageServerProtocol::TextDocumentPositionParams ¶ms,
|
|
|
|
|
const QString &placeholder);
|
|
|
|
|
void handleRenameResponse(Core::SearchResult *search,
|
|
|
|
|
const LanguageServerProtocol::RenameRequest::Response &response);
|
|
|
|
|
void applyRename(const QList<Core::SearchResultItem> &checkedItems);
|
|
|
|
|
|
2020-05-06 10:26:31 +02:00
|
|
|
Client *m_client = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace LanguageClient
|