1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// 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
#pragma once
#include "languageclient_global.h"
#include <coreplugin/find/searchresultitem.h>
#include <texteditor/textdocument.h>
#include <languageserverprotocol/languagefeatures.h>
namespace Core {
class SearchResult;
class SearchResultItem;
}
namespace LanguageServerProtocol { class MessageId; }
namespace LanguageClient {
class Client;
class LANGUAGECLIENT_EXPORT SymbolSupport
{
Q_DECLARE_TR_FUNCTIONS(SymbolSupport)
public:
explicit SymbolSupport(Client *client);
void findLinkAt(TextEditor::TextDocument *document,
const QTextCursor &cursor,
Utils::LinkHandler callback,
const bool resolveTarget);
using ResultHandler = std::function<void(const QList<LanguageServerProtocol::Location> &)>;
Utils::optional<LanguageServerProtocol::MessageId> findUsages(
TextEditor::TextDocument *document,
const QTextCursor &cursor,
const ResultHandler &handler = {});
bool supportsRename(TextEditor::TextDocument *document);
void renameSymbol(TextEditor::TextDocument *document, const QTextCursor &cursor);
static Core::Search::TextRange convertRange(const LanguageServerProtocol::Range &range);
static QStringList getFileContents(const Utils::FilePath &filePath);
private:
void handleFindReferencesResponse(
const LanguageServerProtocol::FindReferencesRequest::Response &response,
const QString &wordUnderCursor,
const ResultHandler &handler);
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);
Client *m_client = nullptr;
};
} // namespace LanguageClient
|