-
Notifications
You must be signed in to change notification settings - Fork 8
/
clangproxy.h
106 lines (90 loc) · 3.39 KB
/
clangproxy.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
#ifndef CLANGPROXY_H
#define CLANGPROXY_H
#include <map>
#include <vector>
#include <wx/string.h>
class TranslationUnit;
class TokenDatabase;
typedef void* CXIndex;
typedef int FileId;
enum TokenCategory
{
tcClassFolder,
tcClass, tcClassPrivate,
tcClassProtected, tcClassPublic,
tcCtorPrivate, tcCtorProtected,
tcCtorPublic,
tcDtorPrivate, tcDtorProtected,
tcDtorPublic,
tcFuncPrivate, tcFuncProtected,
tcFuncPublic,
tcVarPrivate, tcVarProtected,
tcVarPublic,
tcMacroDef,
tcEnum, tcEnumPrivate,
tcEnumProtected, tcEnumPublic,
tcEnumerator,
tcNamespace,
tcTypedef, tcTypedefPrivate,
tcTypedefProtected, tcTypedefPublic,
tcSymbolsFolder,
tcVarsFolder,
tcFuncsFolder,
tcEnumsFolder,
tcPreprocFolder,
tcOthersFolder,
tcTypedefFolder,
tkMacroUse, tcMacroPrivate,
tcMacroProtected, tcMacroPublic,
tcMacroFolder,
tcLangKeyword, // added
tcNone = -1
};
struct ClToken // TODO: do we want this, or is just using CCToken good enough?
{
ClToken(const wxString& nm, int _id, int _weight, int categ) :
id(_id), category(categ), weight(_weight), name(nm) {}
int id;
int category;
int weight;
wxString name;
};
enum Severity { sWarning, sError };
struct ClDiagnostic
{
ClDiagnostic(int ln, int rgStart, int rgEnd, Severity level, const wxString& fl, const wxString& msg) :
line(ln), range(rgStart, rgEnd), severity(level), file(fl), message(msg) {}
int line;
std::pair<int, int> range;
Severity severity;
wxString file;
wxString message;
};
class ClangProxy
{
public:
ClangProxy(TokenDatabase& database, const std::vector<wxString>& cppKeywords);
~ClangProxy();
void CreateTranslationUnit(const wxString& filename, const wxString& commands);
int GetTranslationUnitId(FileId fId);
int GetTranslationUnitId(const wxString& filename);
void CodeCompleteAt(bool isAuto, const wxString& filename, int line, int column, int translId,
const std::map<wxString, wxString>& unsavedFiles, std::vector<ClToken>& results);
wxString DocumentCCToken(int translId, int tknId);
wxString GetCCInsertSuffix(int translId, int tknId, const wxString& newLine, std::pair<int, int>& offsets);
void RefineTokenType(int translId, int tknId, int& tknType); // TODO: cache TokenId (if resolved) for DocumentCCToken()
void GetCallTipsAt(const wxString& filename, int line, int column, int translId,
const wxString& tokenStr, std::vector<wxStringVec>& results);
void GetTokensAt(const wxString& filename, int line, int column, int translId, std::vector<wxString>& results);
void GetOccurrencesOf(const wxString& filename, int line, int column,
int translId, std::vector< std::pair<int, int> >& results);
void ResolveTokenAt(wxString& filename, int& line, int& column, int translId);
void Reparse(int translId, const std::map<wxString, wxString>& unsavedFiles);
void GetDiagnostics(int translId, std::vector<ClDiagnostic>& diagnostics);
private:
TokenDatabase& m_Database;
const std::vector<wxString>& m_CppKeywords;
std::vector<TranslationUnit> m_TranslUnits;
CXIndex m_ClIndex;
};
#endif // CLANGPROXY_H