aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/designercore/projectstorage/modulescanner.h
blob: 64b672de8e3ecaa4d262484ad9c60c87f62a3655 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <qmldesignercorelib_global.h>

#include <externaldependenciesinterface.h>
#include <import.h>

#include <optional>

namespace QmlDesigner {

enum class VersionScanning { No, Yes };

class QMLDESIGNERCORE_EXPORT ModuleScanner
{
public:
    using SkipFunction = std::function<bool(QStringView)>;

    ModuleScanner([[maybe_unused]] SkipFunction skip,
                  [[maybe_unused]] VersionScanning versionScanning,
                  ExternalDependenciesInterface &externalDependencies)
#ifdef QDS_HAS_QMLPRIVATE
        : m_skip{std::move(skip)}
        , m_versionScanning{versionScanning}
        , m_externalDependencies{externalDependencies}
#endif
    {
        m_modules.reserve(128);
    }

    void scan(const QStringList &modulePaths);

    const Imports &modules() const { return m_modules; }

private:
    void scan(std::string_view modulePaths);

private:
    Imports m_modules;
#ifdef QDS_HAS_QMLPRIVATE
    SkipFunction m_skip;
    VersionScanning m_versionScanning;
    ExternalDependenciesInterface &m_externalDependencies;
#endif
};

} // namespace QmlDesigner