forked from Andersbakken/rtags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RClient.h
218 lines (196 loc) · 5.61 KB
/
RClient.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* 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 RClient_h
#define RClient_h
#include "QueryMessage.h"
#include "rct/List.h"
#include "rct/Message.h"
#include "rct/Path.h"
#include "rct/Set.h"
#include "rct/String.h"
class RCCommand;
class QueryCommand;
class Connection;
class RClient
{
public:
enum OptionType {
None = 0,
AbsolutePath,
AllReferences,
AllDependencies,
AllTargets,
Autotest,
BuildIndex,
CheckIncludes,
CheckReindex,
ClassHierarchy,
Clear,
CodeCompleteAt,
CompilationFlagsOnly,
CompilationFlagsSplitLine,
Compile,
ConnectTimeout,
ContainingFunction,
ContainingFunctionLocation,
CurrentFile,
CurrentProject,
CursorKind,
DebugLocations,
DeclarationOnly,
DefinitionOnly,
DeleteProject,
Dependencies,
DependencyFilter,
Diagnose,
Diagnostics,
DisplayName,
DumpCompilationDatabase,
DumpCompletions,
DumpFile,
DumpFileMaps,
DumpIncludeHeaders,
Elisp,
FilterSystemHeaders,
FindFile,
FindFilePreferExact,
FindProjectBuildRoot,
FindProjectRoot,
FindSymbols,
FindVirtuals,
FixIts,
FollowLocation,
GenerateTest,
GuessFlags,
HasFileManager,
Help,
IncludeFile,
IMenu,
IsIndexed,
IsIndexing,
JobCount,
KindFilter,
ListBuffers,
ListSymbols,
LoadCompilationDatabase,
LogFile,
Man,
MatchCaseInsensitive,
MatchRegex,
Max,
NoColor,
NoContext,
NoSortReferencesByInput,
PathFilter,
PrepareCodeCompleteAt,
PreprocessFile,
Project,
ProjectRoot,
QuitRdm,
RTagsConfig,
RangeFilter,
RdmLog,
ReferenceLocation,
ReferenceName,
Reindex,
ReloadFileManager,
RemoveFile,
Rename,
ReverseSort,
SendDiagnostics,
SetBuffers,
Silent,
SilentQuery,
SocketAddress,
SocketFile,
Sources,
Status,
StripParen,
Suspend,
SymbolInfo,
SymbolInfoIncludeParents,
SymbolInfoExcludeReferences,
SymbolInfoExcludeTargets,
SynchronousCompletions,
Timeout,
UnsavedFile,
Verbose,
Version,
Wait,
WildcardSymbolNames,
NumOptions
};
enum Flag {
Flag_None = 0x0,
Flag_Autotest = 0x1
};
RClient();
~RClient();
int exec();
enum ParseStatus {
Parse_Exec,
Parse_Ok,
Parse_Error
};
ParseStatus parse(int &argc, char **argv);
Flags<Flag> flags() const { return mFlags; }
int max() const { return mMax; }
LogLevel logLevel() const { return mLogLevel; }
int timeout() const { return mTimeout; }
int buildIndex() const { return mBuildIndex; }
const Set<QueryMessage::PathFilter> &pathFilters() const { return mPathFilters; }
int minOffset() const { return mMinOffset; }
int maxOffset() const { return mMaxOffset; }
const Set<String> &kindFilters() const { return mKindFilters; }
const UnsavedFiles &unsavedFiles() const { return mUnsavedFiles; }
const List<String> &rdmArgs() const { return mRdmArgs; }
const Path ¤tFile() const { return mCurrentFile; }
String socketFile() const { return mSocketFile; }
String tcpHost() const { return mTcpHost; }
uint16_t tcpPort() const { return mTcpPort; }
Path projectRoot() const { return mProjectRoot; }
Flags<QueryMessage::Flag> queryFlags() const { return mQueryFlags; }
int terminalWidth() const { return mTerminalWidth; }
int argc() const { return mArgc; }
char **argv() const { return mArgv; }
void onNewMessage(const std::shared_ptr<Message> &message, const std::shared_ptr<Connection> &);
List<Path> pathEnvironment() const;
private:
void addQuery(QueryMessage::Type t, const String &query = String(),
Flags<QueryMessage::Flag> extraQueryFlags = Flags<QueryMessage::Flag>());
void addQuitCommand(int exitCode);
void addLog(LogLevel level);
void addCompile(const Path &cwd, const String &args);
void addCompile(const Path &dir);
Flags<Flag> mFlags;
Flags<QueryMessage::Flag> mQueryFlags;
int mMax, mTimeout, mMinOffset, mMaxOffset, mConnectTimeout, mBuildIndex;
LogLevel mLogLevel;
Set<QueryMessage::PathFilter> mPathFilters;
Set<String> mKindFilters;
UnsavedFiles mUnsavedFiles;
List<std::shared_ptr<RCCommand> > mCommands;
List<String> mRdmArgs;
Path mSocketFile;
Path mCurrentFile;
String mTcpHost;
uint16_t mTcpPort;
bool mGuessFlags;
Path mProjectRoot;
int mTerminalWidth;
mutable List<Path> mPathEnvironment;
int mArgc;
char **mArgv;
friend class CompileCommand;
};
RCT_FLAGS(RClient::Flag);
#endif