clangdocuments.h 3.75 KB
Newer Older
1
2
/****************************************************************************
**
3
4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
5
6
7
8
9
10
11
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
12
13
14
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
15
**
16
17
18
19
20
21
22
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23
24
25
**
****************************************************************************/

hjk's avatar
hjk committed
26
#pragma once
27

28
#include "clangdocument.h"
29
#include "clangfilesystemwatcher.h"
Marco Bubke's avatar
Marco Bubke committed
30

31
#include <filecontainer.h>
Marco Bubke's avatar
Marco Bubke committed
32

33
34
35
36
#include <QVector>

#include <vector>

37
namespace ClangBackEnd {
38
39
40

class ProjectParts;
class UnsavedFiles;
41

42
class Documents
43
44
{
public:
45
    Documents(ProjectParts &projectParts, UnsavedFiles &unsavedFiles);
46

47
    std::vector<Document> create(const QVector<FileContainer> &fileContainers);
48
    std::vector<Document> update(const QVector<FileContainer> &fileContainers);
49
50
    void remove(const QVector<FileContainer> &fileContainers);

51
52
    void setUsedByCurrentEditor(const Utf8String &filePath);
    void setVisibleInEditors(const Utf8StringVector &filePaths);
53

54
55
56
57
    const Document &document(const Utf8String &filePath, const Utf8String &projectPartId) const;
    const Document &document(const FileContainer &fileContainer) const;
    bool hasDocument(const Utf8String &filePath, const Utf8String &projectPartId) const;
    bool hasDocumentWithFilePath(const Utf8String &filePath) const;
58

59
    const std::vector<Document> &documents() const;
60

61
    UnsavedFiles unsavedFiles() const;
62
63
64

    void addWatchedFiles(QSet<Utf8String> &filePaths);

65
66
67
    void updateDocumentsWithChangedDependency(const Utf8String &filePath);
    void updateDocumentsWithChangedDependencies(const QVector<FileContainer> &fileContainers);
    void setDocumentsDirtyIfProjectPartChanged();
68
69
70

    QVector<FileContainer> newerFileContainers(const QVector<FileContainer> &fileContainers) const;

71
72
    const ClangFileSystemWatcher *clangFileSystemWatcher() const;

73
private:
74
    Document createDocument(const FileContainer &fileContainer);
75
    std::vector<Document> updateDocument(const FileContainer &fileContainer);
76
77
78
79
    std::vector<Document>::iterator findDocument(const FileContainer &fileContainer);
    std::vector<Document> findAllDocumentsWithFilePath(const Utf8String &filePath);
    std::vector<Document>::const_iterator findDocument(const Utf8String &filePath, const Utf8String &projectPartId) const;
    bool hasDocument(const FileContainer &fileContainer) const;
80
81
    void checkIfProjectPartExists(const Utf8String &projectFileName) const;
    void checkIfProjectPartsExists(const QVector<FileContainer> &fileContainers) const;
82
83
    void checkIfDocumentsDoNotExist(const QVector<FileContainer> &fileContainers) const;
    void checkIfDocumentsForFilePathsExist(const QVector<FileContainer> &fileContainers) const;
84

85
    void removeDocuments(const QVector<FileContainer> &fileContainers);
86
87

private:
88
    ClangFileSystemWatcher fileSystemWatcher;
89
    std::vector<Document> documents_;
90
91
    ProjectParts &projectParts;
    UnsavedFiles &unsavedFiles_;
92
93
};

94
} // namespace ClangBackEnd