aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmljstools/qmljslocatordata.h
blob: d89796568c4b8a26f4aa56c38c5538f8c68e44e4 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include <utils/filepath.h>
#include <qmljs/qmljsdocument.h>

#include <QObject>
#include <QHash>
#include <QMutex>

namespace QmlJSTools {
namespace Internal {

class LocatorData : public QObject
{
    Q_OBJECT
public:
    LocatorData();
    ~LocatorData() override;

    enum EntryType
    {
        Function
    };

    class Entry
    {
    public:
        EntryType type;
        QString symbolName;
        QString displayName;
        QString extraInfo;
        Utils::FilePath fileName;
        int line;
        int column;
    };

    QHash<Utils::FilePath, QList<Entry>> entries() const;

private:
    void onDocumentUpdated(const QmlJS::Document::Ptr &doc);
    void onAboutToRemoveFiles(const Utils::FilePaths &files);

    mutable QMutex m_mutex;
    QHash<Utils::FilePath, QList<Entry>> m_entries;
};

} // namespace Internal
} // namespace QmlJSTools