blob: 4ddc9c79c081ff8323c27843b5ea72645c921563 (
plain)
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
67
68
69
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "languageclient_global.h"
#include <languageserverprotocol/lsptypes.h>
#include <texteditor/ioutlinewidget.h>
#include <utils/treemodel.h>
namespace TextEditor {
class TextDocument;
class BaseTextEditor;
} // namespace TextEditor
namespace Utils { class TreeViewComboBox; }
namespace LanguageClient {
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; }
LanguageServerProtocol::Range selectionRange() const { return m_selectionRange; }
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;
LanguageServerProtocol::Range m_selectionRange;
int m_type = -1;
};
class Client;
class LanguageClientOutlineWidgetFactory : public TextEditor::IOutlineWidgetFactory
{
public:
using IOutlineWidgetFactory::IOutlineWidgetFactory;
static Utils::TreeViewComboBox *createComboBox(Client *client, TextEditor::BaseTextEditor *editor);
// IOutlineWidgetFactory interface
public:
bool supportsEditor(Core::IEditor *editor) const override;
TextEditor::IOutlineWidget *createWidget(Core::IEditor *editor) override;
bool supportsSorting() const override { return true; }
};
} // namespace LanguageClient
|