2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2020-01-08 12:03:54 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-03-26 06:50:19 +01:00
|
|
|
#include <languageserverprotocol/languagefeatures.h>
|
2020-01-08 12:03:54 +01:00
|
|
|
|
|
|
|
|
#include <texteditor/formatter.h>
|
|
|
|
|
|
2022-09-27 13:12:20 +02:00
|
|
|
#include <QPointer>
|
|
|
|
|
|
2020-01-08 12:03:54 +01:00
|
|
|
namespace TextEditor { class TextDocument; }
|
|
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
2020-03-26 06:50:19 +01:00
|
|
|
class Client;
|
|
|
|
|
|
2020-01-08 12:03:54 +01:00
|
|
|
class LanguageClientFormatter : public TextEditor::Formatter
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
LanguageClientFormatter(TextEditor::TextDocument *document, Client *client);
|
|
|
|
|
~LanguageClientFormatter() override;
|
|
|
|
|
|
2021-01-29 13:53:20 +01:00
|
|
|
QFutureWatcher<Utils::ChangeSet> *format(
|
2020-01-08 12:03:54 +01:00
|
|
|
const QTextCursor &cursor, const TextEditor::TabSettings &tabSettings) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void cancelCurrentRequest();
|
|
|
|
|
void handleResponse(
|
|
|
|
|
const LanguageServerProtocol::DocumentRangeFormattingRequest::Response &response);
|
|
|
|
|
|
2022-09-27 13:12:20 +02:00
|
|
|
QPointer<Client> m_client = nullptr; // not owned
|
2020-01-08 12:03:54 +01:00
|
|
|
QMetaObject::Connection m_cancelConnection;
|
|
|
|
|
TextEditor::TextDocument *m_document; // not owned
|
|
|
|
|
bool m_ignoreCancel = false;
|
2021-01-29 13:53:20 +01:00
|
|
|
QFutureInterface<Utils::ChangeSet> m_progress;
|
2022-08-26 10:30:00 +02:00
|
|
|
std::optional<LanguageServerProtocol::MessageId> m_currentRequest;
|
2020-01-08 12:03:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace LanguageClient
|