aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/headerpathfilter.h
blob: b44a47ff299d8970f6f77ee12917f0e329ff9311 (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
// Copyright (C) 2018 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 "compileroptionsbuilder.h"
#include "projectpart.h"

#include <utils/filepath.h>

namespace CppEditor::Internal {

class HeaderPathFilter
{
public:
    HeaderPathFilter(const ProjectPart &projectPart,
                     UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::Yes,
                     const Utils::FilePath &clangIncludeDirectory = {},
                     const QString &projectDirectory = {},
                     const QString &buildDirectory = {})
        : projectPart{projectPart}
        , clangIncludeDirectory{clangIncludeDirectory}
        , projectDirectory(ensurePathWithSlashEnding(projectDirectory))
        , buildDirectory(ensurePathWithSlashEnding(buildDirectory))
        , useTweakedHeaderPaths{useTweakedHeaderPaths}
    {}

    void process();

private:
    void filterHeaderPath(const ProjectExplorer::HeaderPath &headerPath);

    void tweakHeaderPaths();

    void addPreIncludesPath();

    bool isProjectHeaderPath(const QString &path) const;

    void removeGccInternalIncludePaths();

    static QString ensurePathWithSlashEnding(const QString &path);

public:
    ProjectExplorer::HeaderPaths builtInHeaderPaths;
    ProjectExplorer::HeaderPaths systemHeaderPaths;
    ProjectExplorer::HeaderPaths userHeaderPaths;
    const ProjectPart &projectPart;
    const Utils::FilePath clangIncludeDirectory;
    const QString projectDirectory;
    const QString buildDirectory;
    const UseTweakedHeaderPaths useTweakedHeaderPaths;
};

} // namespace CppEditor::Internal