aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/languageclient/languageclientoutline.h
blob: 7476cb2741d6db472ae092b8e3cb5c1c67349f79 (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
// 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 <utils/treemodel.h>

namespace TextEditor { class BaseTextEditor; }
namespace Utils { class TreeViewComboBox; }

namespace LanguageClient {
class Client;

class LANGUAGECLIENT_EXPORT LanguageClientOutlineItem
    : public Utils::TypedTreeItem<LanguageClientOutlineItem>
{
public:
    enum ItemDataRoles {
        AnnotationRole = Qt::UserRole + 1,
    };

    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);
    }

    bool valid() const { return m_client; }

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;
};

Utils::TreeViewComboBox *createOutlineComboBox(Client *client, TextEditor::BaseTextEditor *editor);

void setupLanguageClientOutline();

} // namespace LanguageClient