2020-09-09 08:15:11 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2020 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-04-01 07:34:49 +02:00
|
|
|
#include "languageclient_global.h"
|
|
|
|
|
|
2020-09-09 08:15:11 +02:00
|
|
|
#include <languageserverprotocol/lsptypes.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/id.h>
|
|
|
|
|
|
|
|
|
|
#include <QMap>
|
2022-04-12 14:37:29 +02:00
|
|
|
#include <QTextEdit>
|
2020-09-09 08:15:11 +02:00
|
|
|
|
2021-06-02 17:51:31 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
class TextDocument;
|
|
|
|
|
class TextMark;
|
|
|
|
|
}
|
2020-09-09 08:15:11 +02:00
|
|
|
|
|
|
|
|
namespace LanguageClient {
|
|
|
|
|
|
2021-06-22 15:28:35 +02:00
|
|
|
class Client;
|
|
|
|
|
|
2022-04-01 07:34:49 +02:00
|
|
|
class LANGUAGECLIENT_EXPORT DiagnosticManager : public QObject
|
2020-09-09 08:15:11 +02:00
|
|
|
{
|
2022-04-01 07:34:49 +02:00
|
|
|
Q_OBJECT
|
2020-09-09 08:15:11 +02:00
|
|
|
public:
|
2021-06-22 15:28:35 +02:00
|
|
|
explicit DiagnosticManager(Client *client);
|
2022-04-12 14:37:29 +02:00
|
|
|
~DiagnosticManager() override;
|
2020-09-09 08:15:11 +02:00
|
|
|
|
2022-04-01 07:34:49 +02:00
|
|
|
virtual void setDiagnostics(const LanguageServerProtocol::DocumentUri &uri,
|
|
|
|
|
const QList<LanguageServerProtocol::Diagnostic> &diagnostics,
|
|
|
|
|
const Utils::optional<int> &version);
|
2020-09-09 08:15:11 +02:00
|
|
|
|
2022-04-01 07:34:49 +02:00
|
|
|
virtual void showDiagnostics(const LanguageServerProtocol::DocumentUri &uri, int version);
|
|
|
|
|
virtual void hideDiagnostics(const Utils::FilePath &filePath);
|
|
|
|
|
virtual QList<LanguageServerProtocol::Diagnostic> filteredDiagnostics(
|
|
|
|
|
const QList<LanguageServerProtocol::Diagnostic> &diagnostics) const;
|
2020-09-09 08:15:11 +02:00
|
|
|
|
|
|
|
|
void clearDiagnostics();
|
|
|
|
|
|
|
|
|
|
QList<LanguageServerProtocol::Diagnostic> diagnosticsAt(
|
|
|
|
|
const LanguageServerProtocol::DocumentUri &uri,
|
2021-02-01 14:16:34 +01:00
|
|
|
const QTextCursor &cursor) const;
|
2021-06-02 17:51:31 +02:00
|
|
|
bool hasDiagnostic(const LanguageServerProtocol::DocumentUri &uri,
|
|
|
|
|
const TextEditor::TextDocument *doc,
|
|
|
|
|
const LanguageServerProtocol::Diagnostic &diag) const;
|
2022-05-11 06:38:50 +02:00
|
|
|
bool hasDiagnostics(const TextEditor::TextDocument *doc) const;
|
2021-06-02 17:51:31 +02:00
|
|
|
|
2022-04-01 07:34:49 +02:00
|
|
|
signals:
|
|
|
|
|
void textMarkCreated(const Utils::FilePath &path);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
Client *client() const { return m_client; }
|
|
|
|
|
virtual TextEditor::TextMark *createTextMark(const Utils::FilePath &filePath,
|
|
|
|
|
const LanguageServerProtocol::Diagnostic &diagnostic,
|
|
|
|
|
bool isProjectFile) const;
|
2022-04-12 14:37:29 +02:00
|
|
|
virtual QTextEdit::ExtraSelection createDiagnosticSelection(
|
|
|
|
|
const LanguageServerProtocol::Diagnostic &diagnostic, QTextDocument *textDocument) const;
|
|
|
|
|
|
|
|
|
|
void setExtraSelectionsId(const Utils::Id &extraSelectionsId);
|
2020-09-09 08:15:11 +02:00
|
|
|
|
|
|
|
|
private:
|
2022-04-12 14:37:29 +02:00
|
|
|
struct VersionedDiagnostics
|
|
|
|
|
{
|
2021-02-01 14:16:34 +01:00
|
|
|
Utils::optional<int> version;
|
|
|
|
|
QList<LanguageServerProtocol::Diagnostic> diagnostics;
|
|
|
|
|
};
|
|
|
|
|
QMap<LanguageServerProtocol::DocumentUri, VersionedDiagnostics> m_diagnostics;
|
2022-02-22 10:29:10 +01:00
|
|
|
QMap<Utils::FilePath, QList<TextEditor::TextMark *>> m_marks;
|
2021-06-22 15:28:35 +02:00
|
|
|
Client *m_client;
|
2022-04-12 14:37:29 +02:00
|
|
|
Utils::Id m_extraSelectionsId;
|
2020-09-09 08:15:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace LanguageClient
|