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

#pragma once

#include <projectexplorer/task.h>
#include <qmljs/qmljsdocument.h>
#include <qmljs/qmljsmodelmanagerinterface.h>

#include <QObject>
#include <QList>
#include <QHash>
#include <QString>
#include <QFutureWatcher>
#include <QTimer>

namespace QmlJSEditor {
namespace Internal {

class QmlTaskManager : public QObject
{
    Q_OBJECT
public:
    QmlTaskManager();

    void extensionsInitialized();

    void updateMessages();
    void updateSemanticMessagesNow();
    void documentsRemoved(const Utils::FilePaths &path);

private:
    void displayResults(int begin, int end);
    void displayAllResults();
    void updateMessagesNow(bool updateSemantic = false);

    void insertTask(const ProjectExplorer::Task &task);
    void removeTasksForFile(const Utils::FilePath &fileName);
    void removeAllTasks(bool clearSemantic);

private:
    class FileErrorMessages
    {
    public:
        Utils::FilePath fileName;
        ProjectExplorer::Tasks tasks;
    };
    static void collectMessages(QPromise<FileErrorMessages> &promise,
                                QmlJS::Snapshot snapshot,
                                const QList<QmlJS::ModelManagerInterface::ProjectInfo> &projectInfos,
                                QmlJS::ViewerContext vContext,
                                bool updateSemantic);

private:
    QHash<Utils::FilePath, ProjectExplorer::Tasks> m_docsWithTasks;
    QFutureWatcher<FileErrorMessages> m_messageCollector;
    QTimer m_updateDelay;
    bool m_updatingSemantic = false;
};

} // Internal
} // QmlJSEditor