| 1115 | } |
| 1116 | |
| 1117 | void ClangHelper::DecodeCompletionString(CXCompletionString completionString, String& displayText, String& replaceText, String& chunkText) |
| 1118 | { |
| 1119 | auto num = clang_getNumCompletionChunks(completionString); |
| 1120 | |
| 1121 | //char buf[256]; |
| 1122 | |
| 1123 | bool hadSymbol = false; |
| 1124 | for (int chunkIdx = 0; chunkIdx < (int) num; chunkIdx++) |
| 1125 | { |
| 1126 | auto chunkKind = clang_getCompletionChunkKind(completionString, chunkIdx); |
| 1127 | ToString(clang_getCompletionChunkText(completionString, chunkIdx), chunkText); |
| 1128 | |
| 1129 | switch (chunkKind) |
| 1130 | { |
| 1131 | case CXCompletionChunk_LeftParen: |
| 1132 | hadSymbol = true; |
| 1133 | replaceText += "(\x1"; |
| 1134 | break; |
| 1135 | case CXCompletionChunk_RightParen: |
| 1136 | hadSymbol = true; |
| 1137 | replaceText += "\x1)"; |
| 1138 | break; |
| 1139 | case CXCompletionChunk_Comma: |
| 1140 | replaceText += ",\x1 "; |
| 1141 | break; |
| 1142 | case CXCompletionChunk_LeftBracket: |
| 1143 | case CXCompletionChunk_RightBracket: |
| 1144 | case CXCompletionChunk_LeftBrace: |
| 1145 | case CXCompletionChunk_RightBrace: |
| 1146 | case CXCompletionChunk_LeftAngle: |
| 1147 | case CXCompletionChunk_RightAngle: |
| 1148 | case CXCompletionChunk_CurrentParameter: |
| 1149 | case CXCompletionChunk_Colon: |
| 1150 | case CXCompletionChunk_HorizontalSpace: |
| 1151 | case CXCompletionChunk_VerticalSpace: |
| 1152 | hadSymbol = true; |
| 1153 | replaceText += chunkText; |
| 1154 | break; |
| 1155 | case CXCompletionChunk_TypedText: |
| 1156 | if (!hadSymbol) |
| 1157 | { |
| 1158 | displayText += chunkText; |
| 1159 | } |
| 1160 | replaceText += chunkText; |
| 1161 | break; |
| 1162 | case CXCompletionChunk_Placeholder: |
| 1163 | for (int i = 0; i < (int)chunkText.size(); i++) |
| 1164 | if (chunkText[i] == ',') |
| 1165 | chunkText.insert(chunkText.begin() + i + 1, '\x1'); |
| 1166 | replaceText += chunkText; |
| 1167 | break; |
| 1168 | case CXCompletionChunk_ResultType: |
| 1169 | case CXCompletionChunk_Text: |
| 1170 | case CXCompletionChunk_Informative: |
| 1171 | case CXCompletionChunk_Equal: |
| 1172 | /*if (description.length() > 0) |
| 1173 | description += " "; |
| 1174 | description += chunkText;*/ |