aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppprojectpartchooser.h
blob: 75a415a880bd0aa27fffc37c70141fde02be4fc2 (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
// 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 "cpptoolsreuse.h"
#include "projectpart.h"

#include <functional>

namespace ProjectExplorer { class Project; }

namespace CppEditor::Internal {

class ProjectPartChooser
{
public:
    using FallBackProjectPart = std::function<ProjectPart::ConstPtr()>;
    using ProjectPartsForFile = std::function<QList<ProjectPart::ConstPtr>(const QString &filePath)>;
    using ProjectPartsFromDependenciesForFile
        = std::function<QList<ProjectPart::ConstPtr>(const QString &filePath)>;

public:
    void setFallbackProjectPart(const FallBackProjectPart &getter);
    void setProjectPartsForFile(const ProjectPartsForFile &getter);
    void setProjectPartsFromDependenciesForFile(const ProjectPartsFromDependenciesForFile &getter);

    ProjectPartInfo choose(const QString &filePath,
            const ProjectPartInfo &currentProjectPartInfo,
            const QString &preferredProjectPartId,
            const Utils::FilePath &activeProject,
            Utils::Language languagePreference,
            bool projectsUpdated) const;

private:
    FallBackProjectPart m_fallbackProjectPart;
    ProjectPartsForFile m_projectPartsForFile;
    ProjectPartsFromDependenciesForFile m_projectPartsFromDependenciesForFile;
};

} // namespace CppEditor::Internal