2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 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
|
2018-11-23 09:45:51 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-02-03 14:46:00 +01:00
|
|
|
#include "languageclient_global.h"
|
|
|
|
|
|
|
|
|
|
#include <languageserverprotocol/lsptypes.h>
|
2018-11-23 09:45:51 +01:00
|
|
|
#include <texteditor/ioutlinewidget.h>
|
2023-02-03 14:46:00 +01:00
|
|
|
#include <utils/treemodel.h>
|
2018-11-23 09:45:51 +01:00
|
|
|
|
2022-01-06 09:48:06 +01:00
|
|
|
namespace TextEditor {
|
|
|
|
|
class TextDocument;
|
|
|
|
|
class BaseTextEditor;
|
|
|
|
|
} // namespace TextEditor
|
2020-01-27 14:52:46 +01:00
|
|
|
namespace Utils { class TreeViewComboBox; }
|
|
|
|
|
|
2018-11-23 09:45:51 +01:00
|
|
|
namespace LanguageClient {
|
2023-02-03 14:46:00 +01:00
|
|
|
class Client;
|
|
|
|
|
|
|
|
|
|
class LANGUAGECLIENT_EXPORT LanguageClientOutlineItem
|
|
|
|
|
: public Utils::TypedTreeItem<LanguageClientOutlineItem>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
LanguageClientOutlineItem() = default;
|
|
|
|
|
LanguageClientOutlineItem(const LanguageServerProtocol::SymbolInformation &info);
|
|
|
|
|
LanguageClientOutlineItem(Client *client, const LanguageServerProtocol::DocumentSymbol &info);
|
|
|
|
|
|
|
|
|
|
LanguageServerProtocol::Range range() const { return m_range; }
|
2023-02-03 15:29:12 +01:00
|
|
|
LanguageServerProtocol::Range selectionRange() const { return m_selectionRange; }
|
2023-02-03 14:46:00 +01:00
|
|
|
LanguageServerProtocol::Position pos() const { return m_range.start(); }
|
|
|
|
|
bool contains(const LanguageServerProtocol::Position &pos) const {
|
|
|
|
|
return m_range.contains(pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// TreeItem interface
|
|
|
|
|
QVariant data(int column, int role) const override;
|
|
|
|
|
Qt::ItemFlags flags(int column) const override;
|
|
|
|
|
|
|
|
|
|
QString name() const { return m_name; }
|
|
|
|
|
QString detail() const { return m_detail; }
|
|
|
|
|
int type() const { return m_type; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Client * const m_client = nullptr;
|
|
|
|
|
QString m_name;
|
|
|
|
|
QString m_detail;
|
|
|
|
|
LanguageServerProtocol::Range m_range;
|
2023-02-03 15:29:12 +01:00
|
|
|
LanguageServerProtocol::Range m_selectionRange;
|
2023-02-03 14:46:00 +01:00
|
|
|
int m_type = -1;
|
|
|
|
|
};
|
2018-11-23 09:45:51 +01:00
|
|
|
|
2020-01-27 14:52:46 +01:00
|
|
|
class Client;
|
|
|
|
|
|
2018-11-23 09:45:51 +01:00
|
|
|
class LanguageClientOutlineWidgetFactory : public TextEditor::IOutlineWidgetFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
using IOutlineWidgetFactory::IOutlineWidgetFactory;
|
|
|
|
|
|
2022-01-06 09:48:06 +01:00
|
|
|
static Utils::TreeViewComboBox *createComboBox(Client *client, TextEditor::BaseTextEditor *editor);
|
2018-11-23 09:45:51 +01:00
|
|
|
// IOutlineWidgetFactory interface
|
|
|
|
|
public:
|
|
|
|
|
bool supportsEditor(Core::IEditor *editor) const override;
|
|
|
|
|
TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor) override;
|
2022-02-04 11:27:35 +01:00
|
|
|
bool supportsSorting() const override { return true; }
|
2018-11-23 09:45:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace LanguageClient
|