-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathResult.cpp
154 lines (101 loc) · 3.06 KB
/
Result.cpp
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
#include "Result.h"
#include <clang-c/Index.h>
#include <wx/intl.h>
wxString getCompletionString(CXCompletionString str)
{
int numOfChunks = clang_getNumCompletionChunks(str);
for (int i =0 ; i< numOfChunks; i++)
if (clang_getCompletionChunkKind(str,i) == CXCompletionChunk_TypedText)
{
CXString str2 = clang_getCompletionChunkText(str,i);
const char* str3 = clang_getCString(str2);
wxString resulting = wxString(str3,wxConvUTF8);
clang_disposeString(str2);
return resulting;
}
}
int getImageNum(CXCursorKind kind, CX_CXXAccessSpecifier spec)
{
int result;
switch(kind)
{
case CXCursor_CXXMethod:
case CXCursor_FunctionDecl:
if (spec == CX_CXXPublic || spec == CX_CXXInvalidAccessSpecifier)
result = 13;
else if (spec == CX_CXXProtected)
result = 12;
else if (spec == CX_CXXPrivate)
result = 11;
break;
case CXCursor_FieldDecl:
if (spec == CX_CXXPublic)
result = 16;
else if (spec == CX_CXXProtected)
result = 15;
else if (spec == CX_CXXPrivate)
result = 14;
break;
case CXCursor_EnumDecl:
if (spec == CX_CXXPublic || spec == CX_CXXInvalidAccessSpecifier)
result = 21;
else if (spec == CX_CXXProtected)
result = 20;
else if (spec == CX_CXXPrivate)
result = 19;
break;
case CXCursor_EnumConstantDecl:
result = 22;
break;
case CXCursor_Constructor:
if (spec == CX_CXXPublic || spec == CX_CXXInvalidAccessSpecifier)
result = 7;
else if (spec == CX_CXXProtected)
result = 6;
else if (spec == CX_CXXPrivate)
result = 5;
break;
case CXCursor_ClassDecl:
case CXCursor_StructDecl:
if (spec == CX_CXXPublic)
result = 4;
else if (spec == CX_CXXProtected)
result = 3;
else if (spec == CX_CXXPrivate)
result = 2;
else if (spec == CX_CXXInvalidAccessSpecifier)
result = 1;
break;
case CXCursor_Destructor:
if (spec == CX_CXXPublic)
result = 10;
else if (spec == CX_CXXProtected)
result = 9;
else if (spec == CX_CXXPrivate)
result = 8;
break;
case CXCursor_VarDecl:
result = 16;
break;
case CXCursor_MacroDefinition:
result = 35;
break;
default:
result = 40;
break;
}
return result;
}
Result::Result(CXCompletionResult result)
{
CXCompletionString str = result.CompletionString;
CXCursorKind kind = result.CursorKind;
int type = getImageNum(kind,CX_CXXPublic);
string = getCompletionString(str) + wxString::Format(_T("?%d"),type);
rank = clang_getCompletionPriority(str);
good = (clang_getCompletionAvailability(str) == CXAvailability_Available && string.GetChar(0) != '_');
}
bool Result::isGood()
{
return good;
}