forked from Andersbakken/rtags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndexDataMessage.h
138 lines (114 loc) · 4.29 KB
/
IndexDataMessage.h
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* This file is part of RTags (http://rtags.net).
RTags is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
RTags is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with RTags. If not, see <http://www.gnu.org/licenses/>. */
#ifndef IndexDataMessage_h
#define IndexDataMessage_h
#include "RTagsMessage.h"
#include "Diagnostic.h"
#include <rct/Message.h>
#include <rct/Serializer.h>
#include <rct/String.h>
#include "IndexerJob.h"
#include <rct/Flags.h>
class IndexDataMessage : public RTagsMessage
{
public:
enum { MessageId = IndexDataMessageId };
IndexDataMessage(const std::shared_ptr<IndexerJob> &job)
: RTagsMessage(MessageId), mParseTime(0), mKey(job->source.key()), mId(0),
mIndexerJobFlags(job->flags)
{}
IndexDataMessage()
: RTagsMessage(MessageId), mParseTime(0), mKey(0), mId(0)
{}
void encode(Serializer &serializer) const;
void decode(Deserializer &deserializer);
enum Flag {
None = 0x0,
ParseFailure = 0x1,
InclusionError = 0x2
};
Flags<Flag> flags() const { return mFlags; }
void setFlags(Flags<Flag> flags) { mFlags = flags; }
void setFlag(Flag flag, bool on = true) { mFlags.set(flag, on); }
Set<uint32_t> visitedFiles() const
{
Set<uint32_t> ret;
for (const auto &it : mFiles) {
if (it.second & Visited)
ret.insert(it.first);
}
return ret;
}
Set<uint32_t> blockedFiles() const
{
Set<uint32_t> ret;
for (const auto &it : mFiles) {
if (!(it.second & Visited))
ret.insert(it.first);
}
return ret;
}
uint32_t fileId() const
{
uint32_t fileId, buildRootId;
Source::decodeKey(mKey, fileId, buildRootId);
return fileId;
}
const Path &project() const { return mProject; }
void setProject(const Path &project) { mProject = project; }
uint64_t id() const { return mId; }
void setId(uint64_t id) { mId = id; }
uint64_t parseTime() const { return mParseTime; }
void setParseTime(uint64_t parseTime) { mParseTime = parseTime; }
Flags<IndexerJob::Flag> indexerJobFlags() const { return mIndexerJobFlags; }
void setIndexerJobFlags(Flags<IndexerJob::Flag> flags) { mIndexerJobFlags = flags; }
uint64_t key() const { return mKey; }
void setKey(uint64_t key) { mKey = key; }
const String &message() const { return mMessage; }
void setMessage(const String &msg) { mMessage = msg; }
FixIts &fixIts() { return mFixIts; }
Diagnostics &diagnostics() { return mDiagnostics; }
Includes &includes() { return mIncludes; }
Declarations &declarations() { return mDeclarations; }
enum FileFlag {
NoFileFlag = 0x0,
Visited = 0x1,
HeaderError = 0x2
};
Hash<uint32_t, Flags<FileFlag> > &files() { return mFiles; }
private:
Path mProject;
uint64_t mParseTime, mKey, mId;
Flags<IndexerJob::Flag> mIndexerJobFlags; // indexerjobflags
String mMessage; // used as output for dump when flags & Dump
FixIts mFixIts;
Diagnostics mDiagnostics;
Includes mIncludes;
Declarations mDeclarations; // function declarations and forward declaration
Hash<uint32_t, Flags<FileFlag> > mFiles;
Flags<Flag> mFlags;
};
RCT_FLAGS(IndexDataMessage::Flag);
RCT_FLAGS(IndexDataMessage::FileFlag);
inline void IndexDataMessage::encode(Serializer &serializer) const
{
serializer << mProject << mParseTime << mKey << mId << mIndexerJobFlags
<< mMessage << mFixIts << mIncludes << mDiagnostics << mFiles
<< mDeclarations << mFlags;
}
inline void IndexDataMessage::decode(Deserializer &deserializer)
{
deserializer >> mProject >> mParseTime >> mKey >> mId >> mIndexerJobFlags
>> mMessage >> mFixIts >> mIncludes >> mDiagnostics
>> mFiles >> mDeclarations >> mFlags;
}
#endif