aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/mcusupport/mcusupportimportprovider.h
blob: f7457751b0b4443d694f3470aaa1cb4367dcf9d4 (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) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "mcusupport_global.h"
#include "mcusupportplugin.h"

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

namespace McuSupport::Internal {
using namespace QmlJS;
using namespace Utils;
class McuSupportImportProvider : public CustomImportsProvider
{
public:
    McuSupportImportProvider() {}
    ~McuSupportImportProvider() {}

    // Overridden functions
    QList<Import> imports(ValueOwner *valueOwner,
                          const Document *context,
                          Snapshot *snapshot) const override;
    void loadBuiltins(ImportsPerDocument *importsPerDocument,
                      Imports *imports,
                      const Document *context,
                      ValueOwner *valueOwner,
                      Snapshot *snapshot) override;

    virtual Utils::FilePaths prioritizeImportPaths(const Document *context,
                                                   const Utils::FilePaths &importPaths) override;

    // Add to the interfaces needed for a document
    // path: opened qml document
    // importsPerDocument: imports available in the document (considered imported)
    // import: qul import containing builtin types (interfaces)
    // valueOwner: imports members owner
    // snapshot: where qul documenents live
    void getInterfacesImport(const FilePath &path,
                             ImportsPerDocument *importsPerDocument,
                             Import &import,
                             ValueOwner *valueOwner,
                             Snapshot *snapshot) const;

    // Get the qmlproject module which a qmlfile is part of
    // nullopt means the file is part of the main project
    std::optional<FilePath> getFileModule(const FilePath &file, const FilePath &inputFile) const;
};
}; // namespace McuSupport::Internal